/** * Method performed when button clicked. * * @param event event that triggers action, here clicking of the button. */ public void actionPerformed(ActionEvent event) { if (choiceBox.getSelectedItem().equals(CUSTOM)) { JFileChooser chooser = new JFileChooser(System.getProperty("user.home")); int returnVal = chooser.showOpenDialog(settingsPanel); if (returnVal == JFileChooser.APPROVE_OPTION) { specifiedOntology = CUSTOM; openFile = chooser.getSelectedFile(); choiceBox.setEditable(true); choiceBox.setSelectedItem(openFile.toString()); choiceBox.setEditable(false); def = false; if (((String) choiceBox.getSelectedItem()).endsWith(".obo")) { settingsPanel.getNamespacePanel().choiceBox.setEnabled(true); } else { settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } } if (returnVal == JFileChooser.CANCEL_OPTION) { choiceBox.setSelectedItem(NONE); specifiedOntology = NONE; def = true; settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } } else if (choiceBox.getSelectedItem().equals(NONE)) { specifiedOntology = NONE; def = true; settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } else { specifiedOntology = (String) choiceBox.getSelectedItem(); def = true; settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } }
public CopyFileToTable() { JPanel jPane1 = new JPanel(); jPane1.setLayout(new BorderLayout()); jPane1.add(new JLabel("Filename"), BorderLayout.WEST); jPane1.add(jbtViewFile, BorderLayout.EAST); jPane1.add(jtfFilename, BorderLayout.CENTER); JPanel jPane2 = new JPanel(); jPane2.setLayout(new BorderLayout()); jPane2.setBorder(new TitledBorder("Source Text File")); jPane2.add(jPane1, BorderLayout.NORTH); jPane2.add(new JScrollPane(jtaFile), BorderLayout.CENTER); JPanel jPane3 = new JPanel(); jPane3.setLayout(new GridLayout(5, 0)); jPane3.add(new JLabel("JDBC Driver")); jPane3.add(new JLabel("Database URL")); jPane3.add(new JLabel("Username")); jPane3.add(new JLabel("Password")); jPane3.add(new JLabel("Table Name")); JPanel jPane4 = new JPanel(); jPane4.setLayout(new GridLayout(5, 0)); jcboDriver.setEditable(true); jPane4.add(jcboDriver); jcboURL.setEditable(true); jPane4.add(jcboURL); jPane4.add(jtfUsername); jPane4.add(jtfPassword); jPane4.add(jtfTableName); JPanel jPane5 = new JPanel(); jPane5.setLayout(new BorderLayout()); jPane5.setBorder(new TitledBorder("Target Database Table")); jPane5.add(jbtCopy, BorderLayout.SOUTH); jPane5.add(jPane3, BorderLayout.WEST); jPane5.add(jPane4, BorderLayout.CENTER); add(jlblStatus, BorderLayout.SOUTH); add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPane2, jPane5), BorderLayout.CENTER); jbtViewFile.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { showFile(); } }); jbtCopy.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { try { copyFile(); } catch (Exception ex) { jlblStatus.setText(ex.toString()); } } }); }
public void backBind() { actionButton.setText(viewModel.actionButtonText); fromValue.setText(viewModel.fromValueText); toValue.setEnabled(viewModel.toValueEnabled); toValue.setText(viewModel.toValueText); toUnit.setEditable(viewModel.toUnitEditable); fromUnit.setEditable(viewModel.fromUnitEditable); errorMsg.setText(viewModel.errorMsg); loadTable(); loadLog(); }
private void createGUIDialog() { JPanel mainPanel = new JPanel(new BorderLayout()); setContentPane(mainPanel); mainPanel.add(new JLabel("Select dimensions to rulerender: "), BorderLayout.PAGE_START); JPanel combosPanel = new JPanel(new GridLayout(2, 2, 10, 10)); mainPanel.add(combosPanel, BorderLayout.CENTER); combosPanel.add(new JLabel("Dimension 1:")); box1 = new JComboBox(choices.toArray()); box1.setEditable(false); box1.setSelectedIndex(0); combosPanel.add(box1); combosPanel.add(new JLabel("Dimension 2:")); box2 = new JComboBox(choices.toArray()); box2.setEditable(false); box2.setSelectedIndex(Math.min(choices.size(), 1)); combosPanel.add(box2); Box h = Box.createHorizontalBox(); mainPanel.add(h, BorderLayout.PAGE_END); h.add(Box.createHorizontalGlue()); JButton okButton = new JButton("OK"); h.add(okButton); okButton.setDefaultCapable(true); h.add(Box.createHorizontalStrut(10)); JButton cancelButton = new JButton("Cancel"); h.add(cancelButton); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { returnCode = OK_BUTTON; dispose(); } }); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { returnCode = CANCEL_BUTTON; dispose(); } }); }
public void setEditable(boolean isEditable) { isEditable_ = isEditable; if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) { ((JTextField) component).setEditable(isEditable_); ((JTextField) component).setFocusable(isEditable_); } if (inputType_.equals("DATE")) { ((XFDateField) component).setEditable(isEditable_); ((XFDateField) component).setFocusable(isEditable_); int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14); if (isEditable_) { this.setBounds( this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT); } else { this.setBounds( this.getBounds().x, this.getBounds().y, 124 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT); } } if (inputType_.equals("LISTBOX")) { ((JComboBox) component).setEditable(isEditable_); ((JComboBox) component).setFocusable(isEditable_); } if (inputType_.equals("CHECKBOX")) { ((JCheckBox) component).setEnabled(isEditable_); ((JCheckBox) component).setFocusable(isEditable_); } }
private JPanel createContentPane() { JPanel panel = new JPanel(); combo1 = new JComboBox<>(numData); panel.add(combo1); combo2 = new JComboBox<>(dayData); combo2.setEditable(true); panel.add(combo2); panel.setSize(300, 200); popupMenu = new JPopupMenu(); JMenuItem item; for (int i = 0; i < dayData.length; i++) { item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); item.addActionListener(this); } panel.addMouseListener(new PopupListener(popupMenu)); JTextField field = new JTextField("CTRL+down for Popup"); // CTRL-down will show the popup. field .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); field.getActionMap().put("OPEN_POPUP", new PopupHandler()); panel.add(field); return panel; }
/** Method that creates the JComponents. */ public void makeJComponents() { // button. choiceBox = new JComboBox(choiceArray); choiceBox.setEditable(false); choiceBox.addActionListener(this); }
public Mapper() { super("Action/Input Mapper"); setSize(500, 600); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel setupPane = new JPanel(new GridLayout(0, 1)); JPanel classPane = new JPanel(new BorderLayout()); classPane.add(new JLabel("Class: "), BorderLayout.WEST); classPane.add(nameF, BorderLayout.CENTER); classPane.add(stateC, BorderLayout.EAST); JPanel mapPane = new JPanel(); mapPane.add(inputB); mapPane.add(actionB); mapPane.add(bindingB); setupPane.add(classPane); setupPane.add(mapPane); getContentPane().add(setupPane, BorderLayout.NORTH); getContentPane().add(new JScrollPane(results), BorderLayout.CENTER); nameF.addActionListener(this); stateC.addActionListener(this); stateC.setEditable(false); new Probe().loadAudioActions(); // !!! setVisible(true); }
private void createComponents(JPanel p) { String tt = "Any of these: 45.5 -120.2 or 45 30 0 n 120 12 0 w or Seattle"; JComboBox field = new JComboBox(); field.setOpaque(false); field.setEditable(true); field.setLightWeightPopupEnabled(false); field.setPreferredSize(new Dimension(200, field.getPreferredSize().height)); field.setToolTipText(tt); JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png")); // new // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png"))); label.setOpaque(false); label.setToolTipText(tt); p.add(label, BorderLayout.WEST); p.add(field, BorderLayout.CENTER); field.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { performGazeteerAction(actionEvent); } }); }
/** * This method initializes mIndividualListComboBox * * @return javax.swing.JComboBox */ private JComboBox getMIndividualListComboBox() { if (mIndividualListComboBox == null) { mIndividualListComboBox = new JComboBox(); mIndividualListComboBox.setBounds(new java.awt.Rectangle(228, 103, 168, 25)); mIndividualListComboBox.setEditable(false); } return mIndividualListComboBox; }
@Override public void setMultiConfValues(String[] multiConfValues) { multiConfValuesModel = new DefaultComboBoxModel(multiConfValues); multiConfValuesBox = new JComboBox(); multiConfValuesBox.setModel(multiConfValuesModel); if (!Configuration.getInstance().isEuMode()) { multiConfValuesBox.setEditable(true); } }
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); } // constructor
private static JComboBox<String> makeComboBox(final boolean isDefault, boolean isEditable) { ComboBoxModel<String> m = new DefaultComboBoxModel<>(new String[] {"aaa", "bbb", "ccc"}); JComboBox<String> comboBox; if (isDefault) { comboBox = new JComboBox<>(m); } else { comboBox = new RemoveButtonComboBox<String>(m); } comboBox.setEditable(isEditable); return comboBox; }
private void initialize() { setSize(300, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); // // Create a combo box with four items and set it to editable so that user can // enter their own value. // final JComboBox comboBox = new JComboBox(new String[] {"One", "Two", "Three", "Four"}); comboBox.setEditable(true); getContentPane().add(comboBox); // // Create two button that will set the selected item of the combo box. The // first button select "Two" and and second button select "Four". // JButton button1 = new JButton("Set Two"); getContentPane().add(button1); button1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { comboBox.setSelectedItem("Two"); } }); JButton button2 = new JButton("Set Four"); getContentPane().add(button2); button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { comboBox.setSelectedItem("Four"); } }); // // Create a text field for displaying the selected item when we press the // Get Value button. When user enter their own value the selected item // returned is the string that entered by user. // final JTextField textField = new JTextField(""); textField.setPreferredSize(new Dimension(150, 20)); JButton button3 = new JButton("Get Value"); getContentPane().add(button3); getContentPane().add(textField); button3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { textField.setText((String) comboBox.getSelectedItem()); } }); }
/** Creates a new <code>SeekPanel</code>. */ public SeekPanel(Component hintParent) { setHintParent(hintParent); Preferences prefs = getPrefs(); I18n i18n = getI18n(); WildVariant[] variants = getConn().getSupportedVariants(); // Create ui elements timeField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 3); incField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 3); isRatedBox = i18n.createCheckBox("ratedBox"); variantChoice = new FixedJComboBox(variants); variantChoice.setEditable(false); autoColor = i18n.createRadioButton("autoColorRadioButton"); whiteColor = i18n.createRadioButton("whiteColorRadioButton"); blackColor = i18n.createRadioButton("blackColorRadioButton"); limitRatingBox = i18n.createCheckBox("limitRatingCheckBox"); minRatingField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 4); maxRatingField = new FixedJTextField(new IntegerStrictPlainDocument(0, 9999), "", 4); manualAcceptBox = i18n.createCheckBox("manualAcceptCheckBox"); useFormulaBox = i18n.createCheckBox("useFormulaCheckBox"); ButtonGroup colorButtonGroup = new ButtonGroup(); colorButtonGroup.add(autoColor); colorButtonGroup.add(whiteColor); colorButtonGroup.add(blackColor); String color = prefs.getString("color", "auto"); // Set initial values of ui elements timeField.setText(String.valueOf(prefs.getInt("time", 10))); incField.setText(String.valueOf(prefs.getInt("inc", 0))); isRatedBox.setSelected(prefs.getBool("isRated", true)); variantChoice.setSelectedIndex( findVariantIndex(variants, prefs.getString("variant", "Chess"))); autoColor.setSelected("auto".equals(color)); whiteColor.setSelected("white".equals(color)); blackColor.setSelected("black".equals(color)); limitRatingBox.setSelected(prefs.getBool("limitRating", false)); minRatingField.setText(String.valueOf(prefs.getInt("minRating", 0))); maxRatingField.setText(String.valueOf(prefs.getInt("maxRating", 9999))); manualAcceptBox.setSelected(prefs.getBool("manualAccept", false)); useFormulaBox.setSelected(prefs.getBool("useFormula", true)); // Disable isRated for guests if (getUser().isGuest()) { isRatedBox.setSelected(false); isRatedBox.setEnabled(false); } createUI(); }
/** * Constructor with a string argument that becomes part of the label of the button. * * @param settingsPanel : parent window */ public ChooseOntologyPanel( SettingsPanel settingsPanel, String bingoDir, String[] choiceArray, String choice_def) { super(); this.bingoDir = bingoDir; this.settingsPanel = settingsPanel; this.choiceArray = choiceArray; // annotationFilePath = new File(bingoDir, "bingo"); setOpaque(false); makeJComponents(); // Layout with GridLayout. setLayout(new GridLayout(1, 0)); add(choiceBox); // defaults HashSet<String> choiceSet = new HashSet<String>(); for (String s : choiceArray) { choiceSet.add(s); } if (choiceSet.contains(choice_def)) { choiceBox.setSelectedItem(choice_def); this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); specifiedOntology = (String) choiceBox.getSelectedItem(); def = true; } else { choiceBox.removeActionListener(this); choiceBox.setEditable(true); choiceBox.setSelectedItem(choice_def); choiceBox.setEditable(false); specifiedOntology = BingoAlgorithm.CUSTOM; def = false; if (choice_def.endsWith(".obo")) { this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(true); } else { this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } choiceBox.addActionListener(this); } }
public ReferencePropertyWidget(boolean containedByListReferenceGUI) { this.containedByListReferenceGUI = containedByListReferenceGUI; // get Options m_comboBox = new JComboBox(); m_comboBox.setEditable(false); m_comboBox.setPreferredSize(new Dimension(300, 20)); // m_comboBox.setMinimumSize(new Dimension(260, 20)); m_comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 20)); KeyStroke controlT = KeyStroke.getKeyStroke("control SPACE"); getTextField().getInputMap().put(controlT, controlT); getTextField().getActionMap().put(controlT, new CodeCompleteAction()); ToolTipManager.sharedInstance().registerComponent(m_comboBox); }
protected JPanel buildFieldsPanel() { JPanel fieldsPanel = new JPanel(new FormLayout()); nameField = new JTextField(); setPreferredWidthOf(nameField, 200); fieldsPanel.add(new JLabel("Name:")); fieldsPanel.add(nameField); nameField.setEnabled(false); segmentIdChoice = new JComboBox(); segmentIdChoice.setEditable(false); setPreferredWidthOf(segmentIdChoice, 200); fieldsPanel.add(new JLabel("Temporary data segment:")); fieldsPanel.add(segmentIdChoice); return fieldsPanel; }
public AutoFilterCombo(final String[] data, boolean editable) { // set data in combo to be a copy of the data input. This is required due to behaviour of // removeAllItems() // method in JComboBox which results in removal of elements from the data source also. By making // a copy, only // the elements in the copy are removed, not the original source. super(data == null ? new String[] {""} : data.clone()); // make combo editable super.setEditable(editable); UIHelper.setJComboBoxAsHeavyweight(this); // add key listener to the combobox editor to listen for input from user. super.getEditor() .getEditorComponent() .addKeyListener( new KeyAdapter() { public void keyReleased(KeyEvent e) { super.keyPressed(e); // as long as the key pressed isnt up arrow, down arrow, or return, the proceed if ((e.getKeyCode() != 38) && (e.getKeyCode() != 40) && (e.getKeyCode() != 10)) { String entered = getEditor().getItem().toString().toLowerCase(); removeAllItems(); int itemCount = 0; for (String aData : data) { if (aData.toLowerCase().contains(entered)) { addItem(aData); itemCount++; } } getEditor().setItem(entered); JTextField textField = (JTextField) e.getSource(); textField.setCaretPosition(textField.getDocument().getLength()); hidePopup(); if (itemCount != 0 && isDisplayable()) { showPopup(); } } } }); }
public CustomizableComboBox() { super(new BorderLayout()); myThemedCombo.setEditable(true); PopupMouseListener listener = new PopupMouseListener(); // GTK always draws a border on the textbox. It cannot be removed, // so to compensate, we remove our own border so we don't have a double border. if (UIUtil.isUnderGTKLookAndFeel()) { this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); } else { this.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(getBorderColor(), 1))); } // Try to turn off the border on the JTextField. myTextField = new JBTextField() { @Override public void setBorder(Border border) { super.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); } }; myTextField.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); myTextField.addMouseListener(listener); myTextField.addFocusListener( new FocusListener() { @Override public void focusGained(FocusEvent e) { myTextField.selectAll(); } @Override public void focusLost(FocusEvent e) { // no-op } }); JButton popupButton = createArrowButton(); popupButton.addMouseListener(listener); this.add(popupButton, BorderLayout.EAST); this.add(myTextField, BorderLayout.CENTER); }
public void addComponentToPane(Container pane) { // Put the JComboBox in a JPanel to get a nicer look. JPanel birdsPanel = new JPanel(); // use FlowLayout String[] comboBoxItems = store.getBirdsTypeArray(); JComboBox comboBoxBirds = new JComboBox(comboBoxItems); comboBoxBirds.setEditable(false); comboBoxBirds.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { CardLayout cl = (CardLayout) (cards.getLayout()); cl.show(cards, (String) e.getItem()); } }); birdsPanel.add(comboBoxBirds); // cards = new JPanel(new CardLayout()); for (String item : comboBoxItems) { JPanel card = new JPanel(); JLabel label = new JLabel(item); card.add(label); System.out.println( item + "==" + BirdsType.valueOf(item) + "===" + store.getBirdsByTypeList(item).size()); for (Bird bird : store.getBirdsByTypeList(item)) { System.out.println(bird.getName()); JRadioButton rButton = new JRadioButton(bird.getName()); rButton.setActionCommand(bird.getName()); card.add(rButton); } cards.add(card, item); } pane.add(birdsPanel, BorderLayout.PAGE_START); pane.add(cards, BorderLayout.CENTER); }
public FindProf() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Search your campus!"); JLabel patternLabel2 = new JLabel(""); patternList = new JComboBox<Object>(searchNames); patternList.setEditable(true); patternList.setMaximumRowCount(5); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setHorizontalAlignment(SwingConstants.CENTER); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } // constructor
public ChangeListChooser(List<? extends ChangeList> lists) { super(new BorderLayout(4, 2)); myChooser = new JComboBox(); //noinspection unchecked myChooser.setRenderer( new ColoredListCellRendererWrapper<LocalChangeList>() { @Override protected void doCustomize( JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) { if (value != null) { String name = value.getName().trim(); if (name.length() > MAX_LEN) { name = name.substring(0, MAX_LEN - 3) + "..."; } append( name, value.isDefault() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); } } }); myChooser.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { final LocalChangeList changeList = (LocalChangeList) myChooser.getSelectedItem(); setSelectedList(changeList); myChooser.setToolTipText(changeList == null ? "" : (changeList.getName())); } } }); updateLists(lists); myChooser.setEditable(false); add(myChooser, BorderLayout.CENTER); JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label")); label.setLabelFor(myChooser); add(label, BorderLayout.WEST); }
protected void addMyControls() { // add browser-style control buttons JButton home = new JButton(new ImageIcon("data/Home24.gif")); JButton back = new JButton(new ImageIcon("data/Back24.gif")); JButton fwd = new JButton(new ImageIcon("data/Forward24.gif")); home.setToolTipText("Home"); home.addActionListener(this); home.setActionCommand(homeCmd); back.setToolTipText("Back"); back.addActionListener(this); back.setActionCommand(backCmd); back.setEnabled(false); // initially disabled fwd.setToolTipText("Forward"); fwd.addActionListener(this); fwd.setActionCommand(forwardCmd); fwd.setEnabled(false); // initially disabled add(home); add(back); add(fwd); add(new JToolBar.Separator()); // set built-in index variables homeIndex = getComponentIndex(home); backIndex = getComponentIndex(back); forwardIndex = getComponentIndex(fwd); JComboBox comboBox = new JComboBox(); comboBox.setEditable(true); comboBox.addActionListener(this); comboBox.setActionCommand(comboCmd); comboBox.setMaximumRowCount(3); // don't let it get too long comboBox.insertItemAt(mainBrowserURL, 0); // don't start it out empty add(comboBox); comboBoxIndex = getComponentIndex(comboBox); }
/* * The following method creates the combo box with font size choices * postcondition: returns the panel containing the size combo box. */ public JPanel createSizeComboBox() { sizeCombo = new JComboBox(); sizeCombo.addItem(SMALLEST); sizeCombo.addItem(SMALL); sizeCombo.addItem(SMALL_MEDIUM); sizeCombo.addItem(MEDIUM); sizeCombo.addItem(MEDIUM_LARGE); sizeCombo.addItem(LARGE); sizeCombo.addItem(LARGEST); sizeCombo.addItem(HUGE); sizeCombo.addItem(WOW); sizeCombo.setEditable(true); // facenameCombo.addActionListener(this); sizeCombo.setSelectedIndex(2); JPanel panel = new JPanel(); panel.add(sizeCombo); panel.setBorder(new TitledBorder(new EtchedBorder(), "Font Name")); return panel; } // end createComboBox method
/** The constructor */ private ReferenceEditor() { myComboBox.setEditable(true); myComboBox.setRenderer(new BasicComboBoxRenderer()); myComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopCellEditing(); } }); myPanel.add( myComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
public SelectStudentWindow() { setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); studentList = ReportGenerator.staticList; buttonOK.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onOK(); } }); buttonCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }); editButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onEditButtonClick(); } }); deleteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onDeleteButtonClick(); } }); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onAddButtonClick(); } }); studentsComboBox.setEditable(false); setStudentsComboBox(); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); contentPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
public void setFrame() { f = new JFrame("数据通讯参数设置"); // 获取屏幕分辨率的工具集 Toolkit tool = Toolkit.getDefaultToolkit(); // 利用工具集获取屏幕的分辨率 Dimension dim = tool.getScreenSize(); // 获取屏幕分辨率的高度 int height = (int) dim.getHeight(); // 获取屏幕分辨率的宽度 int width = (int) dim.getWidth(); // 设置位置 f.setLocation((width - 300) / 2, (height - 400) / 2); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); f.setContentPane(this); f.setSize(320, 260); f.setResizable(false); lblIP = new JLabel("主机名"); txtIp = new JTextField(20); try { InetAddress addr = InetAddress.getLocalHost(); txtIp.setText(addr.getHostAddress().toString()); } catch (Exception ex) { } lblNo = new JLabel("端口号"); cmbNo = new JComboBox(); cmbNo.setEditable(true); cmbNo.addPopupMenuListener( new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { cmbNo.removeAllItems(); CommPortIdentifier portId = null; Enumeration portList; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); cmbNo.addItem(portId.getName()); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // To change body of implemented methods use File | Settings | File Templates. } @Override public void popupMenuCanceled(PopupMenuEvent e) { // To change body of implemented methods use File | Settings | File Templates. } }); lblName = new JLabel("工程名"); txtProjectName = new JComboBox(); txtProjectName.setEditable(true); txtProjectName.addPopupMenuListener( new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { txtProjectName.removeAllItems(); Mongo m1 = null; try { m1 = new Mongo(txtIp.getText().toString(), 27017); } catch (UnknownHostException ex) { ex.printStackTrace(); } for (String name : m1.getDatabaseNames()) { txtProjectName.addItem(name); } m1.close(); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // To change body of implemented methods use File | Settings | File Templates. } @Override public void popupMenuCanceled(PopupMenuEvent e) { // To change body of implemented methods use File | Settings | File Templates. } }); lblBote = new JLabel("波特率"); cmbBote = new JComboBox(); cmbBote.addItem(9600); cmbBote.addItem(19200); cmbBote.addItem(57600); cmbBote.addItem(115200); lblLength = new JLabel("数据长度"); cmbLength = new JComboBox(); cmbLength.addItem(8); cmbLength.addItem(7); lblParity = new JLabel("校验"); cmbParity = new JComboBox(); cmbParity.addItem("None"); cmbParity.addItem("Odd"); cmbParity.addItem("Even"); lblStopBit = new JLabel("停止位"); cmbStopBit = new JComboBox(); cmbStopBit.addItem(1); cmbStopBit.addItem(2); lblDelay = new JLabel("刷新"); txtDelay = new JTextField(20); btnOk = new JButton("确定"); btnOk.addActionListener( new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { paramIp = txtIp.getText().toString(); paramName = txtProjectName.getSelectedItem().toString(); paramNo = cmbNo.getSelectedItem().toString(); paramBote = Integer.parseInt(cmbBote.getSelectedItem().toString()); parmLength = Integer.parseInt(cmbLength.getSelectedItem().toString()); parmParity = cmbParity.getSelectedIndex(); parmStopBit = Integer.parseInt(cmbStopBit.getSelectedItem().toString()); parmDelay = Integer.parseInt(txtDelay.getText().toString()); if (!paramName.equals("") && !paramNo.equals("")) { receiveData( paramIp, paramName, paramNo, paramBote, parmLength, parmParity, parmStopBit, parmDelay); } else { } } }); btnCancel = new JButton("取消"); btnCancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); JPanel p1 = new JPanel(); p1.setLayout(new GridLayout(9, 2)); p1.add(lblIP); p1.add(txtIp); p1.add(lblNo); p1.add(cmbNo); p1.add(lblName); p1.add(txtProjectName); p1.add(lblBote); p1.add(cmbBote); p1.add(lblLength); p1.add(cmbLength); p1.add(lblParity); p1.add(cmbParity); p1.add(lblStopBit); p1.add(cmbStopBit); p1.add(lblDelay); p1.add(txtDelay); txtDelay.setText("500"); p1.add(btnOk); p1.add(btnCancel); p1.validate(); f.add(p1); f.validate(); }
/** * Create a choicebox for link line style options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the link style options. */ private JPanel createLinkDashedChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLinkDashed = new JComboBox(); cbLinkDashed.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$ cbLinkDashed.setOpaque(true); cbLinkDashed.setEditable(false); cbLinkDashed.setEnabled(false); cbLinkDashed.setMaximumRowCount(10); cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$ cbLinkDashed.validate(); cbLinkDashed.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLinkDashed.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateLinkDashed(cbLinkDashed.getSelectedIndex()); } }; cbLinkDashed.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLinkDashed, BorderLayout.CENTER); return drawPanel; }
/** * Create a choicbox for link line thickness options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the line thickness options. */ private JPanel createWeightChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLineWeight = new JComboBox(); cbLineWeight.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$ cbLineWeight.setOpaque(true); cbLineWeight.setEditable(false); cbLineWeight.setEnabled(false); cbLineWeight.setMaximumRowCount(10); cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$ cbLineWeight.validate(); cbLineWeight.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLineWeight.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { int ind = cbLineWeight.getSelectedIndex(); if (ind == 0) onUpdateLinkWeight(1); else if (ind == 1) onUpdateLinkWeight(2); else if (ind == 2) onUpdateLinkWeight(3); else if (ind == 3) onUpdateLinkWeight(4); else if (ind == 4) onUpdateLinkWeight(5); else if (ind == 5) onUpdateLinkWeight(6); else if (ind == 6) onUpdateLinkWeight(7); else if (ind == 7) onUpdateLinkWeight(8); else if (ind == 8) onUpdateLinkWeight(9); else if (ind == 9) onUpdateLinkWeight(10); } }; cbLineWeight.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLineWeight, BorderLayout.CENTER); return drawPanel; }