JPanel controls = new JPanel(new GridBagLayout()); controls.add(selectButton = new JButton("Select"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); JPanel pickPanel = new JPanel(new GridBagLayout()); pickPanel.add(selectAllButton = new JButton("Pick All"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); pickPanel.add(clearButton = new JButton("Clear Selection"), new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); pickPanel.add(reverseButton = new JButton("Reverse Selection"), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, generationPanel = new JPanel(new GridBagLayout()); generationPanel.add(new JLabel("Rows"), new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); generationPanel.add(rowSlider = new Slider(1, 1, 9999, 1), new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); generationPanel.add(new JLabel("Columns"), new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); generationPanel.add(columnSlider = new Slider(1, 1, 9999, 1), new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); generationPanel.add(generateBox = new JComboBox(new DefaultComboBoxModel(GenerationMode.values())), new GridBagConstraints(0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); generationPanel.add(generateButton = new JButton("Generate"), new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
final JButton openFileButton = new JButton(new FileSelectionAction()); openFileButton.setMnemonic(KeyEvent.VK_S); openFileButton.setText("Open File"); 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);
textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); JPanel controlPane = new JPanel(); controlPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); final JComboBox<Level> cb = new JComboBox<>(LEVEL_ITEMS); cb.setSelectedItem(level); cb.addActionListener(e -> { int i = cb.getSelectedIndex(); level = LEVEL_ITEMS[i]; registerLogListener(); }); JLabel levelLabel = new JLabel(NLS.str("log_viewer.log_level")); levelLabel.setLabelFor(cb); controlPane.add(levelLabel); controlPane.add(cb); JButton close = new JButton(NLS.str("tabs.close")); close.addActionListener(event -> close()); close.setAlignmentX(0.5f); contentPane.add(controlPane, BorderLayout.PAGE_START); contentPane.add(scrollPane, BorderLayout.CENTER); contentPane.add(close, BorderLayout.PAGE_END);
protected JComboBox createLogLevelCombo() { JComboBox result = new JComboBox(); Iterator levels = getLogLevels(); while (levels.hasNext()) { result.addItem(levels.next()); } result.setSelectedItem(_leastSevereDisplayedLogLevel); result.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox) e.getSource(); LogLevel level = (LogLevel) box.getSelectedItem(); setLeastSevereDisplayedLogLevel(level); } }); result.setMaximumSize(result.getPreferredSize()); return result; }
public void showDialog () { int selectedIndex = -1; DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < options.length; i++) { model.addElement(options[i][0]); if (getValue(i).equals(currentValue)) selectedIndex = i; } JComboBox comboBox = new JComboBox(model); comboBox.setSelectedIndex(selectedIndex); if (showValueDialog(comboBox, description)) value = getValue(comboBox.getSelectedIndex()); }
private void installTestKindComboBox() { myTestKindComboBox.removeAllItems(); myTestKindComboBox.setRenderer(getTestKindListCellRendererWrapper()); for (GoTestRunConfiguration.Kind kind : GoTestRunConfiguration.Kind.values()) { myTestKindComboBox.addItem(kind); } myTestKindComboBox.addActionListener(e -> onTestKindChanged()); } }
JPanel fontPanel = new JPanel(); fontFileText = new JTextField(); fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); browseButton = new JButton("..."); browseButton.setMargin(new Insets(0, 0, 0, 0)); sampleNeheButton = new JButton(); glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64), glyphPageWidthCombo.setSelectedIndex(4); glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64), glyphPageHeightCombo.setSelectedIndex(4); glyphPageCombo = new JComboBox(); glyphPageCombo.setModel(glyphPageComboModel);
JPanel ripPanel = new JPanel(new GridBagLayout()); ripPanel.setBorder(emptyBorder); gbc.gridx = 0; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc); gbc.weightx = 1; gbc.weighty = 1; gbc.weightx = 1; statusLabel = new JLabel(rb.getString("inactive")); statusLabel.setHorizontalAlignment(JLabel.CENTER); configThreadsText = new JTextField(Integer.toString(Utils.getConfigInteger("threads.size", 3))); configLogLevelCombobox = new JComboBox<>(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"}); configSelectLangComboBox = new JComboBox<>(supportedLanges); configSelectLangComboBox.setSelectedItem(rb.getLocale().toString()); configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug")); setLogLevel(configLogLevelCombobox.getSelectedItem().toString()); gbc.gridy = 0; pane.add(ripPanel, gbc); gbc.gridy = 1; pane.add(statusPanel, gbc); gbc.gridy = 2; pane.add(progressPanel, gbc);
topPanel.removeAll(); mainPanel.removeAll(); topPanelBackButton.addActionListener(e -> openConfigList()); topPanelBackButton.setToolTipText("Back"); topPanel.add(topPanelBackButton, BorderLayout.WEST); topPanel.add(listItem.createToggleButton(), BorderLayout.EAST); colorPickerBtn = new JButton("Pick a color"); colorPickerBtn = new JButton(ColorUtil.toHexColor(existingColor).toUpperCase()); JComboBox box = new JComboBox(type.getEnumConstants()); box.setPreferredSize(new Dimension(box.getPreferredSize().width, 25)); box.setRenderer(new ComboBoxListRenderer()); box.setForeground(Color.WHITE); box.setFocusable(false); box.setPrototypeDisplayValue("XXXXXXXX"); //sorry but this is the way to keep the size of the combobox in check. try box.setSelectedItem(selectedItem); box.setToolTipText(selectedItem.toString()); box.addItemListener(e -> box.setToolTipText(box.getSelectedItem().toString());
addButton = new JButton("Add Comp"); addButton.addActionListener(new ActionListener() { JPanel panel = new JPanel(new GridBagLayout()); panel.add(addButton); return panel; private JLabel labelWith = new JLabel("With "); private JComboBox typeCombo = new JComboBox(new Object[]{"height", "length", "volume"}); private JComboBox relationCombo = new JComboBox(new Object[]{"above", "below", "between"}); private JTextField lowerField = new JTextField(); private JLabel labelAnd = new JLabel(" and "); private JTextField upperField = new JTextField(); private JButton removeButton = new JButton("remove"); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); relationCombo.addActionListener(new ActionListener() { enableUpper(relationCombo.getSelectedIndex() == 2); typeCombo.setSelectedIndex(Comp.type); relationCombo.setSelectedIndex(Comp.relation); lowerField.setText(Comp.lower); upperField.setText(Comp.upper); return new Comp(typeCombo.getSelectedIndex(), relationCombo.getSelectedIndex(), lowerField.getText(), upperField.getText());
getContentPane().add(splitPane, BorderLayout.CENTER); JPanel propertiesPanel = new JPanel(new GridBagLayout()); rightSplit.add(propertiesPanel, JSplitPane.TOP); propertiesPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(3, 0, 6, 6), BorderFactory .createTitledBorder("Editor Properties"))); propertiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); scroll.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); JPanel influencersPanel = new JPanel(new GridBagLayout()); influencerBox = new JComboBox(new DefaultComboBoxModel()); JButton addInfluencerButton = new JButton("Add"); addInfluencerButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) {
@Override protected void initializeComponents () { super.initializeComponents(); JButton atlasButton = new JButton("Open Atlas"); JButton textureButton = new JButton("Open Texture"); JButton defaultTextureButton = new JButton("Default Texture"); final JCheckBox genMipMaps = new JCheckBox("Generate MipMaps"); final JComboBox minFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values())); final JComboBox magFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values())); minFilterBox.setSelectedItem(editor.getTexture().getMinFilter()); magFilterBox.setSelectedItem(editor.getTexture().getMagFilter()); minFilterBox.addActionListener(filterListener); magFilterBox.addActionListener(filterListener); atlasButton.addActionListener(new ActionListener() { contentPanel.add(new JLabel("Min. Filter"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(minFilterBox, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Mag. Filter"), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(magFilterBox, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE,
final JFrame frame = new JFrame("Nested Layout Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 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(); try { UIManager.setLookAndFeel( gui.add(plafComponents, BorderLayout.NORTH); new TitledBorder("GridLayout(0,2,3,3)") ); JButton addNew = new JButton("Add Another Label"); labels.add( new JLabel("Label " + ++labelCount) ); frame.setContentPane(gui); frame.pack();
GridBagConstraints gbc; JPanel mainPanel = new JPanel(new GridBagLayout()); JButton ok = new JButton(resourceBundle.getString("button.ok")); JButton cancel = new JButton(resourceBundle.getString("button.cancel")); icon = new JLabel(imageFile != null ? new ImageIcon(imageFile) : null); displayResCombo.addKeyListener(aListener); colorDepthCombo = new JComboBox(); colorDepthCombo.addKeyListener(aListener); displayFreqCombo = new JComboBox(); displayFreqCombo.addKeyListener(aListener); antialiasCombo = new JComboBox(); antialiasCombo.addKeyListener(aListener); fullscreenBox = new JCheckBox(resourceBundle.getString("checkbox.fullscreen")); fullscreenBox.setSelected(source.isFullscreen()); mainPanel.add(vsyncBox, gbc); gbc = new GridBagConstraints(); gbc.weightx = 0.5; ok.addActionListener(new ActionListener() { this.getContentPane().add(mainPanel);
final JFrame frame = new JFrame("Text HIGHLIGHT"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder(5, 5, 5, 5), "Highlighter JTextArea")); contentPane.add(scrollPane); JButton remHighButton = new JButton("REMOVE HIGHLIGHT"); remHighButton.addActionListener(new ActionListener() JButton button = new JButton("HIGHLIGHT TEXT"); button.addActionListener(new ActionListener() String colour = (String) cbox.getSelectedItem(); try frame.add(remHighButton, BorderLayout.PAGE_START); frame.add(contentPane, BorderLayout.CENTER); frame.add(button, BorderLayout.PAGE_END); JLabel colourLabel = new JLabel("Select One Colour : "); cbox = new JComboBox(colourNames); panel.add(colourLabel);
JPanel sideButtons = new JPanel(new GridBagLayout()); add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); controllerTypeCombo = new JComboBox(); controllerTypeCombo.setModel(new DefaultComboBoxModel(ControllerType.values())); sideButtons.add(controllerTypeCombo, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); JButton newButton = new JButton("New"); sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); newButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { ControllerType item = (ControllerType)controllerTypeCombo.getSelectedItem(); JButton deleteButton = new JButton("Delete"); sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
protected JToolBar createToolBar() { JToolBar tb = new JToolBar(); tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE); JComboBox fontCombo = new JComboBox(); JComboBox fontSizeCombo = new JComboBox(); _fontSizeCombo = fontSizeCombo; fontCombo.addItem(fonts[j]); fontCombo.setSelectedItem(_fontName); fontCombo.addActionListener( fontSizeCombo.addItem("8"); fontSizeCombo.addItem("9"); fontSizeCombo.addItem("10"); fontSizeCombo.addItem("12"); fontSizeCombo.addItem("14"); fontSizeCombo.addItem("16"); fontSizeCombo.addItem("18"); fontSizeCombo.addItem("24"); fontSizeCombo.setSelectedItem(String.valueOf(_fontSize)); fontSizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fontCombo.setMaximumSize(fontCombo.getPreferredSize()); fontSizeCombo.setMaximumSize( fontSizeCombo.getPreferredSize());
JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(createTrace()); panel.add(createDate()); final JComboBox trace = new JComboBox(); final String[] traceCmds = {"Enable Trace", "Disable Trace"}; trace.setModel(new DefaultComboBoxModel(traceCmds)); trace.addActionListener(new ActionListener() { if (traceCmds[0].equals(trace.getSelectedItem())) { chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); final JComboBox date = new JComboBox(); final String[] dateCmds = {"Horizontal Dates", "Vertical Dates"}; date.setModel(new DefaultComboBoxModel(dateCmds)); date.addActionListener(new ActionListener() { XYPlot plot = (XYPlot) chart.getPlot(); DateAxis domain = (DateAxis) plot.getDomainAxis(); if (dateCmds[0].equals(date.getSelectedItem())) { domain.setVerticalTickLabels(false); } else { final JButton auto = new JButton(new AbstractAction("Auto Zoom") {
private void initializeComponents () { JPanel contentPanel = getContentPanel(); JLabel label = new JLabel("Shape:"); contentPanel.add(label, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0)); shapeCombo = new JComboBox(); shapeCombo.setModel(new DefaultComboBoxModel(SpawnShape.values())); contentPanel.add(shapeCombo, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); edgesLabel = new JLabel("Edges:"); contentPanel.add(edgesLabel, new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 0, 6), 0, 0)); sideLabel = new JLabel("Side:"); contentPanel.add(sideLabel, new GridBagConstraints(4, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 0, 6), 0, 0)); sideCombo = new JComboBox(); sideCombo.setModel(new DefaultComboBoxModel(SpawnEllipseSide.values())); contentPanel.add(sideCombo, new GridBagConstraints(5, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
private static final JPanel cards = new JPanel(new CardLayout()); private static final JComboBox combo = new JComboBox(); private final String name; this.setPreferredSize(new Dimension(320, 240)); this.setBackground(new Color(random.nextInt())); this.add(new JLabel(name)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); for (int i = 1; i < 9; i++) { CardPanel p = new CardPanel("Panel " + String.valueOf(i)); combo.addItem(p); cards.add(p, p.toString()); JPanel control = new JPanel(); combo.addActionListener(new ActionListener() { CardLayout cl = (CardLayout) cards.getLayout(); cl.show(cards, jcb.getSelectedItem().toString()); f.add(cards, BorderLayout.CENTER); f.add(control, BorderLayout.SOUTH); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true);