List of usage examples for java.awt.event KeyAdapter KeyAdapter
KeyAdapter
From source file:net.pms.encoders.VLCVideo.java
@Override public JComponent config() { // Apply the orientation for the locale Locale locale = new Locale(configuration.getLanguage()); ComponentOrientation orientation = ComponentOrientation.getOrientation(locale); String colSpec = FormLayoutUtil.getColSpec("right:pref, 3dlu, pref:grow, 7dlu, right:pref, 3dlu, pref:grow", orientation);//from w ww .j a v a2s . co m FormLayout layout = new FormLayout(colSpec, ""); // Here goes my 3rd try to learn JGoodies Form layout.setColumnGroups(new int[][] { { 1, 5 }, { 3, 7 } }); DefaultFormBuilder mainPanel = new DefaultFormBuilder(layout); mainPanel.appendSeparator(Messages.getString("VlcTrans.1")); mainPanel.append(experimentalCodecs = new JCheckBox(Messages.getString("VlcTrans.3"), configuration.isVlcExperimentalCodecs()), 3); experimentalCodecs.setContentAreaFilled(false); experimentalCodecs.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setVlcExperimentalCodecs(e.getStateChange() == ItemEvent.SELECTED); } }); mainPanel.append(audioSyncEnabled = new JCheckBox(Messages.getString("VlcTrans.4"), configuration.isVlcAudioSyncEnabled()), 3); audioSyncEnabled.setContentAreaFilled(false); audioSyncEnabled.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setVlcAudioSyncEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mainPanel.nextLine(); // Developer stuff. Theoretically is temporary mainPanel.appendSeparator(Messages.getString("VlcTrans.10")); // Add scale as a subpanel because it has an awkward layout mainPanel.append(Messages.getString("VlcTrans.11")); FormLayout scaleLayout = new FormLayout("pref,3dlu,pref", ""); DefaultFormBuilder scalePanel = new DefaultFormBuilder(scaleLayout); double startingScale = Double.valueOf(configuration.getVlcScale()); scalePanel.append(scale = new JTextField(String.valueOf(startingScale))); final JSlider scaleSlider = new JSlider(JSlider.HORIZONTAL, 0, 10, (int) (startingScale * 10)); scalePanel.append(scaleSlider); scaleSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent ce) { String value = String.valueOf((double) scaleSlider.getValue() / 10); scale.setText(value); configuration.setVlcScale(value); } }); scale.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { String typed = scale.getText(); if (!typed.matches("\\d\\.\\d")) { return; } double value = Double.parseDouble(typed); scaleSlider.setValue((int) (value * 10)); configuration.setVlcScale(String.valueOf(value)); } }); mainPanel.append(scalePanel.getPanel(), 3); // Audio sample rate FormLayout sampleRateLayout = new FormLayout( "right:pref, 3dlu, right:pref, 3dlu, right:pref, 3dlu, left:pref", ""); DefaultFormBuilder sampleRatePanel = new DefaultFormBuilder(sampleRateLayout); sampleRateOverride = new JCheckBox(Messages.getString("VlcTrans.17"), configuration.getVlcSampleRateOverride()); sampleRatePanel.append(Messages.getString("VlcTrans.18"), sampleRateOverride); sampleRate = new JTextField(configuration.getVlcSampleRate(), 8); sampleRate.setEnabled(configuration.getVlcSampleRateOverride()); sampleRate.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setVlcSampleRate(sampleRate.getText()); } }); sampleRatePanel.append(Messages.getString("VlcTrans.19"), sampleRate); sampleRateOverride.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { boolean checked = e.getStateChange() == ItemEvent.SELECTED; configuration.setVlcSampleRateOverride(checked); sampleRate.setEnabled(checked); } }); mainPanel.nextLine(); mainPanel.append(sampleRatePanel.getPanel(), 7); // Extra options mainPanel.nextLine(); mainPanel.append(Messages.getString("VlcTrans.20"), extraParams = new JTextField(), 5); return mainPanel.getPanel(); }
From source file:ru.goodfil.catalog.ui.forms.FilterWindow.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Sasha aaa contentPanel = new JPanel(); label16 = new JLabel(); label17 = new JLabel(); label18 = new JLabel(); label1 = new JLabel(); cbFilterType = new JComboBox(); label5 = new JLabel(); tbAParam = new JTextField(); label2 = new JLabel(); cbFilterForm = new JComboBox(); label6 = new JLabel(); tbBParam = new JTextField(); label3 = new JLabel(); tbName = new JTextField(); label7 = new JLabel(); tbCParam = new JTextField(); label4 = new JLabel(); panel2 = new JPanel(); tbImage = new JTextField(); btnUploadImage = new JButton(); label8 = new JLabel(); tbDParam = new JTextField(); label19 = new JLabel(); cbFilterStatus = new JComboBox(); label9 = new JLabel(); tbEParam = new JTextField(); label15 = new JLabel(); scrollPane1 = new JScrollPane(); tbAdditionalInfo = new JTextArea(); label10 = new JLabel(); tbFParam = new JTextField(); label11 = new JLabel(); tbGParam = new JTextField(); label12 = new JLabel(); tbHParam = new JTextField(); label13 = new JLabel(); tbPbParam = new JTextField(); label14 = new JLabel(); tbNrParam = new JTextField(); panel1 = new JPanel(); okButton = new JButton(); cancelButton = new JButton(); CellConstraints cc = new CellConstraints(); //======== this ======== setModal(true);// w w w .ja va 2s. com setTitle("\u0424\u0438\u043b\u044c\u0442\u0440"); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("default:grow", "fill:default:grow")); //======== contentPanel ======== { // JFormDesigner evaluation mark contentPanel.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), contentPanel.getBorder())); contentPanel.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); contentPanel.setLayout(new FormLayout( "$rgap, default, $lcgap, default:grow, $lcgap, right:20dlu, $lcgap, default:grow, $rgap", "13*(default, $lgap), fill:default:grow, $lgap, default")); //---- label16 ---- label16.setText( "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0435. "); contentPanel.add(label16, cc.xywh(2, 1, 7, 1)); //---- label17 ---- label17.setText( "\u041f\u043e\u043b\u044f, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430\u043c\u0438, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f."); contentPanel.add(label17, cc.xywh(2, 3, 7, 1)); //---- label18 ---- label18.setText( "\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043b\u0438 \u0444\u043e\u0440\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b\"->\"\u0422\u0438\u043f\u044b \u0438 \u0444\u043e\u0440\u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\""); label18.setForeground(Color.blue); contentPanel.add(label18, cc.xywh(2, 5, 7, 1)); //---- label1 ---- label1.setText("\u0422\u0438\u043f*"); contentPanel.add(label1, cc.xy(2, 7)); contentPanel.add(cbFilterType, cc.xy(4, 7)); //---- label5 ---- label5.setText("A"); contentPanel.add(label5, cc.xy(6, 7)); contentPanel.add(tbAParam, cc.xy(8, 7)); //---- label2 ---- label2.setText("\u0424\u043e\u0440\u043c\u0430*"); contentPanel.add(label2, cc.xy(2, 9)); contentPanel.add(cbFilterForm, cc.xy(4, 9)); //---- label6 ---- label6.setText("B"); contentPanel.add(label6, cc.xy(6, 9)); contentPanel.add(tbBParam, cc.xy(8, 9)); //---- label3 ---- label3.setText("\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435*"); contentPanel.add(label3, cc.xy(2, 11)); //---- tbName ---- tbName.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { tbNameKeyTyped(e); } }); tbName.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { tbNameFocusGained(e); } @Override public void focusLost(FocusEvent e) { tbNameFocusGained(e); } }); contentPanel.add(tbName, cc.xy(4, 11)); //---- label7 ---- label7.setText("C"); contentPanel.add(label7, cc.xy(6, 11)); contentPanel.add(tbCParam, cc.xy(8, 11)); //---- label4 ---- label4.setText("\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435"); contentPanel.add(label4, cc.xy(2, 13)); //======== panel2 ======== { panel2.setLayout(new FormLayout("default:grow, $lcgap, default", "default")); panel2.add(tbImage, cc.xy(1, 1)); //---- btnUploadImage ---- btnUploadImage.setText("..."); btnUploadImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnUploadImageActionPerformed(); } }); panel2.add(btnUploadImage, cc.xy(3, 1)); } contentPanel.add(panel2, cc.xy(4, 13)); //---- label8 ---- label8.setText("D"); contentPanel.add(label8, cc.xy(6, 13)); contentPanel.add(tbDParam, cc.xy(8, 13)); //---- label19 ---- label19.setText("\u0421\u0442\u0430\u0442\u0443\u0441"); contentPanel.add(label19, cc.xy(2, 15)); //---- cbFilterStatus ---- cbFilterStatus.setModel(new DefaultComboBoxModel(new String[] { "\u0412 \u041f\u0420\u041e\u0418\u0417\u0412\u041e\u0414\u0421\u0422\u0412\u0415", "\u041f\u041e\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u0422\u0421\u042f", "\u041d\u0415 \u041f\u041e\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u0422\u0421\u042f" })); contentPanel.add(cbFilterStatus, cc.xy(4, 15)); //---- label9 ---- label9.setText("E"); contentPanel.add(label9, cc.xy(6, 15)); contentPanel.add(tbEParam, cc.xy(8, 15)); //---- label15 ---- label15.setText("\u0414\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f"); contentPanel.add(label15, cc.xy(2, 17)); //======== scrollPane1 ======== { scrollPane1.setViewportView(tbAdditionalInfo); } contentPanel.add(scrollPane1, cc.xywh(4, 17, 1, 11)); //---- label10 ---- label10.setText("F"); contentPanel.add(label10, cc.xy(6, 17)); contentPanel.add(tbFParam, cc.xy(8, 17)); //---- label11 ---- label11.setText("G"); contentPanel.add(label11, cc.xy(6, 19)); contentPanel.add(tbGParam, cc.xy(8, 19)); //---- label12 ---- label12.setText("H"); contentPanel.add(label12, cc.xy(6, 21)); contentPanel.add(tbHParam, cc.xy(8, 21)); //---- label13 ---- label13.setText("PB"); contentPanel.add(label13, cc.xy(6, 23)); contentPanel.add(tbPbParam, cc.xy(8, 23)); //---- label14 ---- label14.setText("NR"); contentPanel.add(label14, cc.xy(6, 25)); contentPanel.add(tbNrParam, cc.xy(8, 25)); //======== panel1 ======== { panel1.setLayout(new FormLayout("default:grow, 2*($lcgap, $button)", "default")); //---- okButton ---- okButton.setText("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okButtonActionPerformed(e); } }); panel1.add(okButton, cc.xy(3, 1)); //---- cancelButton ---- cancelButton.setText("\u041e\u0442\u043c\u0435\u043d\u0430"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cancelButtonActionPerformed(e); } }); panel1.add(cancelButton, cc.xy(5, 1)); } contentPanel.add(panel1, cc.xywh(2, 29, 7, 1)); } contentPane.add(contentPanel, cc.xy(1, 1)); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents cbFilterType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { SelectItem selectItem = (SelectItem) e.getItem(); FilterType ft = carsService.getFilterTypeByCode(selectItem.getId()); reReadFilterForms(ft.getCode()); } } }); cbFilterForm.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { adjustParameters(); adjustButtonsEnabled(); } } }); }
From source file:de.codesourcery.flocking.KDTree.java
public static void main(String[] args) { final KDTree<Vec2d> tree = new KDTree<Vec2d>(); Random rnd = new Random(System.currentTimeMillis()); for (int i = 0; i < 100; i++) { final double x = rnd.nextDouble() * MODEL_WIDTH; final double y = rnd.nextDouble() * MODEL_HEIGHT; tree.add(x, y, new Vec2d(x, y)); }/*from w w w . ja va2 s . c om*/ final MyPanel panel = new MyPanel(tree); panel.setPreferredSize(new Dimension((int) MODEL_WIDTH * 2, (int) MODEL_HEIGHT * 2)); panel.addMouseListener(new MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { final Vec2d p = panel.viewToModel(e.getX(), e.getY()); panel.mark(p.x, p.y, 55); }; }); final JFrame frame = new JFrame("KDTreeTest"); frame.addKeyListener(new KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent e) { }; }); frame.getContentPane().setLayout(new GridBagLayout()); final GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.BOTH; cnstrs.gridx = GridBagConstraints.REMAINDER; cnstrs.gridy = GridBagConstraints.REMAINDER; cnstrs.weightx = 1.0; cnstrs.weighty = 1.0; frame.getContentPane().add(panel, cnstrs); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:net.sf.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java
@SuppressWarnings("serial") @Override/*from w ww .ja v a 2 s . c o m*/ public void installComponents(VFSJFileChooser fc) { AbstractVFSFileSystemView fsv = fc.getFileSystemView(); fc.setBorder(new EmptyBorder(12, 12, 11, 11)); fc.setLayout(new BorderLayout(0, 11)); filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor()); fc.addPropertyChangeListener(filePane); updateUseShellFolder(); // ********************************* // // **** Construct the top panel **** // // ********************************* // // Directory manipulation buttons JPanel topPanel = new JPanel(new BorderLayout(11, 0)); topButtonPanel = new JPanel(); topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS)); topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS); // Add the top panel to the fileChooser fc.add(topPanel, BorderLayout.NORTH); // ComboBox Label lookInLabel = new JLabel(lookInLabelText); topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS); // CurrentDir ComboBox directoryComboBox = new JComboBox() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); // Must be small enough to not affect total width. d.width = 150; return d; } }; directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText); directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); lookInLabel.setLabelFor(directoryComboBox); directoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBox.setModel(directoryComboBoxModel); directoryComboBox.addActionListener(directoryComboBoxAction); directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc)); directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT); directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT); directoryComboBox.setMaximumRowCount(8); topPanel.add(directoryComboBox, BorderLayout.CENTER); // Up Button upFolderButton = new JButton(getChangeToParentDirectoryAction()); upFolderButton.setText(null); upFolderButton.setIcon(upFolderIcon); upFolderButton.setToolTipText(upFolderToolTipText); upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName); upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); upFolderButton.setMargin(shrinkwrap); topButtonPanel.add(upFolderButton); topButtonPanel.add(Box.createRigidArea(hstrut5)); // Home Button FileObject homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; if (fsv.isRoot(homeDir)) { toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". } JButton b = new JButton(homeFolderIcon); b.setToolTipText(toolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); b.addActionListener(getGoHomeAction()); topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // New Directory Button if (!UIManager.getBoolean("FileChooser.readOnly")) { b = new JButton(filePane.getNewFolderAction()); b.setText(null); b.setIcon(newFolderIcon); b.setToolTipText(newFolderToolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); } topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // View button group ButtonGroup viewButtonGroup = new ButtonGroup(); // List Button listViewButton = new JToggleButton(listViewIcon); listViewButton.setToolTipText(listViewButtonToolTipText); listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName); listViewButton.setSelected(true); listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); listViewButton.setMargin(shrinkwrap); listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST)); topButtonPanel.add(listViewButton); viewButtonGroup.add(listViewButton); // Details Button detailsViewButton = new JToggleButton(detailsViewIcon); detailsViewButton.setToolTipText(detailsViewButtonToolTipText); detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButtonAccessibleName); detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); detailsViewButton.setMargin(shrinkwrap); detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS)); topButtonPanel.add(detailsViewButton); viewButtonGroup.add(detailsViewButton); filePane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("viewType".equals(e.getPropertyName())) { final int viewType = filePane.getViewType(); if (viewType == VFSFilePane.VIEWTYPE_LIST) { listViewButton.setSelected(true); } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) { detailsViewButton.setSelected(true); } } } }); // ************************************** // // ******* Add the directory pane ******* // // ************************************** // fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS); JComponent accessory = fc.getAccessory(); if (accessory != null) { getAccessoryPanel().add(accessory); } filePane.setPreferredSize(LIST_PREF_SIZE); fc.add(filePane, BorderLayout.CENTER); // ********************************** // // **** Construct the bottom panel ** // // ********************************** // bottomPanel = getBottomPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); fc.add(bottomPanel, BorderLayout.SOUTH); // FileName label and textfield JPanel fileNamePanel = new JPanel(); fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(fileNamePanel); bottomPanel.add(Box.createRigidArea(vstrut5)); fileNameLabel = new AlignedLabel(); populateFileNameLabel(); fileNamePanel.add(fileNameLabel); fileNameTextField = new JTextField(35) { @Override public Dimension getMaximumSize() { return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height); } }; PopupHandler.installDefaultMouseListener(fileNameTextField); fileNamePanel.add(fileNameTextField); fileNameLabel.setLabelFor(fileNameTextField); fileNameTextField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (!getFileChooser().isMultiSelectionEnabled()) { filePane.clearSelection(); } } }); if (fc.isMultiSelectionEnabled()) { setFileName(fileNameString(fc.getSelectedFiles())); } else { setFileName(fileNameString(fc.getSelectedFile())); } // Filetype label and combobox JPanel filesOfTypePanel = new JPanel(); filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(filesOfTypePanel); AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText); filesOfTypePanel.add(filesOfTypeLabel); filterComboBoxModel = createFilterComboBoxModel(); fc.addPropertyChangeListener(filterComboBoxModel); filterComboBox = new JComboBox(filterComboBoxModel); filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText); filesOfTypeLabel.setLabelFor(filterComboBox); filterComboBox.setRenderer(createFilterComboBoxRenderer()); filesOfTypePanel.add(filterComboBox); // buttons getButtonPanel().setLayout(new ButtonAreaLayout()); approveButton = new JButton(getApproveButtonText(fc)); // Note: Metal does not use mnemonics for approve and cancel approveButton.addActionListener(getApproveSelectionAction()); fileNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { getApproveSelectionAction().actionPerformed(null); } } }); approveButton.setToolTipText(getApproveButtonToolTipText(fc)); getButtonPanel().add(approveButton); cancelButton = new JButton(cancelButtonText); cancelButton.setToolTipText(cancelButtonToolTipText); cancelButton.addActionListener(getCancelSelectionAction()); getButtonPanel().add(cancelButton); if (fc.getControlButtonsAreShown()) { addControlButtons(); } groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel }); }
From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java
private void initComponents() { JPanel mainPanel = new JPanel(new GridBagLayout()); // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Title panel JPanel titlePanel = new JPanel(new FlowLayout(LEFT)); titlePanel.setBackground(WHITE);/*from ww w .j a v a 2s. c o m*/ // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10)); JLabel titleLabel = new JLabel(WELCOME); titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f)); // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10)); JLabel titleIcon = new JLabel(tavernaCogs32x32Icon); // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10)); DialogTextArea titleMessage = new DialogTextArea(PLEASE_FILL_IN_THIS_REGISTRATION_FORM); titleMessage.setMargin(new Insets(0, 20, 0, 10)); titleMessage.setFont(baseFont); titleMessage.setEditable(false); titleMessage.setFocusable(false); // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10)); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(titleLabel, NORTH); messagePanel.add(titleMessage, CENTER); messagePanel.setBackground(WHITE); titlePanel.add(titleIcon); titlePanel.add(messagePanel); addDivider(titlePanel, BOTTOM, true); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 2; // gbc.insets = new Insets(5, 10, 0, 0); mainPanel.add(titlePanel, gbc); // Registration messages gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 1; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; // gbc.insets = new Insets(5, 0, 0, 10); DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER); registrationMessage1.setMargin(new Insets(0, 10, 0, 0)); registrationMessage1.setFont(baseFont); registrationMessage1.setEditable(false); registrationMessage1.setFocusable(false); registrationMessage1.setBackground(getBackground()); DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO); registrationMessage2.setMargin(new Insets(0, 10, 0, 10)); registrationMessage2.setFont(baseFont); registrationMessage2.setEditable(false); registrationMessage2.setFocusable(false); registrationMessage2.setBackground(getBackground()); JPanel registrationMessagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); registrationMessagePanel.add(registrationMessage1); registrationMessagePanel.add(registrationMessage2); addDivider(registrationMessagePanel, BOTTOM, true); mainPanel.add(registrationMessagePanel, gbc); // Mandatory label // JLabel mandatoryLabel = new JLabel("* Mandatory fields"); // mandatoryLabel.setFont(baseFont); // gbc.weightx = 0.0; // gbc.weighty = 0.0; // gbc.gridx = 0; // gbc.gridy = 3; // gbc.fill = NONE; // gbc.anchor = GridBagConstraints.EAST; // gbc.gridwidth = 2; // gbc.insets = new Insets(0, 10, 0, 20); // mainPanel.add(mandatoryLabel, gbc); // First name JLabel firstNameLabel = new JLabel(FIRST_NAME); firstNameLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 4; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(0, 10, 0, 10); mainPanel.add(firstNameLabel, gbc); firstNameTextField = new JTextField(); firstNameTextField.setFont(baseFont); if (previousRegistrationData != null) firstNameTextField.setText(previousRegistrationData.getFirstName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 4; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(firstNameTextField, gbc); // Last name JLabel lastNameLabel = new JLabel(LAST_NAME); lastNameLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 5; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(0, 10, 0, 10); mainPanel.add(lastNameLabel, gbc); lastNameTextField = new JTextField(); lastNameTextField.setFont(baseFont); if (previousRegistrationData != null) lastNameTextField.setText(previousRegistrationData.getLastName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 5; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(lastNameTextField, gbc); // Email address JLabel emailLabel = new JLabel(EMAIL_ADDRESS); emailLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 6; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(emailLabel, gbc); emailTextField = new JTextField(); emailTextField.setFont(baseFont); if (previousRegistrationData != null) emailTextField.setText(previousRegistrationData.getEmailAddress()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 6; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(emailTextField, gbc); // Keep me informed keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED); keepMeInformedCheckBox.setFont(baseFont); if (previousRegistrationData != null) keepMeInformedCheckBox.setSelected(previousRegistrationData.getKeepMeInformed()); keepMeInformedCheckBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox.isSelected()); } } }); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 7; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(keepMeInformedCheckBox, gbc); // Institution name JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME); institutionLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 8; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(institutionLabel, gbc); institutionOrCompanyTextField = new JTextField(); institutionOrCompanyTextField.setFont(baseFont); if (previousRegistrationData != null) institutionOrCompanyTextField.setText(previousRegistrationData.getInstitutionOrCompanyName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 8; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(institutionOrCompanyTextField, gbc); // Industry type JLabel industryLabel = new JLabel(" Industry type:"); industryLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 9; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(industryLabel, gbc); industryTypeTextField = new JComboBox<>(industryTypes); industryTypeTextField.setFont(baseFont); if (previousRegistrationData != null) industryTypeTextField.setSelectedItem(previousRegistrationData.getIndustry()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 9; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(industryTypeTextField, gbc); // Field of investigation JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION); fieldLabel.setFont(baseFont); fieldLabel.setEditable(false); fieldLabel.setFocusable(false); fieldLabel.setBackground(getBackground()); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 10; gbc.fill = NONE; gbc.anchor = LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(fieldLabel, gbc); fieldTextField = new JTextField(); fieldTextField.setFont(baseFont); if (previousRegistrationData != null) fieldTextField.setText(previousRegistrationData.getField()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 10; gbc.fill = HORIZONTAL; gbc.anchor = FIRST_LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(fieldTextField, gbc); // Purpose of using Taverna JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA); purposeLabel.setFont(baseFont); purposeLabel.setEditable(false); purposeLabel.setFocusable(false); purposeLabel.setBackground(getBackground()); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 11; gbc.fill = NONE; gbc.anchor = LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(purposeLabel, gbc); purposeTextArea = new JTextArea(4, 30); purposeTextArea.setFont(baseFont); purposeTextArea.setLineWrap(true); purposeTextArea.setAutoscrolls(true); if (previousRegistrationData != null) purposeTextArea.setText(previousRegistrationData.getPurposeOfUsingTaverna()); purposeTextArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_TAB) { if (evt.getModifiers() > 0) purposeTextArea.transferFocusBackward(); else purposeTextArea.transferFocus(); evt.consume(); } } }); JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 11; gbc.fill = HORIZONTAL; gbc.anchor = FIRST_LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(purposeScrollPane, gbc); // Terms and conditions termsAndConditionsCheckBox = new JCheckBox(I_AGREE_TO_THE_TERMS_AND_CONDITIONS); termsAndConditionsCheckBox.setFont(baseFont); termsAndConditionsCheckBox.setBorder(null); termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); termsAndConditionsCheckBox.setSelected(!termsAndConditionsCheckBox.isSelected()); } } }); // gbc.weightx = 0.0; // gbc.weighty = 0.0; // gbc.gridx = 0; // gbc.gridy = 12; // gbc.fill = NONE; // gbc.anchor = WEST; // gbc.gridwidth = 2; // gbc.insets = new Insets(10, 10, 0, 0); // mainPanel.add(termsAndConditionsCheckBox, gbc); // Terms and conditions link JEditorPane termsAndConditionsURL = new JEditorPane(); termsAndConditionsURL.setEditable(false); termsAndConditionsURL.setBackground(getBackground()); termsAndConditionsURL.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); termsAndConditionsURL.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:9px;}"); Document doc = kit.createDefaultDocument(); termsAndConditionsURL.setDocument(doc); termsAndConditionsURL.setText("<html><body><a href=\"" + TERMS_AND_CONDITIONS_URL + "\">" + TERMS_AND_CONDITIONS_URL + "</a></body></html>"); termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { if (he.getEventType() == ACTIVATED) followHyperlinkToTandCs(); } }); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 13; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; gbc.insets = new Insets(5, 10, 0, 10); JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT)); termsAndConditionsPanel.add(termsAndConditionsCheckBox); termsAndConditionsPanel.add(termsAndConditionsURL); mainPanel.add(termsAndConditionsPanel, gbc); // Button panel JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton registerButton = new JButton("Register"); registerButton.setFont(baseFont); registerButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); register(); } } }); registerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { register(); } }); JButton doNotRegisterButton = new JButton("Do not ask me again"); doNotRegisterButton.setFont(baseFont); doNotRegisterButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); doNotRegister(); } } }); doNotRegisterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doNotRegister(); } }); JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks remindMeLaterButton.setFont(baseFont); remindMeLaterButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); remindMeLater(); } } }); remindMeLaterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { remindMeLater(); } }); buttonPanel.add(registerButton); buttonPanel.add(remindMeLaterButton); buttonPanel.add(doNotRegisterButton); addDivider(buttonPanel, TOP, true); gbc.gridx = 0; gbc.gridy = 14; gbc.fill = HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(5, 10, 0, 10); gbc.gridwidth = 2; mainPanel.add(buttonPanel, gbc); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel, CENTER); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java
@SuppressWarnings("serial") @Override/* ww w . j a v a2 s . com*/ public void installComponents(VFSJFileChooser fc) { AbstractVFSFileSystemView fsv = fc.getFileSystemView(); fc.setBorder(new EmptyBorder(12, 12, 11, 11)); fc.setLayout(new BorderLayout(0, 11)); filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor()); fc.addPropertyChangeListener(filePane); updateUseShellFolder(); // ********************************* // // **** Construct the top panel **** // // ********************************* // // Directory manipulation buttons JPanel topPanel = new JPanel(new BorderLayout(11, 0)); topButtonPanel = new JPanel(); topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS)); topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS); // Add the top panel to the fileChooser fc.add(topPanel, BorderLayout.NORTH); // ComboBox Label lookInLabel = new JLabel(lookInLabelText); topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS); // CurrentDir ComboBox directoryComboBox = new JComboBox() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); // Must be small enough to not affect total width. d.width = 150; return d; } }; directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText); directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); lookInLabel.setLabelFor(directoryComboBox); directoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBox.setModel(directoryComboBoxModel); directoryComboBox.addActionListener(directoryComboBoxAction); directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc)); directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT); directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT); directoryComboBox.setMaximumRowCount(8); topPanel.add(directoryComboBox, BorderLayout.CENTER); // Up Button upFolderButton = new JButton(getChangeToParentDirectoryAction()); upFolderButton.setText(null); upFolderButton.setIcon(upFolderIcon); upFolderButton.setToolTipText(upFolderToolTipText); upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName); upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); upFolderButton.setMargin(shrinkwrap); topButtonPanel.add(upFolderButton); topButtonPanel.add(Box.createRigidArea(hstrut5)); // Home Button FileObject homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; if (fsv.isRoot(homeDir)) { toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". } JButton b = new JButton(homeFolderIcon); b.setToolTipText(toolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); b.addActionListener(getGoHomeAction()); topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // New Directory Button if (!UIManager.getBoolean("FileChooser.readOnly")) { b = new JButton(filePane.getNewFolderAction()); b.setText(null); b.setIcon(newFolderIcon); b.setToolTipText(newFolderToolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); } topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // View button group ButtonGroup viewButtonGroup = new ButtonGroup(); // List Button listViewButton = new JToggleButton(listViewIcon); listViewButton.setToolTipText(listViewButtonToolTipText); listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName); listViewButton.setSelected(true); listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); listViewButton.setMargin(shrinkwrap); listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST)); topButtonPanel.add(listViewButton); viewButtonGroup.add(listViewButton); // Details Button detailsViewButton = new JToggleButton(detailsViewIcon); detailsViewButton.setToolTipText(detailsViewButtonToolTipText); detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButtonAccessibleName); detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); detailsViewButton.setMargin(shrinkwrap); detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS)); topButtonPanel.add(detailsViewButton); viewButtonGroup.add(detailsViewButton); filePane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("viewType".equals(e.getPropertyName())) { final int viewType = filePane.getViewType(); if (viewType == VFSFilePane.VIEWTYPE_LIST) { listViewButton.setSelected(true); } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) { detailsViewButton.setSelected(true); } } } }); // ************************************** // // ******* Add the directory pane ******* // // ************************************** // fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS); JComponent accessory = fc.getAccessory(); if (accessory != null) { getAccessoryPanel().add(accessory); } filePane.setPreferredSize(LIST_PREF_SIZE); fc.add(filePane, BorderLayout.CENTER); // ********************************** // // **** Construct the bottom panel ** // // ********************************** // bottomPanel = getBottomPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); fc.add(bottomPanel, BorderLayout.SOUTH); // FileName label and textfield JPanel fileNamePanel = new JPanel(); fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(fileNamePanel); bottomPanel.add(Box.createRigidArea(vstrut5)); fileNameLabel = new AlignedLabel(); populateFileNameLabel(); fileNamePanel.add(fileNameLabel); fileNameTextField = new JTextField(35) { @Override public Dimension getMaximumSize() { return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height); } }; PopupHandler.installDefaultMouseListener(fileNameTextField); fileNamePanel.add(fileNameTextField); fileNameLabel.setLabelFor(fileNameTextField); fileNameTextField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (!getFileChooser().isMultiSelectionEnabled()) { filePane.clearSelection(); } } }); if (fc.isMultiSelectionEnabled()) { setFileName(fileNameString(fc.getSelectedFileObjects())); } else { setFileName(fileNameString(fc.getSelectedFileObject())); } // Filetype label and combobox JPanel filesOfTypePanel = new JPanel(); filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(filesOfTypePanel); AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText); filesOfTypePanel.add(filesOfTypeLabel); filterComboBoxModel = createFilterComboBoxModel(); fc.addPropertyChangeListener(filterComboBoxModel); filterComboBox = new JComboBox(filterComboBoxModel); filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText); filesOfTypeLabel.setLabelFor(filterComboBox); filterComboBox.setRenderer(createFilterComboBoxRenderer()); filesOfTypePanel.add(filterComboBox); // buttons getButtonPanel().setLayout(new ButtonAreaLayout()); approveButton = new JButton(getApproveButtonText(fc)); // Note: Metal does not use mnemonics for approve and cancel approveButton.addActionListener(getApproveSelectionAction()); fileNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { getApproveSelectionAction().actionPerformed(null); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { getFileChooser().cancelSelection(); } } }); approveButton.setToolTipText(getApproveButtonToolTipText(fc)); getButtonPanel().add(approveButton); cancelButton = new JButton(cancelButtonText); cancelButton.setToolTipText(cancelButtonToolTipText); cancelButton.addActionListener(getCancelSelectionAction()); getButtonPanel().add(cancelButton); if (fc.getControlButtonsAreShown()) { addControlButtons(); } groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel }); }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Initialize all GUI components and display the UI *//*from w ww . j a v a 2 s . com*/ protected void initGUI() { settingsCLM = new ProteinQuantChartsCLM(false); setTitle("Qurate"); try { setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this); assert null != contentPanel; } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } //Menu openFileAction = new OpenFileAction(this); createChartsAction = new CreateChartsAction(); filterPepXMLAction = new FilterPepXMLAction(this); proteinSummaryAction = new ProteinSummaryAction(this); try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.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); } //Global stuff setSize(fullWidth, fullHeight); setContentPane(contentPanel); ListenerHelper helper = new ListenerHelper(this); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; leftPanel.setLayout(new GridBagLayout()); leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); //Properties panel stuff propertiesTable = new QuantEvent.QuantEventPropertiesTable(); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesTable); propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight)); //event summary table; disembodied eventSummaryTable = new QuantEventsSummaryTable(); eventSummaryTable.setVisible(true); ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel(); tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler()); JScrollPane eventSummaryScrollPane = new JScrollPane(); eventSummaryScrollPane.setViewportView(eventSummaryTable); eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight); eventSummaryFrame = new Frame("All Events"); eventSummaryFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { eventSummaryFrame.setVisible(false); } }); eventSummaryFrame.setSize(950, 450); eventSummaryFrame.add(eventSummaryScrollPane); //fields related to navigation navigationPanel = new JPanel(); backButton = new JButton("<"); backButton.setToolTipText("Previous Event"); backButton.setMaximumSize(new Dimension(50, 30)); backButton.setEnabled(false); forwardButton = new JButton(">"); forwardButton.setToolTipText("Next Event"); forwardButton.setMaximumSize(new Dimension(50, 30)); forwardButton.setEnabled(false); showEventSummaryButton = new JButton("Show All"); showEventSummaryButton.setToolTipText("Show all events in a table"); showEventSummaryButton.setEnabled(false); helper.addListener(backButton, "buttonBack_actionPerformed"); helper.addListener(forwardButton, "buttonForward_actionPerformed"); helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed"); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; navigationPanel.add(backButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; navigationPanel.add(forwardButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; navigationPanel.add(showEventSummaryButton, gbc); gbc.fill = GridBagConstraints.BOTH; navigationPanel.setBorder(BorderFactory.createTitledBorder("Event")); gbc.anchor = GridBagConstraints.PAGE_START; //Fields related to curation of events curationPanel = new JPanel(); curationPanel.setLayout(new GridBagLayout()); curationPanel.setBorder(BorderFactory.createTitledBorder("Curation")); //Quantitation curation JPanel quantCurationPanel = new JPanel(); quantCurationPanel.setLayout(new GridBagLayout()); quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation")); quantCurationButtonGroup = new ButtonGroup(); JRadioButton unknownRadioButton = new JRadioButton("?"); JRadioButton goodRadioButton = new JRadioButton("Good"); JRadioButton badRadioButton = new JRadioButton("Bad"); onePeakRatioRadioButton = new JRadioButton("1-Peak"); unknownRadioButton.setEnabled(false); goodRadioButton.setEnabled(false); badRadioButton.setEnabled(false); onePeakRatioRadioButton.setEnabled(false); quantCurationButtonGroup.add(unknownRadioButton); quantCurationButtonGroup.add(goodRadioButton); quantCurationButtonGroup.add(badRadioButton); quantCurationButtonGroup.add(onePeakRatioRadioButton); unknownRadioButtonModel = unknownRadioButton.getModel(); goodRadioButtonModel = goodRadioButton.getModel(); badRadioButtonModel = badRadioButton.getModel(); onePeakRadioButtonModel = onePeakRatioRadioButton.getModel(); helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed"); helper.addListener(goodRadioButton, "buttonCuration_actionPerformed"); helper.addListener(badRadioButton, "buttonCuration_actionPerformed"); helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; quantCurationPanel.add(unknownRadioButton, gbc); quantCurationPanel.add(badRadioButton, gbc); quantCurationPanel.add(goodRadioButton, gbc); quantCurationPanel.add(onePeakRatioRadioButton, gbc); gbc.anchor = GridBagConstraints.PAGE_START; //ID curation JPanel idCurationPanel = new JPanel(); idCurationPanel.setLayout(new GridBagLayout()); idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID")); idCurationButtonGroup = new ButtonGroup(); JRadioButton idUnknownRadioButton = new JRadioButton("?"); JRadioButton idGoodRadioButton = new JRadioButton("Good"); JRadioButton idBadRadioButton = new JRadioButton("Bad"); idUnknownRadioButton.setEnabled(false); idGoodRadioButton.setEnabled(false); idBadRadioButton.setEnabled(false); idCurationButtonGroup.add(idUnknownRadioButton); idCurationButtonGroup.add(idGoodRadioButton); idCurationButtonGroup.add(idBadRadioButton); idUnknownRadioButtonModel = idUnknownRadioButton.getModel(); idGoodRadioButtonModel = idGoodRadioButton.getModel(); idBadRadioButtonModel = idBadRadioButton.getModel(); helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; idCurationPanel.add(idUnknownRadioButton, gbc); idCurationPanel.add(idBadRadioButton, gbc); idCurationPanel.add(idGoodRadioButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; curationPanel.add(quantCurationPanel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; curationPanel.add(idCurationPanel, gbc); //curation comment commentTextField = new JTextField(); commentTextField.setToolTipText("Comment on this event"); //saves after every keypress. Would be more efficient to save when navigating away or saving to file commentTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (quantEvents == null) return; QuantEvent quantEvent = quantEvents.get(displayedEventIndex); //save the comment, being careful about tabs and new lines quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " ")); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); curationPanel.add(commentTextField, gbc); assessmentPanel = new JPanel(); assessmentPanel.setLayout(new GridBagLayout()); assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment")); assessmentTypeTextField = new JTextField(); assessmentTypeTextField.setEditable(false); assessmentPanel.add(assessmentTypeTextField, gbc); assessmentDescTextField = new JTextField(); assessmentDescTextField.setEditable(false); assessmentPanel.add(assessmentDescTextField, gbc); //Theoretical peak distribution gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; theoreticalPeaksPanel = new JPanel(); theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks")); theoreticalPeaksPanel.setLayout(new GridBagLayout()); theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight)); theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight)); showTheoreticalPeaks(); //Add everything to the left panel gbc.insets = new Insets(0, 5, 0, 5); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; leftPanel.addComponentListener(new LeftPanelResizeListener()); gbc.weighty = 10; gbc.fill = GridBagConstraints.VERTICAL; leftPanel.add(propertiesScrollPane, gbc); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_END; gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(assessmentPanel, gbc); leftPanel.add(theoreticalPeaksPanel, gbc); gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(curationPanel, gbc); leftPanel.add(navigationPanel, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_START; //Chart display multiChartDisplay = new TabbedMultiChartDisplayPanel(); multiChartDisplay.setResizeDelayMS(0); rightPanel.addComponentListener(new RightPanelResizeListener()); rightPanel.add(multiChartDisplay, gbc); //status message messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); //paranoia. Sometimes it seems Qurate doesn't exit when you close every window addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == WindowEvent.WINDOW_CLOSED) { dispose(); System.exit(0); } } }); }
From source file:uk.ac.liverpool.narrative.SolutionGraph.java
/** * @param template/* w w w. j a v a2 s . c om*/ * @param out * @param in * @param current * @return * @throws IOException */ private StringBuilder mainLoop(final Template template, final JTextArea out, final JTextField in, STRIPSState current) throws IOException { Collection<Action> aa = ggraph.getOutEdges(current); StringBuilder ssf = new StringBuilder(); if (aa == null) { out.append("No action from the start?\n"); return ssf; } do { if (aa.size() == 1) { Action a = aa.iterator().next(); out.append(actionToString(template, a)); ssf.append(actionToString(template, a)); if (a != null) { current = ggraph.getOpposite(current, a); } } else if (aa.size() > 1) { int n = 0; final Map<Integer, Action> hm = new MapWrapper<Integer, Action>(); out.append(" Please select the next action: " + "\n"); Iterator<Action> it = aa.iterator(); while (it.hasNext()) { n++; Action a = it.next(); out.append(" " + n + ") " + actionToString(template, a)); hm.put(n, a); } out.append("" + "\n"); final STRIPSState c2 = current; in.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) return; int a = 0; String s = in.getText(); try { a = Integer.parseInt(s); } catch (Exception x) { } try { a = Integer.parseInt(s); Action a2 = hm.get(a); if (a2 != null) { out.append(actionToString(template, a2)); in.removeKeyListener(this); in.setText(""); mainLoop(template, out, in, ggraph.getOpposite(c2, a2)); } } catch (Exception x) { return; } super.keyReleased(e); } }); return ssf; } else { break; } aa = ggraph.getOutEdges(current); } while (aa.size() > 0); out.append("The end"); return ssf; }
From source file:edu.ku.brc.specify.conversion.CustomDBConverterPanel.java
/** * Creates the UI for the login and hooks up any listeners. * @param isDlg whether the parent is a dialog (false mean JFrame) *//*from w ww . ja v a2 s.c o m*/ protected void createUI(final boolean isDlg) { PropertiesPickListAdapter dbPickList = new PropertiesPickListAdapter("convert.databasesSource"); PropertiesPickListAdapter svPickList = new PropertiesPickListAdapter("convert.serversSource"); PropertiesPickListAdapter dbDestPickList = new PropertiesPickListAdapter("convert.databasesDest"); PropertiesPickListAdapter svDestPickList = new PropertiesPickListAdapter("convert.serversDest"); usernameSource = createTextField(20); passwordSource = createPasswordField(20); usernameDest = createTextField(20); passwordDest = createPasswordField(20); databasesSource = new ValComboBox(dbPickList); serversSource = new ValComboBox(svPickList); databasesDest = new ValComboBox(dbDestPickList); serversDest = new ValComboBox(svDestPickList); setControlSize(passwordSource); setControlSize(passwordDest); setControlSize(databasesSource); setControlSize(serversSource); setControlSize(databasesDest); setControlSize(serversDest); dbPickList.setComboBox(databasesSource); svPickList.setComboBox(serversSource); dbDestPickList.setComboBox(databasesDest); svDestPickList.setComboBox(serversDest); // autoLoginSourceCBX = createCheckBox(getResourceString("autologin")); rememberUsernameSourceCBX = createCheckBox(getResourceString("rememberuser")); rememberPasswordSourceCBX = createCheckBox(getResourceString("rememberpassword")); autoLoginDestCBX = createCheckBox(getResourceString("autologin")); rememberUsernameDestCBX = createCheckBox(getResourceString("rememberuser")); rememberPasswordDestCBX = createCheckBox(getResourceString("rememberpassword")); statusBar = new JStatusBar(); statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); cancelBtn = createButton(getResourceString("CANCEL")); loginBtn = createButton(getResourceString("Login")); helpBtn = createButton(getResourceString("HELP")); forwardImgIcon = IconManager.getIcon("Forward"); downImgIcon = IconManager.getIcon("Down"); //moreBtn = createCheckBox("More", forwardImgIcon); // XXX I18N // Extra dbDrivers = DatabaseDriverInfo.getDriversList(); dbDriverCBX = createComboBox(dbDrivers); dbDriverCBX2 = createComboBox(dbDrivers); if (dbDrivers.size() > 0) { String selectedStr = AppPreferences.getLocalPrefs().get("convert.dbdriverSource_selected", "SQLServer"); int inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null)); dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1); selectedStr = AppPreferences.getLocalPrefs().get("convert.dbdriverDest_selected", "SQLServer"); inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null)); dbDriverCBX2.setSelectedIndex(inx > -1 ? inx : -1); } else { JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); System.exit(1); } dbDriverCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUIControls(); } }); dbDriverCBX2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUIControls(); } }); addFocusListenerForTextComp(usernameSource); addFocusListenerForTextComp(passwordSource); addKeyListenerFor(usernameSource, !isDlg); addKeyListenerFor(passwordSource, !isDlg); addKeyListenerFor(databasesSource.getTextField(), !isDlg); addKeyListenerFor(serversSource.getTextField(), !isDlg); addFocusListenerForTextComp(usernameDest); addFocusListenerForTextComp(passwordDest); addKeyListenerFor(usernameDest, !isDlg); addKeyListenerFor(passwordDest, !isDlg); addKeyListenerFor(databasesDest.getTextField(), !isDlg); addKeyListenerFor(serversDest.getTextField(), !isDlg); if (!isDlg) { addKeyListenerFor(loginBtn, true); } //autoLoginSourceCBX.setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.autologin", false)); rememberUsernameSourceCBX .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberuserSource", false)); rememberPasswordSourceCBX .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberpasswordSource", false)); autoLoginDestCBX.setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.autologin2", false)); rememberUsernameDestCBX .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberuserDest", false)); rememberPasswordDestCBX .setSelected(AppPreferences.getLocalPrefs().getBoolean("convert.rememberpasswordDest", false)); // if (autoLoginSourceCBX.isSelected()) // { // usernameSource.setText(AppPreferences.getLocalPrefs().get("convert.usernameSource", "")); // passwordSource.setText(Encryption.decrypt(AppPreferences.getLocalPrefs().get( // "convert.passwordSource", ""))); // usernameSource.requestFocus(); // // } else // { if (rememberUsernameSourceCBX.isSelected()) { usernameSource.setText(AppPreferences.getLocalPrefs().get("convert.usernameSource", "")); SwingUtilities.invokeLater(new Runnable() { public void run() { passwordSource.requestFocus(); } }); } if (rememberPasswordSourceCBX.isSelected()) { passwordSource .setText(Encryption.decrypt(AppPreferences.getLocalPrefs().get("convert.passwordSource", ""))); SwingUtilities.invokeLater(new Runnable() { public void run() { loginBtn.requestFocus(); } }); } //} if (autoLoginDestCBX.isSelected()) { usernameDest.setText(AppPreferences.getLocalPrefs().get("convert.usernameDest", "")); passwordDest .setText(Encryption.decrypt(AppPreferences.getLocalPrefs().get("convert.passwordDest", ""))); usernameDest.requestFocus(); } else { if (rememberUsernameDestCBX.isSelected()) { usernameDest.setText(AppPreferences.getLocalPrefs().get("convert.usernameDest", "")); SwingUtilities.invokeLater(new Runnable() { public void run() { passwordDest.requestFocus(); } }); } if (rememberPasswordDestCBX.isSelected()) { passwordDest.setText( Encryption.decrypt(AppPreferences.getLocalPrefs().get("convert.passwordDest", ""))); SwingUtilities.invokeLater(new Runnable() { public void run() { loginBtn.requestFocus(); } }); } } cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dbConverterListener != null) { dbConverterListener.cancelled(); } } }); loginBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doLogin(); } }); //HelpManager.registerComponent(helpBtn, "login"); HelpMgr.registerComponent(helpBtn, "convert"); // autoLoginSourceCBX.addChangeListener(new ChangeListener() // { // public void stateChanged(ChangeEvent e) // { // if (autoLoginSourceCBX.isSelected()) // { // rememberUsernameSourceCBX.setSelected(true); // rememberPasswordSourceCBX.setSelected(true); // } // updateUIControls(); // } // // }); // moreBtn.addActionListener(new ActionListener() // { // public void actionPerformed(ActionEvent e) // { // if (extraPanel.isVisible()) // { // if (dbDriverCBX.getSelectedIndex() != -1) // { // extraPanel.setVisible(false); // moreBtn.setIcon(forwardImgIcon); // } // // } else // { // extraPanel.setVisible(true); // moreBtn.setIcon(downImgIcon); // } // if (window != null) // { // window.pack(); // } // } // }); // Ask the PropertiesPickListAdapter to set the index from the prefs dbPickList.setSelectedIndex(); svPickList.setSelectedIndex(); dbDestPickList.setSelectedIndex(); svDestPickList.setSelectedIndex(); serversSource.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databasesSource.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); // Layout the form JPanel p = new JPanel();//FormDebugPanel(); PanelBuilder formBuilder = new PanelBuilder( new FormLayout("p,3dlu,max(220px;p):g,3dlu,p,3dlu,max(220px;p):g", UIHelper.createDuplicateJGoodiesDef("p", "2dlu", 13)), p); CellConstraints cc = new CellConstraints(); formBuilder.addSeparator(getResourceString("SOURCE_DB"), cc.xywh(1, 1, 3, 1)); int y = 3; y = addLine("username", usernameSource, formBuilder, cc, y); y = addLine("password", passwordSource, formBuilder, cc, y); y = addLine("databases", databasesSource, formBuilder, cc, y); y = addLine("servers", serversSource, formBuilder, cc, y); // formBuilder.addSeparator(getResourceString("extratitle"), cc.xywh(1, y, 3, 1)); // y +=2; y = addLine("driver", dbDriverCBX, formBuilder, cc, y); y = addLine(null, rememberUsernameSourceCBX, formBuilder, cc, y); y = addLine(null, rememberPasswordSourceCBX, formBuilder, cc, y); //y = addLine(null, autoLoginSourceCBX, formBuilder, cc, y); int x = 5; formBuilder.addSeparator(getResourceString("DEST_DB"), cc.xywh(x, 1, 3, 1)); y = 3; y = addLine("username", usernameDest, formBuilder, cc, x, y); y = addLine("password", passwordDest, formBuilder, cc, x, y); y = addLine("databases", databasesDest, formBuilder, cc, x, y); y = addLine("servers", serversDest, formBuilder, cc, x, y); // formBuilder.addSeparator(getResourceString("extratitle"), cc.xywh(1, y, 3, 1)); // y +=2; y = addLine("driver", dbDriverCBX2, formBuilder, cc, x, y); y = addLine(null, rememberUsernameDestCBX, formBuilder, cc, x, y); y = addLine(null, rememberPasswordDestCBX, formBuilder, cc, x, y); y = addLine(null, autoLoginDestCBX, formBuilder, cc, x, y); PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,max(220px;p):g", "p,2dlu,p,2dlu,p")); extraPanel = extraPanelBlder.getPanel(); extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2)); //formBuilder.add(moreBtn, cc.xy(1, y)); //y += 2; //extraPanelBlder.addSeparator(getResourceString("extratitle"), cc.xywh(1, 1, 3, 1)); //addLine("driver", dbDriverCBX, extraPanelBlder, cc, 3); //extraPanel.setVisible(false); //formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(1, y, 3, 1)); PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p"), this); //JLabel icon = createLabel(IconManager.getIcon("SpecifyLargeIcon")); //icon.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 2)); formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 5)); //outerPanel.add(icon, cc.xy(1, 1)); outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1)); outerPanel.add(ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn), cc.xywh(1, 3, 3, 1)); outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1)); updateUIControls(); }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizardUI.java
/** Initializes the components composing the display.*/ private void initComponents() { filterAnywhere = true;// ww w . j a v a 2 s. com filterArea = new JTextField(); originalColor = filterArea.getForeground(); setTextFieldDefault(DEFAULT_FILTER_TEXT); StringBuilder builder = new StringBuilder(); builder.append("Filter"); if (TagAnnotationData.class.equals(type)) { builder.append(" Tags."); } else if (FileAnnotationData.class.equals(type)) { builder.append(" Attachments."); } else if (DatasetData.class.equals(type)) { builder.append(" Datasets."); } else builder.append("."); filterArea.setToolTipText(builder.toString()); filterArea.getDocument().addDocumentListener(this); filterArea.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent evt) { String value = filterArea.getText(); if (StringUtils.isBlank(value)) { setTextFieldDefault(DEFAULT_FILTER_TEXT); } } @Override public void focusGained(FocusEvent evt) { } }); filterArea.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { String value = filterArea.getText(); if (DEFAULT_FILTER_TEXT.equals(value)) { setTextFieldDefault(null); } } }); filterArea.addKeyListener(new KeyAdapter() { /** * Adds the items to the selected list. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && filterArea.isFocusOwner()) { addItem(); //reset filter setTextFieldDefault(DEFAULT_FILTER_TEXT); availableItemsListbox.requestFocus(); } } }); sorter = new ViewerSorter(); availableItemsListbox = new JTree(); initializeTree(availableItemsListbox, user); availableItemsListbox.addKeyListener(new KeyAdapter() { /** * Adds the items to the selected list. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && availableItemsListbox.isFocusOwner()) { addItem(); } } }); availableItemsListbox.addMouseListener(new MouseAdapter() { /** * Adds the items to the selected list. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { if (e.getClickCount() == 2) { if (availableItemsListbox.isFocusOwner()) addItem(); } } }); availableItemsListbox.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent evt) { firePropertyChange(AVAILABLE_SELECTION_CHANGE, Boolean.TRUE, Boolean.FALSE); } }); selectedItemsListbox = new JTree(); initializeTree(selectedItemsListbox, user); selectedItemsListbox.addKeyListener(new KeyAdapter() { /** * Removes the selected elements from the selected list. * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && selectedItemsListbox.isFocusOwner()) { removeItem(); } } }); selectedItemsListbox.addMouseListener(new MouseAdapter() { /** * Removes the selected elements from the selected list. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { if (e.getClickCount() == 2) { if (selectedItemsListbox.isFocusOwner()) removeItem(); } } }); IconManager icons = IconManager.getInstance(); addButton = new JButton(icons.getIcon(IconManager.RIGHT_ARROW)); removeButton = new JButton(icons.getIcon(IconManager.LEFT_ARROW)); addAllButton = new JButton(icons.getIcon(IconManager.DOUBLE_RIGHT_ARROW)); removeAllButton = new JButton(icons.getIcon(IconManager.DOUBLE_LEFT_ARROW)); addButton.setActionCommand("" + ADD); addButton.addActionListener(this); addAllButton.setActionCommand("" + ADD_ALL); addAllButton.addActionListener(this); removeButton.setActionCommand("" + REMOVE); removeButton.addActionListener(this); removeAllButton.setActionCommand("" + REMOVE_ALL); removeAllButton.addActionListener(this); setImmutableElements(null); }