How can I create a right click menu item to manipulate a junction point?

981

Solution 1

Since you asked if such solutions exist already, have you taken a look at Junction Link Magic or Link Shell Extension?

Junction Link Magic allows creation, modification, and removal of junction points. It is freeware, and does support Windows 7.

Link Shell Extension also provides the same functionality, and is also freeware. It also supports Windows 7.

UPDATE: The original site for Junction Link Magic is 404'ing now. I've substituted a Softpedia link for those who still want to install JLM.

Solution 2

I just use MKLINK which is built into Windows 7. You'll end up writing batch files I guess, but it's not hard to use.

Share:
981

Related videos on Youtube

terrible-coder
Author by

terrible-coder

Updated on September 17, 2022

Comments

  • terrible-coder
    terrible-coder almost 2 years

    It is my first time creating a program which will connect to a database to fetch the data and place it in a JTable.

    Now the problem is I want to select a row from the above table and display the results in the specified JTextFields.

    I have tried many search results provided by Google but I can't still figure out how to do it.

    Here is the complete source code for the program.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import javax.swing.table.*;
    
    public class MalayaUniversityEnrollment extends JFrame //implements ActionListener
    {
    JLabel header = new JLabel ("MALAYA UNIVERSITY ENROLLMENT SYSTEM");
    
    JLabel searchHeader = new JLabel ("SEARCH A STUDENT ");
    JLabel infoHeader = new JLabel ("STUDENT INFORMATION");
    
    JButton addButton = new JButton ("ENROLL STUDENT");
    JButton editButton = new JButton ("EDIT INFO");
    JButton deleteButton = new JButton ("DELETE STUDENT");
    JButton searchButton = new JButton ("SEARCH IT!");
    JButton clearButton = new JButton ("CLEAR ALL FIELDS");
    
    JTextField studentIDField = new JTextField();
    JTextField lastNameField = new JTextField();
    JTextField firstNameField = new JTextField();
    JTextField middleInitialField = new JTextField();
    JTextField CYSField = new JTextField();
    JTextField tuitionField = new JTextField();
    JTextField statusField = new JTextField();
    JTextField searchField = new JTextField();
    
    JLabel studentIDLabel = new JLabel ("Student ID Number: ");
    JLabel lastNameLabel = new JLabel ("Last Name: ");
    JLabel firstNameLabel = new JLabel ("First Name: ");
    JLabel middleInitialLabel = new JLabel ("Middle Initial: ");
    JLabel CYSLabel = new JLabel ("CYS: ");
    JLabel tuitionLabel = new JLabel ("Semestral Tuition: ");
    JLabel statusLabel = new JLabel ("Status: ");
    private final JTable table = new JTable();
    private final JScrollPane scrollPane = new JScrollPane();
    
    String SID ="";
    String lastName="";
    String firstName="";
    String middleInitial="";
    String CYS="";
    Double semestralTuition=0.00;
    String studentStatus="";
    
    String[] headers = {"Student ID", "Last Name", "First Name", "Middle Initial","CYS", "Semestral Tuition", "Status"};
    
    DefaultTableModel model = new DefaultTableModel();
    
    public MalayaUniversityEnrollment()
    {
        super ("Malaya University [Enrollment]");
    
        Container c = getContentPane();
        c.setLayout(null);
    
        c.add(header);
        header.setBounds(290,20,1000,35);
        header.setFont(new Font("Tahoma", Font.PLAIN, 35));
    
        c.add(addButton);
        c.add(editButton);
        c.add(deleteButton);
        c.add(searchButton);
        c.add(clearButton);
    
        c.add(searchHeader);
        c.add(infoHeader);
    
        c.add(studentIDField);
        c.add(lastNameField);
        c.add(firstNameField);
        c.add(middleInitialField);
        c.add(CYSField);
        c.add(tuitionField);
        c.add(statusField);
        c.add(searchField);
    
        c.add(studentIDLabel);
        c.add(lastNameLabel);
        c.add(firstNameLabel);
        c.add(middleInitialLabel);
        c.add(CYSLabel);
        c.add(tuitionLabel);
        c.add(statusLabel);
    
        studentIDLabel.setBounds(50,575,100,30);
        lastNameLabel.setBounds(50,615,100,30);
        firstNameLabel.setBounds(50,660,100,30);
        middleInitialLabel.setBounds(50,700,100,30);
    
        studentIDField.setBounds(175,575,200,30);
        lastNameField.setBounds(175,615,200,30);
        firstNameField.setBounds(175,660,200,30);
        middleInitialField.setBounds(175,700,200,30);
    
        CYSLabel.setBounds(450,575,100,30);
        tuitionLabel.setBounds(450,615,100,30);
        statusLabel.setBounds(450,660,100,30);
    
        CYSField.setBounds(575,575,200,30);
        tuitionField.setBounds(575,615,200,30);
        statusField.setBounds(575,660,200,30);
    
        infoHeader.setBounds(270,525,500,50);
        infoHeader.setFont(new Font("Tahoma", Font.PLAIN, 30));
    
        searchField.setBounds(885,638,300,30);
        searchHeader.setBounds(895,575,300,50);
        searchHeader.setFont(new Font("Tahoma", Font.PLAIN, 30));
    
        searchButton.setBounds(938,688,200,23);
    
        addButton.setBounds(450,700,146,23);
        editButton.setBounds(630,700,146,23);
        deleteButton.setBounds(450,733,146,23);
        clearButton.setBounds(630,733,146,23);
    
        studentIDField.setHorizontalAlignment(JTextField.CENTER);
        lastNameField.setHorizontalAlignment(JTextField.CENTER);
        firstNameField.setHorizontalAlignment(JTextField.CENTER);
        middleInitialField.setHorizontalAlignment(JTextField.CENTER);
        CYSField.setHorizontalAlignment(JTextField.CENTER);
        tuitionField.setHorizontalAlignment(JTextField.CENTER);
        statusField.setHorizontalAlignment(JTextField.CENTER);
        searchField.setHorizontalAlignment(JTextField.CENTER);
    
    
        scrollPane.setBounds(50, 88, 1190, 412);
    
        getContentPane().add(scrollPane);
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        table.setShowGrid(true);
    
        model.setColumnIdentifiers(headers);
        table.setModel(model);
        scrollPane.setViewportView(table);
    
        JTableHeader header = table.getTableHeader();
    
        header.setDefaultRenderer(new HeaderRenderer(table));
    
        table.getTableHeader().setReorderingAllowed(false);
    
    
    
        setSize(1300,825);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
    
        for (int y=0; y<7; y++)
        {
            DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
            centerRenderer.setHorizontalAlignment( JLabel.CENTER );
            table.getColumnModel().getColumn(y).setCellRenderer( centerRenderer );
        }
    
    
        RetrieveData();
    }
    
    private static class HeaderRenderer implements TableCellRenderer 
        {
    
            DefaultTableCellRenderer renderer;
    
            public HeaderRenderer(JTable table) 
            {
                renderer = (DefaultTableCellRenderer)
                table.getTableHeader().getDefaultRenderer();
                renderer.setHorizontalAlignment(JLabel.CENTER);
            }
    
    
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int col) 
    
            {
                return renderer.getTableCellRendererComponent(
                table, value, isSelected, hasFocus, row, col);
            }
    }
    
    public void RetrieveData()
    {
        try 
        {
            int x=0;
            String query = "Select * FROM `2013-2014 enrollment`";
            DatabaseConfig a = new DatabaseConfig();
            ResultSet rs = a.showR(query);
    
            while(rs.next())
            {
                SID = rs.getString("Student_ID");
                lastName = rs.getString("Last_Name");
                firstName = rs.getString("First_Name");
                middleInitial = rs.getString("Middle_Initial");
                CYS = rs.getString("CYS");
                semestralTuition = rs.getDouble("Semestral_Tuition");
                studentStatus = rs.getString("Status");
    
                model.addRow(new Object[]{SID,lastName,firstName,middleInitial,CYS,semestralTuition,studentStatus});
    
    
                x++;
    
                System.out.println(rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3) + " " + rs.getString(4) + " " + rs.getString(5) + " " + rs.getString(6) + " " + rs.getString(7));
            }
    
    
    
        } 
        catch (Exception e) 
        {
            JOptionPane.showMessageDialog(null, "There is an error.");
        }
    }
    
    public static void main (String[] args)
    {
        try 
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    
        catch (Exception exe)
        {
            System.out.println("ERROR: Could not Load System UI.");
        }
    
    
        new MalayaUniversityEnrollment();   
    
    }
    } 
    

    I want to find out exactly how to do it. Any response/answers will be appreciated. Thanks in advance.

    • cregox
      cregox almost 14 years
      Just to let it out - I can't really think of a situation (or recognize the one you cited) where doing this is a necessity, meaning I'd try other approaches to solve the broader issue, whatever it is. Why linking SSD files to the HDD?
    • Tamara Wijsman
      Tamara Wijsman almost 14 years
      Because not everything fits on the SSD, so I have to move things that do not require to be fast to my HDD without breaking anything... I don't want a workaround, I want a solution.
    • cregox
      cregox about 13 years
  • rockit
    rockit almost 14 years
    For some reason, I vaguely remember @TomWij mentioning these software in a comment on a hardlink/junction point-related question here on SU. I just can't find the actual question at the moment.
  • Tamara Wijsman
    Tamara Wijsman almost 14 years
    Exactly, but I want the best way to do it, I didn't know of the extension though, I'm checking it out now...
  • Tamara Wijsman
    Tamara Wijsman almost 14 years
    It indeeds makes it easier to work with junction points, I'll use this for the moment being and I will leave this open waiting for a better solution... I wish the source code was available so I could remove the text it adds to the directory name and to remove the options I will never use.
  • rockit
    rockit almost 14 years
    Just to add: you've probably found these already, but here's a couple of links off CodeProject (with source) related to junction points: codeproject.com/KB/winsdk/junctionpoints.aspx and codeproject.com/KB/vista/ReparsePointID.aspx
  • Tamara Wijsman
    Tamara Wijsman almost 14 years
    Seems interesting, maybe I either spent a bounty here or decide to spent some time on research and implementation one of these days...
  • Tamara Wijsman
    Tamara Wijsman over 13 years
    After using it for some time, this seems to work just fine. I won't do the swapping that much so I can do the steps manually...
  • mKorbel
    mKorbel over 10 years
    if(selectedRow > -1) then because -1 returns all XxxArraysXxxExceptions, because any row is selected