scrollPane = new JScrollPane(sessions); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
sessions.addMouseListener(new MouseAdapter() {
   private void createSessionsPanel() {      // get an instance of our table model      ctm = new ConfigureTableModel();      // create a table using our custom table model      sessions = new JSortTable(ctm);      // Add enter as default key for connect with this session      Action connect = new AbstractAction("connect") {            public void actionPerformed(ActionEvent e) {               doActionConnect();            }        };      KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0,false);      sessions.getInputMap().put(enter,"connect");      sessions.getActionMap().put("connect",connect );      sessions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);      sessions.setPreferredScrollableViewportSize(new Dimension(500,200));      sessions.setShowGrid(false);      //Create the scroll pane and add the table to it.      scrollPane = new JScrollPane(sessions);      scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);      // This will make the connect dialog react to two clicks instead of having      //  to click on the selection and then clicking twice      sessions.addMouseListener(new MouseAdapter() {         public void mouseClicked(MouseEvent event) {            if (event.getClickCount() == 2) {               doActionConnect();            }         }      });      //Setup our selection model listener      rowSM = sessions.getSelectionModel();          rowSM.addListSelectionListener(new ListSelectionListener() {              public void valueChanged(ListSelectionEvent e) {                  //Ignore extra messages.                  if (e.getValueIsAdjusting())                     return;                  ListSelectionModel lsm =                      (ListSelectionModel)e.getSource();                  if (lsm.isSelectionEmpty()) {                      //no rows are selected                     editButton.setEnabled(false);                     removeButton.setEnabled(false);                     connectButton.setEnabled(false);                  } else {                     int selectedRow = lsm.getMinSelectionIndex();                      //selectedRow is selected                     editButton.setEnabled(true);                     removeButton.setEnabled(true);                     connectButton.setEnabled(true);                  }              }          });      //Setup panels      configOptions.setLayout(borderLayout);      sessionPanel.setLayout(borderLayout);      configOptions.add(sessionPanel, BorderLayout.CENTER);      sessionOpts.add(scrollPane, BorderLayout.CENTER);      sessionPanel.add(sessionOpts, BorderLayout.NORTH);      sessionPanel.add(sessionOptPanel, BorderLayout.SOUTH);      sessionPanel.setBorder(BorderFactory.createRaisedBevelBorder());      // add the option buttons      addOptButton(LangTool.getString("ss.optAdd"),"ADD",sessionOptPanel);      removeButton = addOptButton(LangTool.getString("ss.optDelete"),                                    "REMOVE",                                    sessionOptPanel,                                    false);      editButton = addOptButton(LangTool.getString("ss.optEdit"),                                    "EDIT",                                    sessionOptPanel,                                    false);   }