List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:savant.view.dialog.PluginBrowser.java
public PluginBrowser() { tableModel = new ProgramTableModel(); pluginController.addListener(tableModel); setModel(tableModel);/*from w w w . jav a 2 s . co m*/ setPreferredScrollableViewportSize(new Dimension(600, 400)); setHierarchicalColumn(-1); setSingleExpansion(true); setName("Program Table"); setShowGrid(false); setRowHeight(24); getTableHeader().setPreferredSize(new Dimension(0, 0)); getColumnModel().getColumn(0).setPreferredWidth(500); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); HierarchicalTableComponentFactory factory = new HierarchicalTableComponentFactory() { @Override public Component createChildComponent(HierarchicalTable table, Object value, int row) { if (value instanceof PluginDescriptor) { return new ProgramPanel((PluginDescriptor) value); } return null; } @Override public void destroyChildComponent(HierarchicalTable table, Component component, int row) { } }; setComponentFactory(factory); getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int row = getSelectedRow(); if (row != -1) { expandRow(row); } } }); }
From source file:sk.uniza.fri.pds.spotreba.energie.gui.DbTab.java
public DbTab(Class clazz, SeService service) { this.clazz = clazz; this.service = service; tableModel = new BeanTableModel(clazz); this.tableModel.sortColumnNames(); setName(clazz.getSimpleName());//from ww w. ja va2 s . com initComponents(); try { MetawidgetUtils.setCommonSettings(metawidget); metawidget.setToInspect(clazz.newInstance()); jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (jTable.getSelectedRow() > -1) { Object row = ((BeanTableModel) jTable.getModel()).getRow(jTable.getSelectedRow()); oldObj = SerializationUtils.clone((Serializable) row); metawidget.setToInspect(row); } } }); } catch (InstantiationException | IllegalAccessException ex) { Logger.getLogger(DbTab.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:sturesy.core.ui.loaddialog.SubsettedJListPair.java
private void registerListeners() { _ui.getSourceList().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { subsetSourceListKeyEvent(keyEvent.getKeyCode()); }//from ww w. j a v a 2 s . c o m }); _ui.getContentList().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { subsetContentListKeyEvent(keyEvent.getKeyCode()); } }); _ui.getSourceList().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evnt) { informSourceListChanged(evnt.getValueIsAdjusting()); } }); }
From source file:tauargus.gui.PanelTable.java
private void initTableSelectionListeners() { table.getTableHeader().addMouseListener(new MouseAdapter() { @Override/* w w w. j a v a 2s. c o m*/ public void mouseClicked(MouseEvent e) { if (e.getSource() != table.getTableHeader()) return; int col = table.getTableHeader().columnAtPoint(e.getPoint()); if (col >= 1) { // column header is selected Code code = getColumnCode(col); if (code.state != Code.NODE) { if (code.state == Code.EXPANDED) { code.state = Code.COLLAPSED; } else { code.state = Code.EXPANDED; } createColumnIndices(); ((AbstractTableModel) table.getModel()).fireTableStructureChanged(); adjustColumnWidths(); } } } }); ListSelectionListener listSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int row = table.getSelectedRow(); int col = table.getSelectedColumn(); if (row >= 0 && col >= 0) { if (col == 0) { Code code = getRowCode(row); if (code.state != Code.NODE) { if (code.state == Code.EXPANDED) { code.state = Code.COLLAPSED; } else { code.state = Code.EXPANDED; } createRowIndices(); ((AbstractTableModel) table.getModel()).fireTableDataChanged(); adjustColumnWidths(); } } else { // cell is selected Cell cell = getCell(row, col); panelCellInformation.update(tableSet, cell, integerFormatter, doubleFormatter); organiseSafetyButtons(cell.status); } } } } }; // react on row changes table.getSelectionModel().addListSelectionListener(listSelectionListener); // .. and react on column changes table.getColumnModel().getSelectionModel().addListSelectionListener(listSelectionListener); }
From source file:tvbrowser.ui.filter.dlgs.EditFilterDlg.java
public EditFilterDlg(JFrame parent, FilterList filterList, UserFilter filter) { super(parent, true); UiUtilities.registerForClosing(this); mFilterList = filterList;//from w w w.jav a 2s. c o m mParent = parent; mFilter = filter; JPanel contentPane = (JPanel) getContentPane(); contentPane.setLayout(new BorderLayout(7, 7)); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); if (filter == null) { setTitle(mLocalizer.msg("titleNew", "Create filter")); } else { setTitle(mLocalizer.msg("titleEdit", "Edit filter {0}", filter.toString())); mFilterName = filter.toString(); } JPanel northPanel = new JPanel(); northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS)); mFilterNameTF = new JTextField(new PlainDocument() { public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { str = str.replaceAll("[\\p{Punct}&&[^_]]", "_"); super.insertString(offset, str, a); } }, "", 30); mFilterNameTF.getDocument().addDocumentListener(this); JPanel panel = new JPanel(new BorderLayout(7, 7)); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0)); panel.add(new JLabel(mLocalizer.msg("filterName", "Filter name:")), BorderLayout.WEST); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(mFilterNameTF, BorderLayout.WEST); panel.add(panel1, BorderLayout.CENTER); northPanel.add(panel); mFilterRuleTF = new JTextField(); mFilterRuleTF.getDocument().addDocumentListener(this); mFilterRuleTF.addCaretListener(this); panel = new JPanel(new BorderLayout(7, 7)); panel1 = new JPanel(new BorderLayout()); panel.add(new JLabel(mLocalizer.msg("ruleString", "Filter rule:")), BorderLayout.WEST); JLabel exampleLb = new JLabel( mLocalizer.msg("ruleExample", "example: component1 or (component2 and not component3)")); Font f = exampleLb.getFont(); exampleLb.setFont(new Font(f.getName(), Font.ITALIC | Font.PLAIN, f.getSize())); panel1.add(exampleLb, BorderLayout.WEST); panel.add(panel1, BorderLayout.CENTER); northPanel.add(panel); northPanel.add(mFilterRuleTF); mFilterRuleErrorLb = new JLabel(); mFilterRuleErrorLb.setForeground(Color.red); panel = new JPanel(new BorderLayout(7, 7)); panel.add(mFilterRuleErrorLb, BorderLayout.WEST); mColLb = new JLabel("0"); panel.add(mColLb, BorderLayout.EAST); northPanel.add(panel); JPanel filterComponentsPanel = new JPanel(new BorderLayout(7, 7)); filterComponentsPanel.add(DefaultComponentFactory.getInstance().createSeparator( mLocalizer.msg("componentsTitle", "Available filter components:")), BorderLayout.NORTH); JPanel btnPanel = new JPanel(new BorderLayout()); panel1 = new JPanel(new GridLayout(0, 1, 0, 7)); mNewBtn = new JButton(mLocalizer.msg("newButton", "new")); mEditBtn = new JButton(Localizer.getLocalization(Localizer.I18N_EDIT)); mRemoveBtn = new JButton(Localizer.getLocalization(Localizer.I18N_DELETE)); mNewBtn.addActionListener(this); mEditBtn.addActionListener(this); mRemoveBtn.addActionListener(this); panel1.add(mNewBtn); panel1.add(mEditBtn); panel1.add(mRemoveBtn); btnPanel.add(panel1, BorderLayout.NORTH); mComponentTableModel = new FilterTableModel(); mRuleTableBox = new JTable(mComponentTableModel); mRuleTableBox.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { updateBtns(); } }); mRuleTableBox.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() >= 2) { int row = mRuleTableBox.rowAtPoint(e.getPoint()); if (mRuleTableBox.getSelectedRow() == row && mEditBtn.isEnabled()) { actionPerformed(new ActionEvent(mEditBtn, ActionEvent.ACTION_PERFORMED, mEditBtn.getActionCommand())); } } } }); mRuleTableBox.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mRuleTableBox.setShowGrid(false); mRuleTableBox.setShowVerticalLines(true); mRuleTableBox.getColumnModel().getColumn(0).setPreferredWidth(125); mRuleTableBox.getColumnModel().getColumn(1).setPreferredWidth(320); // mRuleTableBox.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Dispatchs the KeyEvent to the RootPane for Closing the Dialog. // Needed for Java 1.4. mRuleTableBox.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { mRuleTableBox.getRootPane().dispatchEvent(e); } } }); JPanel ruleListBoxPanel = new JPanel(new BorderLayout()); ruleListBoxPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0)); ruleListBoxPanel.add(new JScrollPane(mRuleTableBox), BorderLayout.CENTER); filterComponentsPanel.add(btnPanel, BorderLayout.EAST); filterComponentsPanel.add(ruleListBoxPanel, BorderLayout.CENTER); ButtonBarBuilder2 bottomBar = Utilities.createFilterButtonBar(); mOkBtn = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); mOkBtn.addActionListener(this); getRootPane().setDefaultButton(mOkBtn); mCancelBtn = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); mCancelBtn.addActionListener(this); bottomBar.addButton(new JButton[] { mOkBtn, mCancelBtn }); contentPane.add(northPanel, BorderLayout.NORTH); contentPane.add(filterComponentsPanel, BorderLayout.CENTER); contentPane.add(bottomBar.getPanel(), BorderLayout.SOUTH); if (mFilter != null) { mFilterNameTF.setText(mFilter.toString()); mFilterRuleTF.setText(mFilter.getRule()); } FilterComponent[] fc = FilterComponentList.getInstance().getAvailableFilterComponents(); Arrays.sort(fc, new FilterComponent.NameComparator()); for (FilterComponent element : fc) { mComponentTableModel.addElement(element); } updateBtns(); Settings.layoutWindow("editFilterDlg", this, new Dimension(600, 300)); setVisible(true); }
From source file:typoscript.TypoScriptPluginOptions.java
protected void _init() { // Take a copy of the current sites config localSitesConfig = (Vector) TypoScriptPlugin.siteConfig.clone(); listModel = new DefaultListModel(); Iterator iter = localSitesConfig.iterator(); while (iter.hasNext()) { listModel.addElement(iter.next()); }/* www . java2s . co m*/ setLayout(new BorderLayout()); add(BorderLayout.NORTH, new JLabel("TYPO3 Sites")); JPanel sites = new JPanel(new BorderLayout()); siteList = new JList(listModel); siteList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); siteList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); siteList.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { // Edit if doubleclick if (e.getClickCount() == 2) { new AddEditSiteDialog(TypoScriptPluginOptions.this, (T3Site) localSitesConfig.get(siteList.getSelectedIndex())); } } public void mouseEntered(MouseEvent e) { ; } public void mousePressed(MouseEvent e) { ; } public void mouseReleased(MouseEvent e) { ; } public void mouseExited(MouseEvent e) { ; } }); JScrollPane scrollPane = new JScrollPane(siteList); sites.add(scrollPane); this.add(sites); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.setBorder(new EmptyBorder(6, 0, 0, 0)); add = new RolloverButton(GUIUtilities.loadIcon("Plus.png")); add.setToolTipText("Add Site"); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open the add/edit dialog in add mode new AddEditSiteDialog(TypoScriptPluginOptions.this, null); } }); buttons.add(add); remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png")); remove.setToolTipText("Remove Site"); remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { localSitesConfig.remove(siteList.getSelectedIndex()); listModel.removeElementAt(siteList.getSelectedIndex()); } }); buttons.add(remove); edit = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png")); edit.setToolTipText("Edit Site"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Open add/edit dialog in edit mode new AddEditSiteDialog(TypoScriptPluginOptions.this, (T3Site) localSitesConfig.get(siteList.getSelectedIndex())); } }); buttons.add(edit); buttons.add(Box.createGlue()); updateButtons(); add(BorderLayout.SOUTH, buttons); }
From source file:UI.HomePage.java
public HomePage() throws JSONException { initComponents();//from w w w. j a va 2s . com jRecord.setVisible(false); //jScrollPane1.getViewport().setOpaque(false); //jScrollPane1.setOpaque(false); //jScrollPane1.getColumnHeader().setOpaque(false); //getContentPane().add(jScrollPane1,BorderLayout.CENTER); jName.setText(Player.GetPlayer().GetNickName()); jMoney.setText("Money: " + Player.GetPlayer().GetBalance() + ""); jRank.setText("Rank: " + Player.GetPlayer().GetRank() + ""); timer_roomlist = new java.util.Timer(true); //Ask4RoomList task = new Ask4RoomList(); DefaultTableModel model = (DefaultTableModel) jRoomList.getModel(); jRoomList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (jRoomList.getSelectedRow() == -1) { return; } else { selected_row = jRoomList.getSelectedRow(); //System.out.println("Listener: " + selected_row); } } }); task.setOnRefreshListner(new Ask4RoomList.OnRefreshListener() { @Override public void onRefresh(String test) { model.setRowCount(0); jName.setText(Player.GetPlayer().GetNickName()); jMoney.setText("Money: " + Player.GetPlayer().GetBalance() + ""); jRank.setText("Rank: " + Player.GetPlayer().GetRank() + ""); if (task.get_room_number() > 0) { for (int i = 0; i < task.get_room_number(); i++) { model.addRow(new Object[] { task.get_room_title()[i], task.get_creator_name()[i], task.get_room_name()[i], task.get_currentmax()[i] }); //System.out.println(task.get_room_name()[i]+task.get_creator_name()[i]+task.get_game_name()[i]+task.get_currentmax()[i]); } } if (selected_row != -1) { jRoomList.setRowSelectionInterval(selected_row, selected_row); //System.out.println(jRoomList.getSelectedRow()); } roomids = task.get_roomids(); roomwagers = task.get_room_wager(); roomtypes = task.get_room_type(); roommax = task.get_room_max(); roomtitles = task.get_room_title(); } }); timer_roomlist.schedule(task, START_TIME, PERIOD); //System.out.println("Reach"); }
From source file:umich.ms.batmass.gui.viewers.map2d.options.Map2DOptionsPanel.java
Map2DOptionsPanel(Map2DOptionsOptionsPanelController controller) { this.controller = controller; this.config = new CompositeConfiguration(); initComponents();// w w w. j ava2 s . com colorList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (colorList.getSelectedValuesList().size() > 0) { btnChangeColor.setEnabled(true); btnMoveColorUp.setEnabled(true); btnMoveDown.setEnabled(true); btnRemoveColor.setEnabled(true); } else { btnChangeColor.setEnabled(false); btnMoveColorUp.setEnabled(false); btnMoveDown.setEnabled(false); btnRemoveColor.setEnabled(false); } } }); }
From source file:wsattacker.plugin.intelligentdos.ui.dialog.ConfigureCommonParams_NB.java
/** * Creates new form ConfigureCommonParams_NB * /* ww w .j a v a 2 s . c o m*/ * @param commonParamItems */ public ConfigureCommonParams_NB(List<CommonParamItem> commonParamItems) { commonParamTableModel = new CommonParamTableModel(commonParamItems); initComponents(); configureKeyBinding(); numberOfRequests.setDocument(new JTextFieldInteger()); numberOfRequests.getDocument().addDocumentListener(dl); numberOfThreads.setDocument(new JTextFieldInteger()); numberOfThreads.getDocument().addDocumentListener(dl); milliesBetweenReques.setDocument(new JTextFieldInteger()); milliesBetweenReques.getDocument().addDocumentListener(dl); commonParamTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent event) { int selectedRow = commonParamTable.getSelectedRow(); if (selectedRow < 0) { jButton2.setEnabled(false); numberOfRequests.setText(""); numberOfThreads.setText(""); milliesBetweenReques.setText(""); } else { jButton2.setEnabled(true); CommonParamItem cpi = commonParamTableModel.get(selectedRow); numberOfRequests.setText(String.valueOf(cpi.getNumberOfRequests())); numberOfThreads.setText(String.valueOf(cpi.getNumberOfThreads())); milliesBetweenReques.setText(String.valueOf(cpi.getMilliesBetweenRequests())); } } }); }