Java Code Examples for javax.swing.DefaultListSelectionModel#setSelectionMode()
The following examples show how to use
javax.swing.DefaultListSelectionModel#setSelectionMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeysTableView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example 2
Source File: HistoryQuickSearchView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearance table.setRowHeight(22); table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener((evt) -> pm.setSelected(getSelectedRow())); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); table.getActionMap().put("confirmRow", enterAction); table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "confirmRow"); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.setViewportView(table); return scrollPane; }
Example 3
Source File: MainFrameView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); table.setDefaultRenderer(EncryptBackAction.class, new EncryptBackActionCellRenderer()); table.addMouseListener(encrBackClickHandler); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example 4
Source File: SorterTableColumnModel.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
public SorterTableColumnModel(Sortables[] columnHeaders) { MainFrame mainFrame = MainFrame.getInstance(); int x = 0; for (Sortables c : columnHeaders) { if (!c.isAvailable(mainFrame)) { continue; } shown.add(c); TableColumn tc = makeTableColumn(x, c); columnList.add(tc); x++; } dlsm = new DefaultListSelectionModel(); dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); orderUpdate(); check(); }
Example 5
Source File: EndmemberFormModel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public EndmemberFormModel(AppContext appContext) { this.appContext = appContext; endmemberListModel = new DefaultListModel<>(); endmemberListSelectionModel = new DefaultListSelectionModel(); endmemberListSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); endmemberListModel.addListDataListener(new EndmemberListDataListener()); endmemberListSelectionModel.addListSelectionListener(new EndmemberListSelectionListener()); addAction = new AddAction(); removeAction = new RemoveAction(); clearAction = new ClearAction(); exportAction = new ExportAction(); endmemberDiagram = new Diagram(); endmemberDiagram.setXAxis(new DiagramAxis("Wavelength", "")); endmemberDiagram.setYAxis(new DiagramAxis("Radiation", "")); endmemberDiagram.setDrawGrid(false); propertyChangeSupport = new PropertyChangeSupport(this); }
Example 6
Source File: ClientListPanel.java From VideoConference with GNU General Public License v2.0 | 5 votes |
void createListModel() { list_model=new javax.swing.DefaultListModel(); list_online_clients = new javax.swing.JList(list_model); list_online_clients.setBorder(javax.swing.BorderFactory.createTitledBorder("Buddy List")); dlsm=new DefaultListSelectionModel(); dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list_online_clients.setSelectionModel(dlsm); this.setLayout(new BorderLayout()); this.add(list_online_clients,BorderLayout.CENTER); }
Example 7
Source File: ServerMonitor.java From VideoConference with GNU General Public License v2.0 | 5 votes |
void createListModel() { list_model=new javax.swing.DefaultListModel(); list_online_clients = new javax.swing.JList(list_model); list_online_clients.setBorder(javax.swing.BorderFactory.createTitledBorder("ONLINE CLIENTS")); dlsm=new DefaultListSelectionModel(); dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list_online_clients.setSelectionModel(dlsm); list_panel.setLayout(new BorderLayout()); list_panel.add(list_online_clients); }
Example 8
Source File: DropDownSelectionTextField.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected ListSelectionModel createListSelectionModel() { DefaultListSelectionModel model = new DefaultListSelectionModel(); model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); return model; }
Example 9
Source File: JTableSelectionModelEditor.java From netbeans with Apache License 2.0 | 4 votes |
private static ListSelectionModel createListSelectionModel(int selectionMode) { DefaultListSelectionModel model = new DefaultListSelectionModel(); model.setSelectionMode(selectionMode); return model; }
Example 10
Source File: PhotoList.java From mvisc with GNU General Public License v3.0 | 4 votes |
public PhotoList(ZooracleContentPanel zooracleContentPanel) { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.zooracleContentPanel = zooracleContentPanel; // Set the frame characteristics // setSize(150, 600); setBackground(Color.gray); // Create a panel to hold all other components topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); this.add(topPanel); // Create some data // String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } }; // Create a new table instance table = new JTable(null, columnNames); // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // table.setMinimumSize(new Dimension(150, 600)); // table.setPreferredSize(new Dimension(150, 600)); // table.setD selectionModel = new DefaultListSelectionModel(); model = new DefaultTableModel(); // table.setC selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectionIndex = table.getSelectedRow(); if (lastSelectionIndex != selectionIndex) { lastSelectionIndex = selectionIndex; if (selectionIndex==-1) return; System.out.println(table.getValueAt(selectionIndex, 0)); System.out.println("sele:" + selectionIndex); if (PhotoList.this.zooracleContentPanel instanceof ImportView) { ((ImportView)(PhotoList.this.zooracleContentPanel)).setCurrentPhoto(selectionIndex); } // if (selectionIndex > 2) // PhotoList.this.maximize(false); } } }); // table.setDefaultRenderer(Object.class, new EditedCellRenderer(this)); table.setSelectionModel(selectionModel); table.setDefaultRenderer(String.class, new BoardTableCellRenderer()); table.setDefaultRenderer(Object.class, new BoardTableCellRenderer()); table.setModel(model); // table.setMaximumSize(new Dimension(100, 300)); // Add the table to a scrolling pane scrollPane = new JScrollPane(); // scrollPane.add(table.getTableHeader()); // scrollPane.add(table); // topPanel.add(scrollPane); topPanel.add(table.getTableHeader()); topPanel.add(new JScrollPane(table)); }