List of usage examples for javax.swing ListSelectionModel SINGLE_SELECTION
int SINGLE_SELECTION
To view the source code for javax.swing ListSelectionModel SINGLE_SELECTION.
Click Source Link
From source file:net.sf.jabref.gui.openoffice.StyleSelectDialog.java
private void setupTable() { styles = new BasicEventList<>(); EventList<OOBibStyle> sortedStyles = new SortedList<>(styles); tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat()); table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(100); cm.getColumn(1).setPreferredWidth(200); cm.getColumn(2).setPreferredWidth(80); selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedStyles); table.setSelectionModel(selectionModel); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.addMouseListener(new MouseAdapter() { @Override/*from www . ja va 2s .c om*/ public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } }); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder//ww w . j a va 2 s . co m */ private DeckBuilder() { super("DeckBuilder"); form = this; timerPanel = new TimerGlassPane(); cardLoader = new CardLoader(timerPanel); timer = new Timer(200, cardLoader); setGlassPane(timerPanel); try { setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif")); } catch (Exception e) { // IGNORING } // Load settings loadSettings(); // Initialize components final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this); quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this); deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this); aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK)); final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this); final JMenu mainMenu = UIHelper.buildMenu("menu_file"); mainMenu.add(newItem); mainMenu.add(loadItem); mainMenu.add(saveAsItem); mainMenu.add(saveItem); mainMenu.add(new JSeparator()); mainMenu.add(quitItem); super.optionMenu = new JMenu("Options"); final JMenu convertMenu = UIHelper.buildMenu("menu_convert"); convertMenu.add(convertDCK); final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this); helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); final JMenu helpMenu = new JMenu("?"); helpMenu.add(helpItem); helpMenu.add(deckConstraintsItem); helpMenu.add(aboutItem); final JMenuBar menuBar = new JMenuBar(); menuBar.add(mainMenu); initAbstractMenu(); menuBar.add(optionMenu); menuBar.add(convertMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); addWindowListener(this); // Build the panel containing amount of available cards final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT); // Build the left list allListModel = new MListModel<MCardCompare>(amountLeft, false); leftList = new ThreadSafeJList(allListModel); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftList.setLayoutOrientation(JList.VERTICAL); leftList.getSelectionModel().addListSelectionListener(this); leftList.addMouseListener(this); leftList.setVisibleRowCount(10); // Initialize the text field containing the amount to add addQtyTxt = new JTextField("1"); // Build the "Add" button addButton = new JButton(LanguageManager.getString("db_add")); addButton.setMnemonic('a'); addButton.setEnabled(false); // Build the panel containing : "Add" amount and "Add" button final Box addPanel = Box.createHorizontalBox(); addPanel.add(addButton); addPanel.add(addQtyTxt); addPanel.setMaximumSize(new Dimension(32010, 26)); // Build the panel containing the selected card name cardNameTxt = new JTextField(); new HireListener(cardNameTxt, addButton, this, leftList); final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : "); searchLabel.setLabelFor(cardNameTxt); // Build the panel containing search label and card name text field final Box searchPanel = Box.createHorizontalBox(); searchPanel.add(searchLabel); searchPanel.add(cardNameTxt); searchPanel.setMaximumSize(new Dimension(32010, 26)); listScrollerLeft = new JScrollPane(leftList); MToolKit.addOverlay(listScrollerLeft); // Build the left panel containing : list, available amount, "Add" panel final JPanel srcPanel = new JPanel(null); srcPanel.add(searchPanel); srcPanel.add(listScrollerLeft); srcPanel.add(amountLeft); srcPanel.add(addPanel); srcPanel.setMinimumSize(new Dimension(220, 200)); srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS)); // Initialize constraints constraintsChecker = new ConstraintsChecker(); constraintsChecker.setBorder(new EtchedBorder()); final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker); MToolKit.addOverlay(constraintsCheckerScroll); // create a pane with the oracle text for the present card oracleText = new JLabel(); oracleText.setPreferredSize(new Dimension(180, 200)); oracleText.setVerticalAlignment(SwingConstants.TOP); final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(oracle); // build some Pie Charts and a panel to display it initSets(); datasets = new ChartSets(); final JTabbedPane tabbedPane = new JTabbedPane(); for (ChartFilter filter : ChartFilter.values()) { final Dataset dataSet = filter.createDataSet(this); final JFreeChart chart = new JFreeChart(null, null, filter.createPlot(dataSet, painterMapper.get(filter)), false); datasets.addDataSet(filter, dataSet); ChartPanel pieChartPanel = new ChartPanel(chart, true); tabbedPane.add(pieChartPanel, filter.getTitle()); } // add the Constraints scroll panel and Oracle text Pane to the tabbedPane tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints")); tabbedPane.add(oracle, LanguageManager.getString("db_text")); tabbedPane.setSelectedComponent(oracle); // The toollBar for color filtering toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton clearButton = UIHelper.buildButton("clear"); clearButton.addActionListener(this); toolBar.add(clearButton); final JToggleButton toggleColorlessButton = new JToggleButton( UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true); toggleColorlessButton.setActionCommand("0"); toggleColorlessButton.addActionListener(this); toolBar.add(toggleColorlessButton); for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) { final JToggleButton toggleButton = new JToggleButton( UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true); toggleButton.setActionCommand(String.valueOf(index)); toggleButton.addActionListener(this); toolBar.add(toggleButton); } // sorted card type combobox creation final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames)); Collections.sort(idCards); final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") }, idCards.toArray()); idCardComboBox = new JComboBox(cardTypes); idCardComboBox.setSelectedIndex(0); idCardComboBox.addActionListener(this); idCardComboBox.setActionCommand("cardTypeFilter"); // sorted card properties combobox creation final List<String> properties = new ArrayList<String>( CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty())); Collections.sort(properties); final Object[] cardProperties = ArrayUtils .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray()); propertiesComboBox = new JComboBox(cardProperties); propertiesComboBox.setSelectedIndex(0); propertiesComboBox.addActionListener(this); propertiesComboBox.setActionCommand("propertyFilter"); final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : "); final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : "); final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : "); // filter Panel with colors toolBar and card type combobox final Box filterPanel = Box.createHorizontalBox(); filterPanel.add(colors); filterPanel.add(toolBar); filterPanel.add(types); filterPanel.add(idCardComboBox); filterPanel.add(property); filterPanel.add(propertiesComboBox); getContentPane().add(filterPanel, BorderLayout.NORTH); // Destination section : // Build the panel containing amount of available cards final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT); rightAmount.setMaximumSize(new Dimension(220, 26)); // Build the right list rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true)); rightListModel.addTableModelListener(this); rightList = new JTable(rightListModel); rightList.setShowGrid(false); rightList.setTableHeader(null); rightList.getSelectionModel().addListSelectionListener(this); rightList.getColumnModel().getColumn(0).setMaxWidth(25); rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // Build the panel containing the selected deck deckNameTxt = new JTextField("loading..."); deckNameTxt.setEditable(false); deckNameTxt.setBorder(null); final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : "); deckLabel.setLabelFor(deckNameTxt); final Box deckNamePanel = Box.createHorizontalBox(); deckNamePanel.add(deckLabel); deckNamePanel.add(deckNameTxt); deckNamePanel.setMaximumSize(new Dimension(220, 26)); // Initialize the text field containing the amount to remove removeQtyTxt = new JTextField("1"); // Build the "Remove" button removeButton = new JButton(LanguageManager.getString("db_remove")); removeButton.setMnemonic('r'); removeButton.addMouseListener(this); removeButton.setEnabled(false); // Build the panel containing : "Remove" amount and "Remove" button final Box removePanel = Box.createHorizontalBox(); removePanel.add(removeButton); removePanel.add(removeQtyTxt); removePanel.setMaximumSize(new Dimension(220, 26)); // Build the right panel containing : list, available amount, constraints final JScrollPane deskListScroller = new JScrollPane(rightList); MToolKit.addOverlay(deskListScroller); deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY)); deskListScroller.setMinimumSize(new Dimension(220, 200)); deskListScroller.setMaximumSize(new Dimension(220, 32000)); final Box destPanel = Box.createVerticalBox(); destPanel.add(deckNamePanel); destPanel.add(deskListScroller); destPanel.add(rightAmount); destPanel.add(removePanel); destPanel.setMinimumSize(new Dimension(220, 200)); destPanel.setMaximumSize(new Dimension(220, 32000)); // Build the panel containing the name of card in picture cardPictureNameTxt = new JLabel("<html><i>no selected card</i>"); final Box cardPictureNamePanel = Box.createHorizontalBox(); cardPictureNamePanel.add(cardPictureNameTxt); cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26)); // Group the detail panels final JPanel viewCard = new JPanel(null); viewCard.add(cardPictureNamePanel); viewCard.add(CardView.getInstance()); viewCard.add(tabbedPane); viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS)); final Box mainPanel = Box.createHorizontalBox(); mainPanel.add(destPanel); mainPanel.add(viewCard); // Add the main panel getContentPane().add(srcPanel, BorderLayout.WEST); getContentPane().add(mainPanel, BorderLayout.CENTER); // Size this frame getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); getRootPane().setMinimumSize(getRootPane().getPreferredSize()); pack(); }
From source file:com.mirth.connect.client.ui.SettingsPanelMap.java
private void initComponents() { setBackground(Color.WHITE);//from ww w.j a va 2 s .c om setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); setLayout(new MigLayout("insets 12, fill")); configurationMapTable = new MirthTable(); configurationMapTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); configurationMapTable.getTableHeader().setReorderingAllowed(false); configurationMapTable.setSortable(false); configurationMapTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); configurationMapTable .setModel(new RefreshTableModel(new String[][] {}, new String[] { "Key", "Value", "Comment" })); TableCellEditor cellEditor = new TextFieldCellEditor() { @Override protected boolean valueChanged(String value) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); return true; } }; configurationMapTable.getColumnExt("Key").setCellEditor(cellEditor); configurationMapTable.getColumnExt("Value").setCellEditor(cellEditor); configurationMapTable.getColumnExt("Comment").setCellEditor(cellEditor); configurationMapTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { int selectedRow; if (configurationMapTable.isEditing()) { selectedRow = configurationMapTable.getEditingRow(); } else { selectedRow = configurationMapTable.getSelectedRow(); } removeButton.setEnabled(selectedRow != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { configurationMapTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } configurationMapScrollPane = new JScrollPane(); configurationMapScrollPane.setViewportView(configurationMapTable); addButton = new MirthButton("Add"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((RefreshTableModel) configurationMapTable.getModel()).addRow(new String[] { "", "" }); if (configurationMapTable.getRowCount() == 1) { configurationMapTable.setRowSelectionInterval(0, 0); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); removeButton = new MirthButton("Remove"); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (configurationMapTable.getSelectedModelIndex() != -1 && !configurationMapTable.isEditing()) { Integer selectedModelIndex = configurationMapTable.getSelectedModelIndex(); RefreshTableModel model = (RefreshTableModel) configurationMapTable.getModel(); int newViewIndex = configurationMapTable.convertRowIndexToView(selectedModelIndex); if (newViewIndex == (model.getRowCount() - 1)) { newViewIndex--; } // must set lastModelRow to -1 so that when setting the new // row selection below the old data won't try to be saved. model.removeRow(selectedModelIndex); if (model.getRowCount() != 0) { configurationMapTable.setRowSelectionInterval(newViewIndex, newViewIndex); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); configurationMapPanel = new JPanel(); configurationMapPanel.setBackground(Color.WHITE); configurationMapPanel.setLayout(new MigLayout("fill, flowy, insets 0", "[grow][]", "grow")); configurationMapPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createMatteBorder(1, 0, 0, 0, new java.awt.Color(204, 204, 204)), "Configuration Map", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N configurationMapPanel.add(configurationMapScrollPane, "grow, wrap"); configurationMapPanel.add(addButton, "growx, aligny top, split"); configurationMapPanel.add(removeButton, "growx, aligny top"); add(configurationMapPanel, "grow, height 100px:100%:100%, wrap"); }
From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java
private final JPanel buildTestbedPanel() throws RemoteException { JPanel testbedPanel = new JPanel(new BorderLayout()); testbedPanel.setBorder(new TitledBorder("Physical Deployments")); // --- left-side ------------------------------------------------- JPanel sidePanel = new JPanel(new BorderLayout()); sidePanel.setPreferredSize(new Dimension(WINDOW_WIDTH / 3, SIZE_IGNORED)); testbedList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); testbedList.setListData(testbedManager.getTestbedList().toArray()); testbedList.addListSelectionListener(new TestbedListSelectionListener()); sidePanel.add(new JScrollPane(testbedList), BorderLayout.CENTER); testbedPanel.add(sidePanel, BorderLayout.WEST); // --- right-side ------------------------------------------------ sidePanel = new JPanel(new BorderLayout()); sidePanel.setPreferredSize(new Dimension(310, SIZE_IGNORED)); JPanel rsTopPanel = new JPanel(new BorderLayout()); rsTopPanel.setPreferredSize(new Dimension(SIZE_IGNORED, 50)); JPanel labelPanel = new JPanel(new GridLayout(2, 1, 0, 5)); labelPanel.add(new JLabel("Name: ")); labelPanel.add(new JLabel("Description: ")); JPanel infoPanel = new JPanel(new GridLayout(2, 1, 0, 5)); infoPanel.add(testbedName);// w w w .ja v a 2 s . c o m testbedName.setEditable(false); infoPanel.add(testbedDescription); testbedDescription.setEditable(false); rsTopPanel.add(labelPanel, BorderLayout.WEST); rsTopPanel.add(infoPanel, BorderLayout.CENTER); sidePanel.add(rsTopPanel, BorderLayout.NORTH); testbedPanel.add(sidePanel, BorderLayout.EAST); return testbedPanel; }
From source file:net.sf.jabref.openoffice.StyleSelectDialog.java
private void init(String inSelection) { this.initSelection = inSelection; ButtonGroup bg = new ButtonGroup(); bg.add(useDefaultAuthoryear);// w w w. j a v a2s . co m bg.add(useDefaultNumerical); bg.add(chooseDirectly); bg.add(setDirectory); if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE)) { useDefaultAuthoryear.setSelected(true); } else if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE)) { useDefaultNumerical.setSelected(true); } else { if (Globals.prefs.getBoolean(JabRefPreferences.OO_CHOOSE_STYLE_DIRECTLY)) { chooseDirectly.setSelected(true); } else { setDirectory.setSelected(true); } } directFile.setText(Globals.prefs.get(JabRefPreferences.OO_DIRECT_FILE)); styleDir.setText(Globals.prefs.get(JabRefPreferences.OO_STYLE_DIRECTORY)); directFile.setEditable(false); styleDir.setEditable(false); popup.add(edit); BrowseAction dfBrowse = BrowseAction.buildForFile(directFile, directFile); browseDirectFile.addActionListener(dfBrowse); BrowseAction sdBrowse = BrowseAction.buildForDir(styleDir, setDirectory); browseStyleDir.addActionListener(sdBrowse); showDefaultAuthoryearStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { displayDefaultStyle(true); } }); showDefaultNumericalStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { displayDefaultStyle(false); } }); // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor: edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { int i = table.getSelectedRow(); if (i == -1) { return; } ExternalFileType type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("jstyle"); String link = tableModel.getElementAt(i).getFile().getPath(); try { if (type == null) { JabRefDesktop.openExternalFileUnknown(frame, new BibEntry(), new MetaData(), link, new UnknownExternalFileType("jstyle")); } else { JabRefDesktop.openExternalFileAnyFormat(new MetaData(), link, type); } } catch (IOException e) { LOGGER.warn("Problem open style file editor", e); } } }); diag = new JDialog(frame, Localization.lang("Styles"), true); styles = new BasicEventList<>(); EventList<OOBibStyle> sortedStyles = new SortedList<>(styles); // Create a preview panel for previewing styles: preview = new PreviewPanel(null, new MetaData(), ""); // Use the test entry from the Preview settings tab in Preferences: preview.setEntry(prevEntry); tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat()); table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(100); cm.getColumn(1).setPreferredWidth(200); cm.getColumn(2).setPreferredWidth(80); selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedStyles); table.setSelectionModel(selectionModel); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } }); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); styleDir.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } @Override public void removeUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } @Override public void changedUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } }); directFile.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } @Override public void removeUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } @Override public void changedUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } }); contentPane.setTopComponent(new JScrollPane(table)); contentPane.setBottomComponent(preview); readStyles(); DefaultFormBuilder b = new DefaultFormBuilder( new FormLayout("fill:pref,4dlu,fill:150dlu,4dlu,fill:pref", "")); b.append(useDefaultAuthoryear, 3); b.append(showDefaultAuthoryearStyle); b.nextLine(); b.append(useDefaultNumerical, 3); b.append(showDefaultNumericalStyle); b.nextLine(); b.append(chooseDirectly); b.append(directFile); b.append(browseDirectFile); b.nextLine(); b.append(setDirectory); b.append(styleDir); b.append(browseStyleDir); b.nextLine(); DefaultFormBuilder b2 = new DefaultFormBuilder( new FormLayout("fill:1dlu:grow", "fill:pref, fill:pref, fill:270dlu:grow")); b2.nextLine(); b2.append(new JLabel("<html>" + Localization.lang("This is the list of available styles. Select the one you want to use.") + "</html>")); b2.nextLine(); b2.append(contentPane); b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); b2.getPanel().setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5)); diag.add(b.getPanel(), BorderLayout.NORTH); diag.add(b2.getPanel(), BorderLayout.CENTER); AbstractAction okListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { if (!useDefaultAuthoryear.isSelected() && !useDefaultNumerical.isSelected()) { if (chooseDirectly.isSelected()) { File f = new File(directFile.getText()); if (!f.exists()) { JOptionPane.showMessageDialog(diag, Localization.lang( "You must select either a valid style file, or use a default style."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE); return; } } else { if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) { JOptionPane.showMessageDialog(diag, Localization.lang( "You must select either a valid style file, or use a default style."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE); return; } } } okPressed = true; storeSettings(); diag.dispose(); } }; ok.addActionListener(okListener); Action cancelListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { diag.dispose(); } }; cancel.addActionListener(cancelListener); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(ok); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.add(bb.getPanel(), BorderLayout.SOUTH); ActionMap am = bb.getPanel().getActionMap(); InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelListener); im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk"); am.put("enterOk", okListener); diag.pack(); diag.setLocationRelativeTo(frame); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { contentPane.setDividerLocation(contentPane.getSize().height - 150); } }); }
From source file:org.fhcrc.cpl.viewer.gui.ProteinMatcherFrame.java
/** * initial setup of UI and class variables */// w w w . ja v a 2 s . co m public void initialize() { _ms1Features = getMS1Features(); if (_ms1Features == null) { ApplicationContext.infoMessage(TextProvider.getText("AMT_REQUIRES_DISPLAYED_FEATURES")); this.setVisible(false); this.dispose(); return; } this.setVisible(true); //graphical stuff try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/gui/ProteinMatcherMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } Container contentPanel; try { contentPanel = Localizer.renderSwixml("org/fhcrc/cpl/viewer/gui/ProteinMatcherFrame.xml", this); setContentPane(contentPanel); pack(); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_CREATING_DIALOG"), x); throw new RuntimeException(x); } Dimension d = contentPanel.getPreferredSize(); setBounds(600, 100, (int) d.getWidth(), (int) d.getHeight()); ListenerHelper helper = new ListenerHelper(this); helper.addListener(tblProteins.getSelectionModel(), "tblProteinsModel_valueChanged"); helper.addListener(buttonFilterProteins, "buttonFilterProteins_actionPerformed"); //hitting enter in the text field should act the same as hitting the filter button. Hack, focus, whatever helper.addListener(textProteinPrefix, "buttonFilterProteins_actionPerformed"); helper.addListener(tblFeatures.getSelectionModel(), "tblFeaturesModel_valueChanged"); _proteinTableModel = new ProteinTableModel(); tblProteins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblProteins.setAutoCreateColumnsFromModel(false); tblProteins.setModel(_proteinTableModel); tblProteins.setColumnModel(_proteinTableModel.columnModel); if (null != displayMatchedUnmatchedComboBox) { //TODO: should really use TextProvider here, and use an internal value for determining state displayMatchedUnmatchedComboBox.addItem("matched"); displayMatchedUnmatchedComboBox.addItem("unmatched peptides"); displayMatchedUnmatchedComboBox.addItem("unmatched ms2"); helper.addListener(displayMatchedUnmatchedComboBox, "displayMatchedUnmatchedComboBox_actionPerformed"); } _featureTableModel = new FeatureTableModel(); tblFeatures.setModel(_featureTableModel); tblFeatures.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tblFeatures.setAutoCreateColumnsFromModel(false); ProteinTablePopupMenu proteinPopup = new ProteinTablePopupMenu(); tblProteins.setComponentPopupMenu(proteinPopup); proteinLabel.setComponentPopupMenu(proteinPopup); }
From source file:com.floreantpos.ui.model.PizzaItemForm.java
private void initComponents() { setLayout(new BorderLayout()); JLabel lblButtonColor = new JLabel(Messages.getString("MenuItemForm.19")); //$NON-NLS-1$ tabbedPane = new javax.swing.JTabbedPane(); JPanel tabGeneral = new javax.swing.JPanel(); JLabel lblName = new JLabel(); lblName.setHorizontalAlignment(SwingConstants.TRAILING); tfName = new com.floreantpos.swing.FixedLengthTextField(20); tfDescription = new JTextArea(new FixedLengthDocument(120)); JLabel lTax = new javax.swing.JLabel(); lTax.setHorizontalAlignment(SwingConstants.TRAILING); cbTax = new javax.swing.JComboBox(); JButton btnNewTax = new javax.swing.JButton(); JPanel tabShift = new javax.swing.JPanel(); JPanel tabPrice = new javax.swing.JPanel(); JPanel tabButtonStyle = new javax.swing.JPanel(); JButton btnDeleteShift = new javax.swing.JButton(); JButton btnAddShift = new javax.swing.JButton(); JButton btnNewPrice = new javax.swing.JButton(); JButton btnUpdatePrice = new javax.swing.JButton(); JButton btnDeletePrice = new javax.swing.JButton(); JButton btnDeleteAll = new javax.swing.JButton(); JButton btnDefaultValue = new javax.swing.JButton(); JButton btnAutoGenerate = new javax.swing.JButton(); JScrollPane jScrollPane2 = new javax.swing.JScrollPane(); JScrollPane priceTabScrollPane = new javax.swing.JScrollPane(); shiftTable = new JTable(); priceTable = new JTable(); priceTable.setRowHeight(PosUIManager.getSize(priceTable.getRowHeight())); priceTable.setCellSelectionEnabled(true); priceTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); priceTable.setSurrendersFocusOnKeystroke(true); cbPrinterGroup = new JComboBox<PrinterGroup>(new DefaultComboBoxModel<PrinterGroup>( PrinterGroupDAO.getInstance().findAll().toArray(new PrinterGroup[0]))); cbPrinterGroup.setPreferredSize(new Dimension(226, 0)); tfDefaultSellPortion = new IntegerTextField(10); tfTranslatedName = new FixedLengthTextField(20); tfTranslatedName.setLength(120);/*from w ww. j a v a2s .c o m*/ lblKitchenPrinter = new JLabel(Messages.getString("MenuItemForm.27")); //$NON-NLS-1$ lblName.setText(Messages.getString("LABEL_NAME")); //$NON-NLS-1$ tfName.setLength(120); JLabel lblTranslatedName = new JLabel(Messages.getString("MenuItemForm.lblTranslatedName.text")); //$NON-NLS-1$ tfSortOrder = new IntegerTextField(20); tfSortOrder.setText(""); //$NON-NLS-1$ cbTax.setPreferredSize(new Dimension(198, 0)); btnButtonColor = new JButton(); //$NON-NLS-1$ btnButtonColor.setPreferredSize(new Dimension(228, 40)); JLabel lblTextColor = new JLabel(Messages.getString("MenuItemForm.lblTextColor.text")); //$NON-NLS-1$ btnTextColor = new JButton(Messages.getString("MenuItemForm.SAMPLE_TEXT")); //$NON-NLS-1$ cbShowTextWithImage = new JCheckBox(Messages.getString("MenuItemForm.40")); //$NON-NLS-1$ cbShowTextWithImage.setActionCommand(Messages.getString("MenuItemForm.41")); //$NON-NLS-1$ lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); //$NON-NLS-1$ btnNewTax.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewTaxdoCreateNewTax(evt); } }); tabbedPane.addTab(com.floreantpos.POSConstants.GENERAL, tabGeneral); tabbedPane.setPreferredSize(new Dimension(750, 470)); tabbedPane.addTab(com.floreantpos.POSConstants.MODIFIER_GROUPS, getModifierGroupTab()); btnAddShift.addActionListener(this); btnDeleteShift.addActionListener(this); tabGeneral.setLayout(new MigLayout("insets 20", "[][]20px[][]", "[][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ tabGeneral.add(lblName, "cell 0 1 ,right"); //$NON-NLS-1$ tabGeneral.add(tfName, "cell 1 1,grow"); //$NON-NLS-1$ tabGeneral.add(lblTranslatedName, "cell 0 2,right"); //$NON-NLS-1$ tabGeneral.add(tfTranslatedName, "cell 1 2,grow"); JLabel lgroup = new javax.swing.JLabel(); lgroup.setHorizontalAlignment(SwingConstants.TRAILING); lgroup.setText(Messages.getString("LABEL_GROUP")); //$NON-NLS-1$ tabGeneral.add(lgroup, "cell 0 3,alignx right"); //$NON-NLS-1$ JLabel lblBarcode = new JLabel(Messages.getString("MenuItemForm.lblBarcode.text")); //$NON-NLS-1$ tabGeneral.add(lblBarcode, "cell 0 4,alignx right"); //$NON-NLS-1$ tfBarcode = new FixedLengthTextField(20); tabGeneral.add(tfBarcode, "cell 1 4,grow"); //$NON-NLS-1$ JLabel lblStockCount = new JLabel(Messages.getString("MenuItemForm.17")); //$NON-NLS-1$ tabGeneral.add(lblStockCount, "cell 0 5,alignx right"); //$NON-NLS-1$ tfStockCount = new DoubleTextField(1); tabGeneral.add(tfStockCount, "cell 1 5,grow"); //$NON-NLS-1$ chkVisible = new javax.swing.JCheckBox(); tabGeneral.add(new JLabel("Default sell portion (%)"), "cell 0 6"); tabGeneral.add(tfDefaultSellPortion, "cell 1 6,grow"); chkVisible.setText(com.floreantpos.POSConstants.VISIBLE); chkVisible.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); chkVisible.setMargin(new java.awt.Insets(0, 0, 0, 0)); tabGeneral.add(chkVisible, "cell 1 7"); tabGeneral.add(lblKitchenPrinter, "cell 2 1,right"); //$NON-NLS-1$ tabGeneral.add(cbPrinterGroup, "cell 3 1,grow"); //$NON-NLS-1$ tabGeneral.add(lTax, "cell 2 2,right"); //$NON-NLS-1$ tabGeneral.add(cbTax, "cell 3 2"); //$NON-NLS-1$ tabGeneral.add(btnNewTax, "cell 3 2,grow"); //$NON-NLS-1$ cbGroup = new javax.swing.JComboBox(); cbGroup.setPreferredSize(new Dimension(198, 0)); tabGeneral.add(cbGroup, "flowx,cell 1 3"); //$NON-NLS-1$ JButton btnNewGroup = new javax.swing.JButton(); btnNewGroup.setText("..."); //$NON-NLS-1$ btnNewGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doCreateNewGroup(evt); } }); tabGeneral.add(btnNewGroup, "cell 1 3"); //$NON-NLS-1$ tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.25")), "cell 2 3,right"); //$NON-NLS-1$ //$NON-NLS-2$ orderList = new CheckBoxList(); List<OrderType> orderTypes = Application.getInstance().getOrderTypes(); orderList.setModel(orderTypes); JScrollPane orderCheckBoxList = new JScrollPane(orderList); orderCheckBoxList.setPreferredSize(new Dimension(228, 100)); tabGeneral.add(orderCheckBoxList, "cell 3 3 3 3"); //$NON-NLS-1$ cbDisableStockCount = new JCheckBox(Messages.getString("MenuItemForm.18")); //$NON-NLS-1$ tabGeneral.add(cbDisableStockCount, "cell 1 8"); //$NON-NLS-1$ tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.29")), "cell 2 6,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$ JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrlDescription.setPreferredSize(new Dimension(228, 70)); tfDescription.setLineWrap(true); tabGeneral.add(scrlDescription, "cell 3 6 3 3"); //$NON-NLS-1$ add(tabbedPane); //TODO: addRecepieExtension(); btnDeleteShift.setText(com.floreantpos.POSConstants.DELETE_SHIFT); btnAddShift.setText(com.floreantpos.POSConstants.ADD_SHIFT); shiftTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ jScrollPane2.setViewportView(shiftTable); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(tabShift); tabShift.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup().addContainerGap(76, Short.MAX_VALUE) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 670, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup().add(btnAddShift).add(5, 5, 5) .add(btnDeleteShift))) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 345, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(btnAddShift).add(btnDeleteShift)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); tabbedPane.addTab(com.floreantpos.POSConstants.SHIFTS, tabShift); btnNewPrice.setText(Messages.getString("MenuItemForm.9")); //$NON-NLS-1$ btnNewPrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewPrice(); } }); btnUpdatePrice.setText(Messages.getString("MenuItemForm.13")); //$NON-NLS-1$ btnUpdatePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updatePrice(); } }); btnDeletePrice.setText(Messages.getString("MenuItemForm.14")); //$NON-NLS-1$ btnDeletePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deletePrice(); } }); btnAutoGenerate.setText("Auto Generate"); //$NON-NLS-1$ btnAutoGenerate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { autoGeneratePizzaItemSizeAndPrice(); } }); btnDeleteAll.setText(Messages.getString("MenuItemForm.15")); //$NON-NLS-1$ btnDeleteAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteAll(); } }); btnDefaultValue.setText(Messages.getString("MenuItemForm.7")); //$NON-NLS-1$ priceTabScrollPane.setViewportView(priceTable); tabPrice.setLayout(new BorderLayout()); tabPrice.add(priceTabScrollPane, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.add(btnNewPrice); buttonPanel.add(btnUpdatePrice); buttonPanel.add(btnDeletePrice); buttonPanel.add(btnAutoGenerate); tabPrice.add(buttonPanel, BorderLayout.SOUTH); tabGeneral.add(tabPrice, "cell 0 10,grow,span"); tabbedPane.addChangeListener(this); tabButtonStyle.setLayout(new MigLayout("insets 10", "[][]100[][][][]", "[][][center][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$ lblImage.setHorizontalAlignment(SwingConstants.TRAILING); tabButtonStyle.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$ lblImagePreview = new JLabel(""); //$NON-NLS-1$ lblImagePreview.setHorizontalAlignment(JLabel.CENTER); lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); lblImagePreview.setPreferredSize(new Dimension(100, 100)); tabButtonStyle.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$ JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$ btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$ tabButtonStyle.add(btnClearImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(lblButtonColor, "cell 0 2,right"); //$NON-NLS-1$ tabButtonStyle.add(btnButtonColor, "cell 1 2,grow"); //$NON-NLS-1$ tabButtonStyle.add(lblTextColor, "cell 0 3,right"); //$NON-NLS-1$ tabButtonStyle.add(btnTextColor, "cell 1 3"); //$NON-NLS-1$ tabButtonStyle.add(cbShowTextWithImage, "cell 1 4"); //$NON-NLS-1$ btnTextColor.setPreferredSize(new Dimension(228, 50)); btnSelectImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectImageFile(); } }); btnClearImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doClearImage(); } }); btnButtonColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(POSUtil.getBackOfficeWindow(), Messages.getString("MenuItemForm.42"), btnButtonColor.getBackground()); //$NON-NLS-1$ btnButtonColor.setBackground(color); btnTextColor.setBackground(color); } }); btnTextColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(POSUtil.getBackOfficeWindow(), Messages.getString("MenuItemForm.43"), btnTextColor.getForeground()); //$NON-NLS-1$ btnTextColor.setForeground(color); } }); tabbedPane.addTab(Messages.getString("MenuItemForm.26"), tabButtonStyle); //$NON-NLS-1$ }
From source file:com.neurotec.samples.panels.EnrollFromScanner.java
@Override protected void initGUI() { panelMain = new JPanel(); panelScanners = new JPanel(); scrollPaneList = new JScrollPane(); scannerList = new JList(); panelButtons = new JPanel(); btnRefresh = new JButton(); btnScan = new JButton(); btnCancel = new JButton(); btnForce = new JButton(); cbAutomatic = new JCheckBox(); scrollPane = new JScrollPane(); panelSouth = new JPanel(); panelInfo = new JPanel(); lblInfo = new JLabel(); panelSave = new JPanel(); btnIdentifyPatient = new JButton(); btnRegisterPatient = new JButton(); cbShowProcessed = new JCheckBox(); setLayout(new BorderLayout()); panelMain.setLayout(new BorderLayout()); panelScanners.setBorder(BorderFactory.createTitledBorder("Scanners list")); panelScanners.setLayout(new BorderLayout()); scrollPaneList.setPreferredSize(new Dimension(0, 90)); scannerList.setModel(new DefaultListModel()); scannerList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scannerList.setBorder(LineBorder.createBlackLineBorder()); scrollPaneList.setViewportView(scannerList); panelScanners.add(scrollPaneList, BorderLayout.CENTER); panelButtons.setLayout(new FlowLayout(FlowLayout.LEADING)); btnRefresh.setText("Refresh list"); panelButtons.add(btnRefresh);// w w w .j a v a 2 s. co m btnScan.setText("Scan"); panelButtons.add(btnScan); btnCancel.setText("Cancel"); btnCancel.setEnabled(false); panelButtons.add(btnCancel); btnForce.setText("Force"); panelButtons.add(btnForce); cbAutomatic.setSelected(true); cbAutomatic.setText("Scan automatically"); panelButtons.add(cbAutomatic); panelScanners.add(panelButtons, BorderLayout.SOUTH); panelMain.add(panelScanners, BorderLayout.NORTH); panelMain.add(scrollPane, BorderLayout.CENTER); panelSouth.setLayout(new BorderLayout()); panelInfo.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); panelInfo.setLayout(new GridLayout(1, 1)); lblInfo.setText(" "); panelInfo.add(lblInfo); panelSouth.add(panelInfo, BorderLayout.NORTH); panelSave.setLayout(new FlowLayout(FlowLayout.LEADING)); btnIdentifyPatient.setText("Identify Patient"); btnIdentifyPatient.setEnabled(false); panelSave.add(btnIdentifyPatient); btnRegisterPatient.setText("Register Patient"); btnRegisterPatient.setEnabled(false); panelSave.add(btnRegisterPatient); cbShowProcessed.setSelected(true); cbShowProcessed.setText("Show processed image"); panelSave.add(cbShowProcessed); panelSouth.add(panelSave, BorderLayout.SOUTH); panelMain.add(panelSouth, BorderLayout.SOUTH); add(panelMain, BorderLayout.CENTER); panelLicensing = new LicensingPanel(requiredLicenses, optionalLicenses); add(panelLicensing, java.awt.BorderLayout.NORTH); fcImage = new JFileChooser(); fcImage.setFileFilter(new Utils.ImageFileFilter(NImages.getSaveFileFilter())); fcTemplate = new JFileChooser(); view = new NFingerView(); view.setShownImage(ShownImage.RESULT); view.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { super.mouseClicked(ev); if (ev.getButton() == MouseEvent.BUTTON3) { cbShowProcessed.doClick(); } } }); scrollPane.setViewportView(view); btnRefresh.addActionListener(this); btnScan.addActionListener(this); btnCancel.addActionListener(this); btnForce.addActionListener(this); btnIdentifyPatient.addActionListener(this); btnRegisterPatient.addActionListener(this); cbShowProcessed.addActionListener(this); scannerList.addListSelectionListener(new ScannerSelectionListener()); }
From source file:zet.gui.assignmentEditor.JAssignmentPanel.java
/** * Returns the panel on the left side of the {@code JAssignmentPanel} that * contains lists of assignments and assignment types. * @return the panel on the left side of the {@code JAssignmentPanel} */// w w w . j ava2s . c o m private JPanel getLeftPanel() { final int space = 16; double size[][] = // Columns { { space, TableLayout.FILL, space, TableLayout.FILL, space }, //Rows { space, TableLayout.PREFERRED, // Label 1, TableLayout.FILL, // Auswahlbox space, TableLayout.PREFERRED, // Label Name 1, TableLayout.PREFERRED, // TextFeld 1, TableLayout.PREFERRED, 1, TableLayout.PREFERRED, 1, TableLayout.PREFERRED, // Button space, TableLayout.PREFERRED, // Button Neu 5, TableLayout.PREFERRED, // Button Lschen space } }; JPanel leftPanel = new JPanel(new TableLayout(size)); int row = 1; leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.Assignments")), "1, " + row++); row++; assignmentSelector = new AssignmentListModel(); lstAssignment = new JList<>(); lstAssignment.setModel(assignmentSelector); lstAssignment.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstAssignment.setCellRenderer(new AssignmentListRenderer()); lstAssignment.setSelectionModel(new AssignmentListSelectionModel()); lstAssignment.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { setCurrent(); } } }); leftPanel.add(new JScrollPane(lstAssignment), "1, " + row++); row++; leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.Name")), "1, " + row++); row++; addAssignmentText = new JTextField(); leftPanel.add(addAssignmentText, "1, " + row++); row++; JButton assignmentChange = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentSave"), aclAssignmentSaveChanges); assignmentChange.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentSave.ToolTip")); leftPanel.add(assignmentChange, "1, " + row++); row++; row += 4; JButton assignmentAdd = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentAdd"), aclAssignmentAdd); assignmentAdd.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentSave.ToolTip")); leftPanel.add(assignmentAdd, "1, " + row++); row++; JButton assignmentDelete = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentDelete"), aclAssignmentDelete); assignmentDelete.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentSave.ToolTip")); leftPanel.add(assignmentDelete, "1, " + row++); row++; // Rechter Teil row = 1; leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.AssignmentTypes")), "3, " + row++); row++; assignmentTypeSelector = new AssignmentTypeListModel(); lstAssignmentType = new JList<>(); lstAssignmentType.setModel(assignmentTypeSelector); lstAssignmentType.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstAssignmentType.setCellRenderer(new AssignmentTypeListRenderer()); lstAssignmentType.setSelectionModel(new AssignmentTypeListSelectionModel()); leftPanel.add(new JScrollPane(lstAssignmentType), "3, " + row++); row++; leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.Name")), "3, " + row++); row++; addAssignmentTypeText = new JTextField(); leftPanel.add(addAssignmentTypeText, "3, " + row++); row++; leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.DefaultEvacuees")), "3, " + row++); row++; txtDefaultEvacuees = new JTextField(); txtDefaultEvacuees.addKeyListener(kylEvacuees); leftPanel.add(txtDefaultEvacuees, "3, " + row++); row++; JButton assignmentTypeChange = Button.newButton( loc.getString("gui.AssignmentEditor.button.AssignmentTypeSave"), aclAssignmentTypeSaveChanges); assignmentTypeChange .setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentTypeSave.ToolTip")); leftPanel.add(assignmentTypeChange, "3, " + row++); row++; JButton assignmentTypeAdd = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentTypeAdd"), aclAssignmentTypeAdd); assignmentTypeAdd.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentTypeAdd.ToolTip")); leftPanel.add(assignmentTypeAdd, "3, " + row++); row++; JButton assignmentTypeDelete = Button.newButton( loc.getString("gui.AssignmentEditor.button.AssignmentTypeDelete"), aclAssignmentTypeDelete); assignmentTypeDelete .setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentTypeSave.ToolTip")); leftPanel.add(assignmentTypeDelete, "3, " + row++); row++; return leftPanel; }
From source file:ca.uhn.hl7v2.testpanel.ui.v2tree.Hl7V2MessageTree.java
/** Creates new TreePanel */ public Hl7V2MessageTree(Controller theController) { addKeyListener(new KeyAdapter() { @Override// w ww . java2s . c o m public void keyPressed(KeyEvent e) { handleKeyPress(e); } }); setFont(new Font("LUCIDA", Font.PLAIN, 9)); myController = theController; myPipeParser = new PipeParser(); myPipeParser.setValidationContext(new ValidationContextImpl()); setRenderDataProvider(new TreeRenderDataProvider()); setShowGrid(true); setGridColor(new Color(0.9f, 0.9f, 0.9f)); setRowHeight(16); setRowSelectionAllowed(true); setSelectionModel(new MySelectionModel()); ValueCellEditor valueCellEditor = new ValueCellEditor(getFont()); setDefaultEditor(String.class, valueCellEditor); valueCellEditor.addCellEditorListener(new CellEditorListener() { public void editingCanceled(ChangeEvent theE) { ourLog.info("No longer editing"); myCurrentlyEditing = false; } public void editingStopped(ChangeEvent theE) { ourLog.info("No longer editing"); myCurrentlyEditing = false; } }); myHighlitedPathListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { if (myController.isMessageEditorInFollowMode()) { if (Hl7V2MessageTree.this.hasFocus() == false) { synchronizeTreeWithHighlitedPath(); } } } }; myParsedMessagesListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { myUpdaterThread.scheduleUpdate(); } }; myValidationContextListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { myUpdaterThread.scheduleUpdate(); } }; myMessageEncodingListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { myUpdaterThread.scheduleUpdate(); } }; getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myUpdaterThread = new UpdaterThread(); myUpdaterThread.start(); }