List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
/** Inits GUI. */ public JarListPanel() { super(new BorderLayout()); m_addJarList = new JList<String>(new DefaultListModel<String>()) { /** {@inheritDoc} */ @Override//from w w w. j a v a 2 s . c o m protected void processComponentKeyEvent(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_A && e.isControlDown()) { int end = getModel().getSize() - 1; getSelectionModel().setSelectionInterval(0, end); } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { onJarRemove(); } } }; m_addJarList.setCellRenderer(new ConvenientComboBoxRenderer()); add(new JScrollPane(m_addJarList), BorderLayout.CENTER); JPanel southP = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5)); m_addJarFilesButton = new JButton("Add File(s)..."); m_addJarFilesButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarFileAdd(); } }); m_addJarURLsButton = new JButton("Add KNIME URL..."); m_addJarURLsButton.setToolTipText("Add 'knime' URLs that resolve to local paths"); m_addJarURLsButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarURLAdd(); } }); m_removeButton = new JButton("Remove"); m_removeButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarRemove(); } }); m_addJarList.addListSelectionListener(new ListSelectionListener() { /** {@inheritDoc} */ @Override public void valueChanged(final ListSelectionEvent e) { m_removeButton.setEnabled(!m_addJarList.isSelectionEmpty()); } }); m_removeButton.setEnabled(!m_addJarList.isSelectionEmpty()); southP.add(m_addJarFilesButton); southP.add(m_addJarURLsButton); southP.add(m_removeButton); add(southP, BorderLayout.SOUTH); JPanel northP = new JPanel(new FlowLayout()); JLabel label = new JLabel("<html><body>Specify additional jar files " + "that are necessary for the snippet to run</body></html>"); northP.add(label); add(northP, BorderLayout.NORTH); }
From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java
/** * Creates new form DSWorkbenchTroopsFrame *//*from w ww . java2 s. c om*/ DSWorkbenchTroopsFrame() { initComponents(); centerPanel = new GenericTestPanel(true); jTroopsPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jXTroopsPanel); buildMenu(); capabilityInfoPanel1.addActionListener(this); jTroopsTabPane.getModel().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { TroopTableTab activeTab = getActiveTab(); if (activeTab != null) { activeTab.updateSet(); } } }); DataHolder.getSingleton().addDataHolderListener(DSWorkbenchTroopsFrame.this); jXGroupsList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateFilter(); } }); jTroopAddTribe.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateTroopAddVillageList(); } } }); jTroopsAddDialog.pack(); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.troops_view", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> setGlassPane(jxSearchPane); pack(); }
From source file:com.mirth.connect.client.ui.EditMessageDialog.java
private void initSourceMapTable(Map<String, Object> sourceMap) { Object[][] data = new Object[sourceMap.size()][2]; int i = 0;/* ww w .j a v a 2 s . c o m*/ for (Entry<String, Object> entry : sourceMap.entrySet()) { data[i][0] = entry.getKey(); data[i][1] = entry.getValue(); i++; } sourceMapTable = new MirthTable(); sourceMapTable.setModel(new RefreshTableModel(data, new Object[] { "Variable", "Value" }) { @Override public boolean isCellEditable(int row, int column) { return true; } }); sourceMapTable.setDragEnabled(false); sourceMapTable.setRowSelectionAllowed(true); sourceMapTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); sourceMapTable.setRowHeight(UIConstants.ROW_HEIGHT); sourceMapTable.setFocusable(false); sourceMapTable.setOpaque(true); sourceMapTable.getTableHeader().setResizingAllowed(false); sourceMapTable.getTableHeader().setReorderingAllowed(false); sourceMapTable.setSortable(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { sourceMapTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } sourceMapTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { deleteButton.setEnabled(sourceMapTable.getSelectedRow() > -1); } } }); class SourceMapTableCellEditor extends AbstractCellEditor implements TableCellEditor { private JTable table; private int column; private JTextField textField; private Object originalValue; private String newValue; public SourceMapTableCellEditor(JTable table, int column) { super(); this.table = table; this.column = column; textField = new JTextField(); textField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { textField.setCaretPosition(textField.getText().length()); } }); } @Override public boolean isCellEditable(EventObject evt) { if (evt == null) { return false; } if (evt instanceof MouseEvent) { return ((MouseEvent) evt).getClickCount() >= 2; } return true; } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { originalValue = value; newValue = null; textField.setText(String.valueOf(value)); return textField; } @Override public Object getCellEditorValue() { if (newValue != null) { return newValue; } else { return originalValue; } } @Override public boolean stopCellEditing() { if (!valueChanged()) { super.cancelCellEditing(); } else { newValue = textField.getText(); } return super.stopCellEditing(); } private boolean valueChanged() { String value = textField.getText(); if (StringUtils.isBlank(value)) { return false; } for (int i = 0; i < table.getRowCount(); i++) { Object tableValue = table.getValueAt(i, column); if (tableValue != null && String.valueOf(tableValue).equals(value)) { return false; } } return true; } } sourceMapTable.getColumnModel().getColumn(0).setCellEditor(new SourceMapTableCellEditor(sourceMapTable, 0)); sourceMapTable.getColumnModel().getColumn(1).setCellEditor(new SourceMapTableCellEditor(sourceMapTable, 1)); sourceMapScrollPane.setViewportView(sourceMapTable); deleteButton.setEnabled(false); }
From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.support.PropertyHolderTable.java
protected JTable buildPropertiesTable() { propertiesModel = getPropertyHolderTableModel(); propertiesTable = new PropertiesHolderJTable(); propertiesTable.setName(PROPERTIES_HOLDER_TABLE_NAME); propertiesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); propertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRow = propertiesTable.getSelectedRow(); if (removePropertyAction != null) { removePropertyAction.setEnabled(selectedRow != -1); }/*from ww w. j a v a 2 s .c o m*/ if (movePropertyUpAction != null) { movePropertyUpAction.setEnabled(selectedRow > 0); } if (movePropertyDownAction != null) { movePropertyDownAction .setEnabled(selectedRow >= 0 && selectedRow < propertiesTable.getRowCount() - 1); } } }); propertiesTable.setDragEnabled(true); propertiesTable.setTransferHandler(new TransferHandler("testProperty")); if (getHolder().getModelItem() != null) { DropTarget dropTarget = new DropTarget(propertiesTable, new PropertyHolderTablePropertyExpansionDropTarget()); dropTarget.setDefaultActions(DnDConstants.ACTION_COPY_OR_MOVE); } // Set render this only for value column. In this cell render we handle password shadowing. propertiesTable.getColumnModel().getColumn(1).setCellRenderer(new PropertiesTableCellRenderer()); return propertiesTable; }
From source file:logdruid.ui.RecordingList.java
/** * Create the panel.//from www .j a va2 s . c o m */ public RecordingList(final Repository rep) { if (Preferences.getPreference("timings").equals("true")) { header = (String[]) new String[] { "name", "regexp", "type", "active", "success time", "failed time", "match attempt", "success match" }; } else { header = (String[]) new String[] { "name", "regexp", "type", "active" }; } records = rep.getRecordings(); // Collections.sort(records); Iterator it = records.iterator(); while (it.hasNext()) { Recording record = (Recording) it.next(); stats = DataVault.getRecordingStats(record.getName()); if (stats != null) { data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), record.getIsActive(), stats[0], stats[1], stats[2], stats[3] }); } else { data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), record.getIsActive(), 0, 0, 0, 0 }); } } repository = rep; model = new MyTableModel2(data, header); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.insets = new Insets(5, 0, 5, 5); gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); int column; panel_1.add(scrollPane); table.setPreferredScrollableViewportSize(new Dimension(0, 150)); table.setFillsViewportHeight(true); // Set up column sizes. initColumnSizes(table); table.setAutoCreateRowSorter(true); // RowSorter sorter = table.getRowSorter(); // sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); if (model.getRowCount() > 0) { table.getRowSorter().toggleSortOrder(0); table.getRowSorter().toggleSortOrder(2); } table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); ; logger.info("ListSelectionListener - selectedRow: " + selectedRow); if (selectedRow >= 0) { if (jPanelDetail != null) { logger.info("ListSelectionListener - valueChanged"); jPanelDetail.removeAll(); recEditor = getEditor(repository.getRecording(selectedRow)); if (recEditor != null) { jPanelDetail.add(recEditor, BorderLayout.CENTER); } jPanelDetail.revalidate(); } } } }); JPanel panel = new JPanel(); FlowLayout flowLayout = (FlowLayout) panel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); flowLayout.setVgap(2); flowLayout.setHgap(2); panel_1.add(panel, BorderLayout.SOUTH); JButton btnNewMeta = new JButton("New Meta"); panel.add(btnNewMeta); btnNewMeta.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int rowCount = table.getRowCount(); jPanelDetail.removeAll(); Recording re = new MetadataRecording("name", "regex", "example line", "", true, null); recEditor = new MetadataRecordingEditor(thiis, repository, "the line", "regex", (MetadataRecording) re); jPanelDetail.add(recEditor, BorderLayout.CENTER); repository.addRecording(re); model.addRow( new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 }); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(rowCount, rowCount); logger.info("New record - row count : " + rowCount); } }); JButton btnDuplicate = new JButton("Duplicate"); btnDuplicate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); int selectRow = ((table.getSelectedRow() != -1) ? table.getSelectedRow() : -1); int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); repository.addRecording( repository.getRecording(table.convertRowIndexToModel(table.getSelectedRow())).duplicate()); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(selectRow, selectRow); } }); JButton btnNewStat = new JButton("New Stat"); btnNewStat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); jPanelDetail.removeAll(); Recording re = new StatRecording("name", "regex", "example line", "", true, null); recEditor = new StatRecordingEditor(thiis, repository, "the line", "regex", (StatRecording) re); jPanelDetail.add(recEditor, BorderLayout.CENTER); repository.addRecording(re); model.addRow( new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 }); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(rowCount, rowCount); logger.info("New record - row count : " + rowCount); } }); panel.add(btnNewStat); JButton btnNewEvent = new JButton("New Event"); btnNewEvent.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); logger.info("table.getRowCount()" + table.getRowCount()); jPanelDetail.removeAll(); Recording re = new EventRecording("name", "regex", "example line", "", true, null); recEditor = new EventRecordingEditor(thiis, repository, "the line", "regex", (EventRecording) re); jPanelDetail.add(recEditor, BorderLayout.CENTER); repository.addRecording(re); model.addRow( new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 }); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(rowCount, rowCount); logger.info("New record - row count : " + rowCount); } }); panel.add(btnNewEvent); panel.add(btnDuplicate); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); ; int realSelectedRow = table.getSelectedRow(); logger.info("selectedRow : " + selectedRow + ", row count: " + table.getRowCount()); if (rowCount != 0) { repository.deleteRecording(selectedRow); model.fireTableRowsDeleted(selectedRow, selectedRow); // table.remove(selectedRow); if (realSelectedRow != -1) { if (realSelectedRow != 0) table.setRowSelectionInterval(realSelectedRow - 1, realSelectedRow - 1); else if (realSelectedRow > 0) table.setRowSelectionInterval(realSelectedRow, realSelectedRow); else if (rowCount > 1) table.setRowSelectionInterval(0, 0); } /* if (table.getRowCount() > 0) { if (selectedRow == table.getRowCount()) { table.setRowSelectionInterval(selectedRow - 1, selectedRow - 1); } else table.setRowSelectionInterval(selectedRow, selectedRow); }*/ } } }); panel.add(btnDelete); setLayout(new BorderLayout(0, 0)); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); jPanelDetail = new JPanel(); GridBagConstraints gbc_jPanelDetail = new GridBagConstraints(); gbc_jPanelDetail.insets = new Insets(0, 0, 0, 5); gbc_jPanelDetail.fill = GridBagConstraints.BOTH; gbc_jPanelDetail.gridx = 1; gbc_jPanelDetail.gridy = 4; splitPane.setBottomComponent(jPanelDetail); splitPane.setTopComponent(panel_1); jPanelDetail.setLayout(new BorderLayout(0, 0)); if (repository.getRecordingCount() > 0) { //recEditor = getEditor(repository.getRecording(0)); //jPanelDetail.add(recEditor, BorderLayout.CENTER); table.setRowSelectionInterval(0, 0); } jPanelDetail.revalidate(); }
From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java
BamInternalFrame(BamFileRef ref) { super(ref.bamFile.getName(), true, false, true, true); this.ref = ref; JPanel mainPane = new JPanel(new BorderLayout(5, 5)); setContentPane(mainPane);/*from w w w. ja v a 2s. co m*/ JTabbedPane tabbedPane = new JTabbedPane(); mainPane.add(tabbedPane, BorderLayout.CENTER); JPanel pane = new JPanel(new BorderLayout(5, 5)); tabbedPane.addTab("BAM", pane); this.tableModel = new BamTableModel(); this.jTable = createTable(tableModel); this.jTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); this.jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll1 = new JScrollPane(this.jTable); this.infoTableModel = new FlagTableModel(); JTable tInfo = createTable(this.infoTableModel); this.genotypeTableModel = new SAMTagAndValueModel(); JTable tGen = createTable(this.genotypeTableModel); this.groupTableModel = new ReadGroupTableModel(); JTable tGrp = createTable(this.groupTableModel); JPanel splitH = new JPanel(new GridLayout(1, 0, 5, 5)); splitH.add(new JScrollPane(tInfo)); splitH.add(new JScrollPane(tGen)); splitH.add(new JScrollPane(tGrp)); JSplitPane splitVert = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scroll1, splitH); this.jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int row = jTable.getSelectedRow(); SAMRecord ctx; if (row == -1 || (ctx = tableModel.getElementAt(row)) == null) { infoTableModel.setContext(null); genotypeTableModel.setContext(null); groupTableModel.setContext(null); } else { infoTableModel.setContext(ctx); genotypeTableModel.setContext(ctx); groupTableModel.setContext(ctx); } } }); pane.add(splitVert); //header as text pane = new JPanel(new BorderLayout(5, 5)); tabbedPane.addTab("Header", pane); JTextArea area = new JTextArea(String.valueOf(ref.header.getTextHeader())); area.setCaretPosition(0); area.setEditable(false); pane.add(new JScrollPane(area), BorderLayout.CENTER); //dict pane = new JPanel(new BorderLayout(5, 5)); tabbedPane.addTab("Reference", pane); JTable dictTable = createTable(new SAMSequenceDictionaryTableModel(ref.header.getSequenceDictionary())); dictTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); pane.add(new JScrollPane(dictTable), BorderLayout.CENTER); this.selList = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; listSelectionChanged(); } }; this.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameActivated(InternalFrameEvent e) { jTable.getSelectionModel().addListSelectionListener(selList); } @Override public void internalFrameDeactivated(InternalFrameEvent e) { jTable.getSelectionModel().removeListSelectionListener(selList); } }); }
From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java
@Override public void initialize(Viewable viewableArg) { super.initialize(viewableArg); GetSetValueIFace parentField = (GetSetValueIFace) formViewObj.getControlByName("parent"); Component comp = formViewObj.getControlByName("definitionItem"); if (comp instanceof ValComboBox) { final ValComboBox rankComboBox = (ValComboBox) comp; final JCheckBox acceptedCheckBox = (JCheckBox) formViewObj.getControlByName("isAccepted"); Component apComp = formViewObj.getControlByName("acceptedParent"); final ValComboBoxFromQuery acceptedParentWidget = apComp instanceof ValComboBoxFromQuery ? (ValComboBoxFromQuery) apComp : null;/* w w w . j av a2s. co m*/ if (parentField instanceof ValComboBoxFromQuery) { final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) parentField; if (parentCBX != null && rankComboBox != null) { parentCBX.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e == null || !e.getValueIsAdjusting()) { parentChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox, acceptedParentWidget); } } }); rankComboBox.getComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rankChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox, acceptedParentWidget); } }); } } if (acceptedCheckBox != null && acceptedParentWidget != null) { acceptedCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (acceptedCheckBox.isSelected()) { acceptedParentWidget.setValue(null, null); acceptedParentWidget.setChanged(true); // This should be done automatically acceptedParentWidget.setEnabled(false); } else { acceptedParentWidget.setEnabled(true); } } }); } } }
From source file:com.mirth.connect.client.ui.RegexAttachmentDialog.java
private void initOutboundReplacementTable() { DefaultTableModel model = new DefaultTableModel(new Object[][] {}, new String[] { "Replace All", "Replace With" }) { public boolean isCellEditable(int rowIndex, int columnIndex) { return true; }//ww w . ja v a 2s . c o m @Override public void setValueAt(Object value, int row, int column) { if (!value.equals(getValueAt(row, column))) { parent.setSaveEnabled(true); } super.setValueAt(value, row, column); } }; outboundReplacementTable.setSortable(false); outboundReplacementTable.getTableHeader().setReorderingAllowed(false); outboundReplacementTable.setModel(model); outboundReplacementTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { outboundDeleteButton.setEnabled(outboundReplacementTable.getSelectedRow() != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { outboundReplacementTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } outboundDeleteButton.setEnabled(false); }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java
private void initComponents() { ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel(); jtExtensions = new JKseTable(extensionsTableModel); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel); sorter.setComparator(2, new ObjectIdComparator()); jtExtensions.setRowSorter(sorter);//from w w w . j a v a 2 s . c om jtExtensions.setShowGrid(false); jtExtensions.setRowMargin(0); jtExtensions.getColumnModel().setColumnMargin(0); jtExtensions.getTableHeader().setReorderingAllowed(false); jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS); jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight())); for (int i = 0; i < jtExtensions.getColumnCount(); i++) { TableColumn column = jtExtensions.getColumnModel().getColumn(i); column.setHeaderRenderer( new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer())); column.setCellRenderer(new ExtensionsTableCellRend()); } TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0); criticalCol.setResizable(false); criticalCol.setMinWidth(28); criticalCol.setMaxWidth(28); criticalCol.setPreferredWidth(28); ListSelectionModel selectionModel = jtExtensions.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { try { CursorUtil.setCursorBusy(DViewExtensions.this); updateExtensionValue(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } } }); jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground()); jpExtensionsTable = new JPanel(new BorderLayout(5, 5)); jpExtensionsTable.setPreferredSize(new Dimension(500, 200)); jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER); jpExtensionValue = new JPanel(new BorderLayout(5, 5)); jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text")); jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH); jepExtensionValue = new JEditorPane(); jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize())); jepExtensionValue.setEditable(false); jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip")); // JGoodies - keep uneditable color same as editable jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE); // for displaying URLs in extensions as clickable links jepExtensionValue.setContentType("text/html"); jepExtensionValue.addHyperlinkListener(this); // use default font and foreground color from the component jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5)); jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200)); jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER); jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER); jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text")); PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0)); jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip")); jbAsn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DViewExtensions.this); asn1DumpPressed(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } }); jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jpExtensionValueAsn1.add(jbAsn1); jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH); jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5)); jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)))); jpExtensions.add(jpExtensionsTable); jpExtensions.add(jpExtensionValue); jbOK = new JButton(res.getString("DViewExtensions.jbOK.text")); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false); extensionsTableModel.load(extensions); if (extensionsTableModel.getRowCount() > 0) { jtExtensions.changeSelection(0, 0, false, false); } getContentPane().add(jpExtensions, BorderLayout.CENTER); getContentPane().add(jpOK, BorderLayout.SOUTH); setResizable(false); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); getRootPane().setDefaultButton(jbOK); pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jbOK.requestFocus(); } }); }
From source file:com.floreantpos.customer.DefaultCustomerListView.java
public void initUI() { setLayout(new MigLayout("fill", "[grow]", "[grow][grow][grow]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JPanel searchPanel = new JPanel(new MigLayout()); JLabel lblByPhone = new JLabel(Messages.getString("CustomerSelectionDialog.1")); //$NON-NLS-1$ JLabel lblByLoyality = new JLabel(Messages.getString("CustomerSelectionDialog.16")); //$NON-NLS-1$ JLabel lblByName = new JLabel(Messages.getString("CustomerSelectionDialog.19")); //$NON-NLS-1$ tfMobile = new POSTextField(16); tfLoyaltyNo = new POSTextField(16); tfName = new POSTextField(16); tfName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer();/*from w ww . j av a 2 s. co m*/ } }); tfLoyaltyNo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer(); } }); tfMobile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer(); } }); PosButton btnSearch = new PosButton(Messages.getString("CustomerSelectionDialog.15")); //$NON-NLS-1$ btnSearch.setFocusable(false); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer(); } }); PosButton btnKeyboard = new PosButton(IconFactory.getIcon("/images/", "keyboard.png")); //$NON-NLS-1$ //$NON-NLS-2$ btnKeyboard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { qwertyKeyPad.setCollapsed(!qwertyKeyPad.isCollapsed()); } }); searchPanel.add(lblByPhone, "growy"); //$NON-NLS-1$ searchPanel.add(tfMobile, "growy"); //$NON-NLS-1$ searchPanel.add(lblByLoyality, "growy"); //$NON-NLS-1$ searchPanel.add(tfLoyaltyNo, "growy"); //$NON-NLS-1$ searchPanel.add(lblByName, "growy"); //$NON-NLS-1$ searchPanel.add(tfName, "growy"); //$NON-NLS-1$ searchPanel.add(btnKeyboard, "growy,w " + PosUIManager.getSize(80) + "!,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ searchPanel.add(btnSearch, ",growy,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$ add(searchPanel, "cell 0 1"); //$NON-NLS-1$ JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.setBorder(new TitledBorder(null, POSConstants.SELECT_CUSTOMER.toUpperCase(), TitledBorder.LEADING, TitledBorder.TOP, null, null)); //$NON-NLS-1$ JPanel customerListPanel = new JPanel(new BorderLayout(0, 0)); customerListPanel.setBorder(new EmptyBorder(5, 5, 0, 5)); customerTable = new CustomerTable(); customerTable.setModel(new CustomerListTableModel()); customerTable.setFocusable(false); customerTable.setRowHeight(60); customerTable.getTableHeader().setPreferredSize(new Dimension(100, 35)); customerTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); customerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { selectedCustomer = customerTable.getSelectedCustomer(); if (selectedCustomer != null) { //btnInfo.setEnabled(true); } else { btnInfo.setEnabled(false); } } }); JScrollPane scrollPane = new JScrollPane(); scrollPane.setFocusable(false); scrollPane.setViewportView(customerTable); customerListPanel.add(scrollPane, BorderLayout.CENTER); JPanel panel = new JPanel(new MigLayout("hidemode 3,al center", "sg", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ btnInfo = new PosButton(Messages.getString("CustomerSelectionDialog.23")); //$NON-NLS-1$ btnInfo.setFocusable(false); panel.add(btnInfo, "grow"); //$NON-NLS-1$ btnInfo.setEnabled(false); PosButton btnHistory = new PosButton(Messages.getString("CustomerSelectionDialog.24")); //$NON-NLS-1$ btnHistory.setEnabled(false); panel.add(btnHistory, "grow"); //$NON-NLS-1$ btnCreateNewCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.25")); //$NON-NLS-1$ btnCreateNewCustomer.setFocusable(false); panel.add(btnCreateNewCustomer, "grow"); //$NON-NLS-1$ btnCreateNewCustomer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doCreateNewCustomer(); } }); btnRemoveCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.26")); //$NON-NLS-1$ btnRemoveCustomer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doRemoveCustomerFromTicket(); } }); panel.add(btnRemoveCustomer, "grow"); //$NON-NLS-1$ PosButton btnSelect = new PosButton(Messages.getString("CustomerSelectionDialog.28")); //$NON-NLS-1$ btnSelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isCreateNewTicket()) { doCreateNewTicket(); } else { closeDialog(false); } } }); panel.add(btnSelect, "grow"); //$NON-NLS-1$ btnCancel = new PosButton(Messages.getString("CustomerSelectionDialog.29")); //$NON-NLS-1$ btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(true); } }); panel.add(btnCancel, "grow"); //$NON-NLS-1$ customerListPanel.add(panel, BorderLayout.SOUTH); centerPanel.add(customerListPanel, BorderLayout.CENTER); //$NON-NLS-1$ add(centerPanel, "cell 0 2,grow"); //$NON-NLS-1$ qwertyKeyPad = new com.floreantpos.swing.QwertyKeyPad(); qwertyKeyPad.setCollapsed(false); add(qwertyKeyPad, "cell 0 3,grow"); //$NON-NLS-1$ }