/** * <code>setUpChooser</code> retrieves all available display modes and * places them in a <code>JComboBox</code>. The resolution specified by * GameSettings is used as the default value. * * @return the combo box of display modes. */ private JComboBox setUpResolutionChooser() { JComboBox resolutionBox = new JComboBox(); resolutionBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateDisplayChoices(); } }); return resolutionBox; }
private void initializeComponents (BillboardParticleBatch renderer) { alignCombo = new JComboBox(); alignCombo.setModel(new DefaultComboBoxModel(AlignModeWrapper.values())); alignCombo.setSelectedItem(getAlignModeWrapper(renderer.getAlignMode())); alignCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { AlignModeWrapper align = (AlignModeWrapper)alignCombo.getSelectedItem(); sortCombo = new JComboBox(); sortCombo.setModel(new DefaultComboBoxModel(SortMode.values())); sortCombo.setSelectedItem(getSortMode(renderer.getSorter())); sortCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { SortMode mode = (SortMode)sortCombo.getSelectedItem(); contentPanel.add(new JLabel("Align"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(alignCombo, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Use GPU"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(useGPUBox, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Sort"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(sortCombo, new GridBagConstraints(1, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
private JPanel makeTregexPatternArea() { recentTregexPatterns = new JComboBox<>(recentTregexPatternsModel); recentTregexPatterns.setMinimumSize(new Dimension(120, 24)); recentTregexPatterns.addActionListener(this); JLabel recentLabel = new JLabel("Recent: "); JLabel patternLabel = new JLabel("Pattern: "); tregexPattern = new JTextArea(); tregexPattern.setFocusTraversalKeysEnabled(true); JPanel tregexInput = new JPanel(); tregexInput.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 1; tregexInput.add(patternLabel,c); c.gridx = 1; c.weightx = 12.0;
private final JComboBox combo1 = new JComboBox( new String[]{"Course 1", "Course 2", "Course 3"}); private final JComboBox combo2 = new JComboBox(); private ComboBoxModel[] models = new ComboBoxModel[3]; this.add(combo1); this.add(combo2); combo1.addActionListener(this); JFrame f = new JFrame("ComboTest"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(this); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true);
JPanel jp_form_label = new JPanel(new GridLayout(5, 1, RESTView.BORDER_WIDTH, RESTView.BORDER_WIDTH)); jp_form_label.add(new JLabel("<html>Host: </html>")); jp_form_label.add(new JLabel("<html>Realm: </html>")); jp_form_label.add(new JLabel("<html>Username: <font color=red>*</font></html>")); jp_form_label.add(new JLabel("<html>Password: </html>")); JLabel jl_premptive = new JLabel("Preemptive?"); jp_form_label.add(jl_premptive); JPanel jp_form_input = new JPanel(new GridLayout(5, 1, RESTView.BORDER_WIDTH, RESTView.BORDER_WIDTH)); jp_form_input.add(jtf_host); jp_form_input.add(jtf_realm); jp_form_input.add(jcb_preemptive); JPanel jp_form = new JPanel(new BorderLayout()); jp_form.add(jp_form_label, BorderLayout.WEST); jp_form.add(jp_form_input, BorderLayout.CENTER); jcb_types.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) {
public ComboEditor() { m_panel = new JPanel(new BorderLayout()); m_panel.add(m_cbox, BorderLayout.CENTER); m_cbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { setValue(m_cbox.getSelectedItem()); } }); }
private SettingsGroup makeOtherGroup() { JComboBox<LangLocale> languageCbx = new JComboBox<>(NLS.getI18nLocales()); for (LangLocale locale : NLS.getI18nLocales()) { if (locale.equals(settings.getLangLocale())) { languageCbx.addActionListener(e -> settings.setLangLocale((LangLocale) languageCbx.getSelectedItem()));
protected JToolBar createToolBar() { JToolBar tb = new JToolBar(); tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE); JComboBox fontCombo = new JComboBox(); JComboBox fontSizeCombo = new JComboBox(); _fontSizeCombo = fontSizeCombo; fontCombo.addActionListener( fontSizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { tb.add(new JLabel(" Font: ")); tb.add(fontCombo); tb.add(fontSizeCombo); tb.addSeparator(); tb.addSeparator();
private void addDisplayFormatComponent() { formatLabel = new JLabel(Messages.getString("ToolPanel.disp_format") + StringUtil.COLON); //$NON-NLS-1$ this.add(formatLabel); formatCombo = new JComboBox<>(Format.values()); formatCombo.setFocusable(false); formatCombo.setSelectedItem(view.getCurrentFormat()); formatCombo.addActionListener(e -> view.setFormat((Format) formatCombo.getSelectedItem())); this.add(formatCombo); } }
protected JToolBar createToolBar() { JToolBar tb = new JToolBar(); tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE); JComboBox fontCombo = new JComboBox(); JComboBox fontSizeCombo = new JComboBox(); _fontSizeCombo = fontSizeCombo; fontCombo.addActionListener( fontSizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { tb.add(new JLabel(" Font: ")); tb.add(fontCombo); tb.add(fontSizeCombo);
public StatisticChooser(StackGraphPanel graph) { super(new BorderLayout()); this.graph = graph; statSelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String label = (String)statSelector.getSelectedItem(); statCard.show(statOptions, label); // if user manually selects current displayed type, // keep them in sync if new type is loaded // otherwise leave it on user's selected type // so viewing stats live won't change dropdown while user choosing a stat updateWhenLoaded = label.equals(lastLoadedType); } }); final JPanel statChooserPanel = stackWest(new JLabel("Select statistic for report type "), statSelector, new JLabel(":")); statOptions.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); statOptions.setLayout(statCard); for(String typeName : DataTypeHelper.getTypes()) { statOptions.add(DataTypeHelper.forType(typeName).getOptionEditor(), typeName); } stackIn(this, BorderLayout.NORTH, statChooserPanel, statOptions, flow(close)); }
public DateFormatView() { super("DateFormat", "Date format", "Format of the date"); p = new JPanel(); p.setLayout(new MigLayout()); combobox = new JComboBox(new String[]{ "HH:mm:ss", // "HH:mm:ss.SSS",// "dd-MM HH:mm:ss.SSS",// "E HH:mm:ss", // "E HH:mm:ss.SS", // "MMM dd, HH:mm:ss",// }); addLabel("Date format", 'd', combobox); final JTextField exampleTextField = new JTextField(20); exampleTextField.setEditable(false); addLabel("Format example", 'e', exampleTextField); combobox.addActionListener(e -> exampleTextField.setText(new SimpleDateFormat((String) combobox.getSelectedItem()).format(new Date()))); }
private void buildLanguageOptions(Container container, OPTION[] options,ActionListener languageChangeListener) { listLanguages = new JComboBox(options); listLanguages.setName(CMB_LANGUAGE); listLanguages.addActionListener(languageChangeListener); container.add(listLanguages,BorderLayout.NORTH); }
expirationComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); toolBar.add(pauseLabel); toolBar.add(Box.createHorizontalGlue()); toolBar.add(new JLabel("Clear after:")); toolBar.add(expirationComboBox);
private JPanel makeSettingsPanel(JButton browseButton, JButton goButton, JButton cxButton) { JPanel settingsPanel = new JPanel(); GridBagHelper helper = new GridBagHelper(settingsPanel, new double[] { 0.2, 0.7, 0.1, 0.1 }); helper.addLabel("Root source directory:"); languageBox.addItem(String.valueOf(LANGUAGE_SETS[i][0])); languageBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
reloadFileButton.setText("Reload File"); final JComboBox<ParseMode> modesCombobox = new JComboBox<>(ParseMode.values()); modesCombobox.setSelectedIndex(0); modesCombobox.addActionListener(event -> { model.setParseMode((ParseMode) modesCombobox.getSelectedItem()); reloadAction.actionPerformed(null); }); final JLabel modesLabel = new JLabel("Modes:", SwingConstants.RIGHT); final int leftIndentation = 10; modesLabel.setBorder(BorderFactory.createEmptyBorder(0, leftIndentation, 0, 0)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(1, 2)); buttonPanel.add(openFileButton); buttonPanel.add(reloadFileButton); final JPanel modesPanel = new JPanel(); modesPanel.add(modesLabel); modesPanel.add(modesCombobox); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(buttonPanel); mainPanel.add(modesPanel, BorderLayout.LINE_END);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JPanel gui = new JPanel(new BorderLayout(5,5)); gui.setBorder( new TitledBorder("BorderLayout(5,5)") ); JPanel plafComponents = new JPanel( new FlowLayout(FlowLayout.RIGHT, 3,3)); plafComponents.setBorder( plafNames[ii] = plafInfos[ii].getName(); final JComboBox plafChooser = new JComboBox(plafNames); plafComponents.add(plafChooser); plafComponents.add(pack); plafChooser.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent ae) { int index = plafChooser.getSelectedIndex(); gui.add(plafComponents, BorderLayout.NORTH); labels.add( new JLabel("Label " + ++labelCount) ); frame.validate(); frame.setVisible(true);
private void initializeComponents (BillboardParticleBatch renderer) { alignCombo = new JComboBox(); alignCombo.setModel(new DefaultComboBoxModel(AlignModeWrapper.values())); alignCombo.setSelectedItem(getAlignModeWrapper(renderer.getAlignMode())); alignCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { AlignModeWrapper align = (AlignModeWrapper)alignCombo.getSelectedItem(); sortCombo = new JComboBox(); sortCombo.setModel(new DefaultComboBoxModel(SortMode.values())); sortCombo.setSelectedItem(getSortMode(renderer.getSorter())); sortCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { SortMode mode = (SortMode)sortCombo.getSelectedItem(); contentPanel.add(new JLabel("Align"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(alignCombo, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Use GPU"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(useGPUBox, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Sort"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(sortCombo, new GridBagConstraints(1, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
public MarkNoteFilter() { super(NAME, DESCRIPTION); noteComboBox.setBorder(BorderFactory.createTitledBorder("With note:")); noteComboBox.addActionListener(e -> listener.ifPresent(LogFilterValueChangeListener::valueChanged)); markComboBox.setBorder(BorderFactory.createTitledBorder("Marked:")); markComboBox.addActionListener(e -> listener.ifPresent(LogFilterValueChangeListener::valueChanged)); gui = new JPanel(new GridLayout(2, 1)); gui.add(noteComboBox); gui.add(markComboBox); }
private JComboBox<String> createInsertComboBox(final String title, final String[] patterns) { ArrayList<String> itemList = new ArrayList<>(); itemList.add(title); itemList.addAll(Arrays.asList(patterns)); final JComboBox<String> comboBox = new JComboBox<>(itemList.toArray(new String[itemList.size()])); comboBox.setFont(insertCompFont); comboBox.setEditable(false); comboBox.setForeground(insertCompColor); comboBox.addActionListener(e -> { if (comboBox.getSelectedIndex() != 0) { insertCodePattern((String) comboBox.getSelectedItem()); comboBox.setSelectedIndex(0); } }); return comboBox; }