List of usage examples for javax.swing JComboBox JComboBox
public JComboBox(Vector<E> items)
JComboBox
that contains the elements in the specified Vector. From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java
private void init() { segmentWindowField = new JTextField(); SegmentWindowDocument segDoc = new SegmentWindowDocument(); segmentWindowField.setDocument(segDoc); segmentWindowField.setText(DEFAULT_SEGMENT_WINDOW + ""); segDoc.addDocumentListener(new SegmentWindowListener()); segmentLabel = new SegmentLabel(); segmentLabel.setSegmentWindow(DEFAULT_SEGMENT_WINDOW); segmentLabel.setCurrentTime(0L);//from w w w . j av a 2 s.c o m segmentLabel.lockSegmentStartTime(-1L); modeBox = new JComboBox(SegmentationMode.values()); modeBox.setSelectedItem(SegmentationMode.INSERT_AFTER_CURRENT); JPanel topPanel = new JPanel(); FormLayout topLayout = new FormLayout("right:pref, 3dlu, fill:default:grow, pref", "pref, pref, pref, pref"); topPanel.setLayout(topLayout); CellConstraints cc = new CellConstraints(); topPanel.add(new JLabel("Segment Window"), cc.xy(1, 1)); topPanel.add(segmentWindowField, cc.xy(3, 1)); topPanel.add(new JLabel("ms"), cc.xy(4, 1)); JLabel infoLabel = new JLabel("Set to 0 for unlimited segment time"); infoLabel.setFont(infoLabel.getFont().deriveFont(10.0f)); topPanel.add(infoLabel, cc.xy(3, 2)); topPanel.add(new JLabel("Current Window"), cc.xy(1, 3)); topPanel.add(segmentLabel, cc.xy(3, 3)); topPanel.add(new JLabel("Mode"), cc.xy(1, 4)); topPanel.add(modeBox, cc.xyw(3, 4, 2)); setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); participantPanel = new JPanel(); participantPanel.setBackground(Color.white); participantPanel.setOpaque(true); JScrollPane participantScroller = new JScrollPane(participantPanel); Dimension prefSize = participantScroller.getPreferredSize(); prefSize.height = 150; participantScroller.setPreferredSize(prefSize); Dimension maxSize = participantScroller.getMaximumSize(); maxSize.height = 200; participantScroller.setMaximumSize(maxSize); Dimension minSize = participantScroller.getMinimumSize(); minSize.height = 100; participantScroller.setMinimumSize(minSize); participantScroller.setBorder(BorderFactory.createTitledBorder("Participants")); add(participantScroller, BorderLayout.CENTER); updateParticipantPanel(); setupEditorActions(); }
From source file:biomine.bmvis2.pipeline.BestPathHiderOperation.java
public JComponent getSettingsComponent(final SettingsChangeCallback settingsChangeCallback, final VisualGraph graph) { long nodeCount = graph.getAllNodes().size(); if (oldCount != 0) { long newTarget = (target * nodeCount) / oldCount; this.target = Math.max(newTarget, target); } else/*from w w w . j a v a 2 s . c o m*/ this.target = nodeCount; this.oldCount = nodeCount; JPanel ret = new JPanel(); // if int overflows, we're fucked final JSlider sl = new JSlider(0, (int) nodeCount, (int) Math.min(target, nodeCount)); sl.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (target == sl.getValue()) return; target = sl.getValue(); settingsChangeCallback.settingsChanged(false); } }); ret.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; //c.gridwidth=2; ret.add(sl, c); c.gridy++; int choices = graph.getNodesOfInterest().size() + 1; Object[] items = new Object[choices]; items[0] = "All PoIs"; for (int i = 1; i < choices; i++) { items[i] = i + " nearest"; } final JComboBox pathTypeBox = new JComboBox(items); pathTypeBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int i = pathTypeBox.getSelectedIndex(); grader.setPathK(i); settingsChangeCallback.settingsChanged(false); } }); ret.add(new JLabel("hide by best path quality to:"), c); c.gridy++; ret.add(pathTypeBox, c); c.gridy++; System.out.println("new confpane nodeCount = " + nodeCount); final JCheckBox useMatchingColoring = new JCheckBox(); ret.add(useMatchingColoring, c); useMatchingColoring.setAction(new AbstractAction("Use matching coloring") { public void actionPerformed(ActionEvent arg0) { matchColoring = useMatchingColoring.isSelected(); settingsChangeCallback.settingsChanged(false); } }); useMatchingColoring.setAlignmentX(JComponent.CENTER_ALIGNMENT); c.gridy++; final JCheckBox labelsBox = new JCheckBox(); ret.add(labelsBox, c); labelsBox.setAction(new AbstractAction("Show goodness in node labels") { public void actionPerformed(ActionEvent arg0) { showLabel = labelsBox.isSelected(); settingsChangeCallback.settingsChanged(false); } }); return ret; }
From source file:com.jhash.oimadmin.ui.UIJavaCompile.java
@Override public void initializeComponent() { logger.debug("Initializing {}", this); this.outputDirectory = configuration.getWorkArea() + Config.VAL_WORK_AREA_CLASSES + File.separator + System.currentTimeMillis(); logger.debug("Compile output directory {}", outputDirectory); File templateDirectory = new File(configuration.getWorkArea() + File.separator + Config.VAL_WORK_AREA_CONF + File.separator + "templates"); logger.debug("Trying to validate template directory {} exists and is directory", templateDirectory); if (templateDirectory.exists() && templateDirectory.isDirectory()) { logger.debug("Trying to list files in directory"); String[] listOfFile = templateDirectory.list(new FilenameFilter() { @Override/*from w w w.j a va 2s.c om*/ public boolean accept(File dir, String name) { logger.trace("Validating file {}", name); if (name.startsWith(templatePrefix)) { logger.trace("File {} begins with prefix", name); return true; } return false; } }); java.util.List<String> fixedListOfFile = new ArrayList<>(); logger.debug("Extract class name and display name from file names {}", listOfFile); for (String fileName : listOfFile) { String fileSuffix = fileName.replaceAll(templatePrefix, ""); logger.trace("Adding class {} to list", fileSuffix); fixedListOfFile.add(fileSuffix); } if (fixedListOfFile != null && fixedListOfFile.size() > 0) { logger.debug("Creating combo-box with values {}", fixedListOfFile); sourceCodeSelector = new JComboBox<String>(fixedListOfFile.toArray(new String[0])); sourceCodeSelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.debug("Event {} triggered on combo box {}", e, sourceCodeSelector); String sourceCodeSelected = (String) sourceCodeSelector.getSelectedItem(); if (sourceCodeSelector != null) { logger.debug("Trying to read file for selected source code {}", sourceCodeSelected); String readData = Utils.readFile(templatePrefix + sourceCodeSelected, templateDirectory.getAbsolutePath()); sourceCode.setText(readData); classNameText.setText(sourceCodeSelected); } } }); sourceCodeSelector.setSelectedIndex(0); } } compileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { logger.debug("Triggered action {} on {}", e, compileButton); compile(); logger.debug("Completed action {} on {}", e, compileButton); } catch (Exception exception) { displayMessage("Compilation failed", "Failed to compile", exception); } } }); javaCompileUI = buildCodePanel(); }
From source file:com.googlecode.vfsjfilechooser2.accessories.connection.ConnectionDialog.java
private void initCenterPanelComponents() { // create the panel this.centerPanel = new JPanel(new GridBagLayout()); this.centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); // create the components this.hostnameLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.hostnameLabelText")); this.hostnameLabel.setForeground(Color.RED); this.hostnameTextField = new JTextField(25); this.portLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.portLabelText")); this.portTextField = new JFormattedTextField(NumberFormat.getInstance()); this.isPortTextFieldDirty = false; this.protocolLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.protocolLabelText")); this.protocolModel = new DefaultComboBoxModel(Protocol.values()); this.protocolList = new JComboBox(protocolModel); this.protocolList.setRenderer(new ProtocolRenderer()); this.usernameLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.usernameLabelText")); this.usernameTextField = new JTextField(20); this.passwordLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.passwordLabelText")); this.passwordTextField = new JPasswordField(12); this.defaultRemotePathLabel = new JLabel(VFSResources.getMessage("VFSJFileChooser.pathLabelText")); this.defaultRemotePathTextField = new JTextField(20); // Add the components to the panel makeGridPanel(new Component[] { hostnameLabel, hostnameTextField, portLabel, portTextField, protocolLabel, protocolList, usernameLabel, usernameTextField, passwordLabel, passwordTextField, defaultRemotePathLabel, defaultRemotePathTextField }); }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2SetupDialog.java
/** Creates the interface elements */ @Override//from w ww.j a v a2 s.co m protected void addDialogComponents() { super.addDialogComponents(); comboClustersModel = new DefaultComboBoxModel<>(); PeakList[] peakLists = MZmineCore.getDesktop().getSelectedPeakLists(); // ----------------------------- // Panel with preview UI elements // ----------------------------- // Preview CheckBox chkPreview = new JCheckBox("Show preview"); chkPreview.addActionListener(this); chkPreview.setHorizontalAlignment(SwingConstants.CENTER); chkPreview.setEnabled(peakLists != null && peakLists.length > 0); // Preview panel that will contain ComboBoxes final JPanel panel = new JPanel(new BorderLayout()); panel.add(new JSeparator(), BorderLayout.NORTH); panel.add(chkPreview, BorderLayout.CENTER); panel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); pnlUIElements = new JPanel(new BorderLayout()); pnlUIElements.add(panel, BorderLayout.NORTH); // ComboBox with Clusters cboClusters = new JComboBox<>(comboClustersModel); cboClusters.setFont(COMBO_FONT); cboClusters.addActionListener(this); pnlComboBoxes = GUIUtils.makeTablePanel(1, 2, new JComponent[] { new JLabel("Clusters"), cboClusters }); // -------------------------------------------------------------------- // ----- Panel with plots -------------------------------------- // -------------------------------------------------------------------- pnlPlots = new JPanel(); pnlPlots.setLayout(new BoxLayout(pnlPlots, BoxLayout.Y_AXIS)); // Plot with retention-time clusters retTimeMZPlot = new SimpleScatterPlot("Retention time", "m/z"); retTimeMZPlot.setMinimumSize(MIN_DIMENSIONS); final JPanel pnlPlotRetTimeClusters = new JPanel(new BorderLayout()); pnlPlotRetTimeClusters.setBackground(Color.white); pnlPlotRetTimeClusters.add(retTimeMZPlot, BorderLayout.CENTER); GUIUtils.addMarginAndBorder(pnlPlotRetTimeClusters, 10); // Plot with chromatograms retTimeIntensityPlot = new EICPlot(); retTimeIntensityPlot.setMinimumSize(MIN_DIMENSIONS); JPanel pnlPlotShapeClusters = new JPanel(new BorderLayout()); pnlPlotShapeClusters.setBackground(Color.white); pnlPlotShapeClusters.add(retTimeIntensityPlot, BorderLayout.CENTER); GUIUtils.addMarginAndBorder(pnlPlotShapeClusters, 10); pnlPlots.add(pnlPlotRetTimeClusters); pnlPlots.add(pnlPlotShapeClusters); super.mainPanel.add(pnlUIElements, 0, super.getNumberOfParameters() + 3, 2, 1, 0, 0, GridBagConstraints.HORIZONTAL); }
From source file:com.willwinder.ugp.tools.GcodeTilerTopComponent.java
public GcodeTilerTopComponent() { setName(GcodeTilerTitle);//from w w w . j av a 2s . c o m setToolTipText(GcodeTilerTooltip); backend = CentralLookup.getDefault().lookup(BackendAPI.class); numCopiesX = new SpinnerNumberModel(3, 1, 1000, 1); numCopiesY = new SpinnerNumberModel(3, 1, 1000, 1); padding = new SpinnerNumberModel(5, 0, 1000, 0.1); units = new JComboBox<>(SwingHelpers.getUnitOptions()); // Button callbacks generateGcodeButton.addActionListener(al -> generateGcode()); exportGcodeButton.addActionListener(al -> exportGcode()); // Change listeners numCopiesX.addChangeListener(l -> controlChangeListener()); numCopiesY.addChangeListener(l -> controlChangeListener()); padding.addChangeListener(l -> controlChangeListener()); // Dowel settings setLayout(new MigLayout("fillx, wrap 4")); add(new JLabel(Localization.getString("platform.plugin.dowel-module.x")), "growx"); add(new JSpinner(numCopiesX), "growx"); add(new JLabel(Localization.getString("gcode.setting.units")), "growx"); add(units, "growx"); add(new JLabel(Localization.getString("platform.plugin.dowel-module.y")), "growx"); add(new JSpinner(numCopiesY), "growx"); add(new JLabel(Localization.getString("platform.plugin.gcode-tools.tiler.padding")), "growx"); add(new JSpinner(padding), "growx"); add(generateGcodeButton, "growx, span2"); add(exportGcodeButton, "growx, span2"); }
From source file:org.jfree.chart.demo.XYStepAreaChartDemo.java
/** * Creates a new demo.//from w ww .j av a 2 s . com * * @param title the frame title. */ public XYStepAreaChartDemo(final String title) { super(title); this.xySeries = new XYSeries("Some data"); for (int i = 0; i < TEST_DATA.length; i++) { this.xySeries.add((Integer) TEST_DATA[i][0], (Integer) TEST_DATA[i][1]); } final XYSeriesCollection dataset = new XYSeriesCollection(this.xySeries); final JFreeChart chart = createChart(dataset); this.chartPanel = new ChartPanel(chart); // allow zooming // this.chartPanel.setHorizontalZoom(true); // this.chartPanel.setVerticalZoom(true); // size this.chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // make stroke more striking final Plot plot = this.chartPanel.getChart().getPlot(); plot.setOutlineStroke(new BasicStroke(2)); plot.setOutlinePaint(Color.magenta); // add some components to make options changable final JPanel main = new JPanel(new BorderLayout()); final JPanel optionsPanel = new JPanel(); final String[] options = { ORIENT_VERT, ORIENT_HORIZ }; this.orientationComboBox = new JComboBox(options); this.orientationComboBox.addActionListener(this); optionsPanel.add(this.orientationComboBox); this.outlineCheckBox = new JCheckBox("Outline"); this.outlineCheckBox.addActionListener(this); optionsPanel.add(this.outlineCheckBox); optionsPanel.add(new JLabel("Base")); this.rangeBaseTextField = new JTextField("0", 5); this.rangeBaseTextField.addActionListener(this); optionsPanel.add(this.rangeBaseTextField); this.nullValuesCheckBox = new JCheckBox("NULL values"); this.nullValuesCheckBox.addActionListener(this); optionsPanel.add(this.nullValuesCheckBox); main.add(optionsPanel, BorderLayout.SOUTH); main.add(this.chartPanel); setContentPane(main); }
From source file:com.eviware.soapui.impl.rest.panels.mock.RestMockResponseDesktopPanel.java
private JComboBox createStatusCodeCombo() { ComboBoxModel httpStatusCodeComboBoxModel = new HttpStatusCodeComboBoxModel(); final JComboBox statusCodeCombo = new JComboBox(httpStatusCodeComboBoxModel); statusCodeCombo.setSelectedItem(CompleteHttpStatus.from(getModelItem().getResponseHttpStatus())); statusCodeCombo.setToolTipText("Set desired HTTP status code"); statusCodeCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { getModelItem().setResponseHttpStatus( ((CompleteHttpStatus) statusCodeCombo.getSelectedItem()).getStatusCode()); }/* w ww.j a v a 2 s . c o m*/ }); return statusCodeCombo; }
From source file:components.RootLayeredPaneDemo.java
private JPanel createControlPanel() { onTop = new JCheckBox("Top Position in Layer"); onTop.setSelected(true);/*from ww w. j a v a2 s .co m*/ onTop.setActionCommand(ON_TOP_COMMAND); onTop.addActionListener(this); layerList = new JComboBox(layerStrings); layerList.setSelectedIndex(INITIAL_DUKE_LAYER_INDEX); layerList.setActionCommand(LAYER_COMMAND); layerList.addActionListener(this); JPanel controls = new JPanel(); controls.add(layerList); controls.add(onTop); controls.setBorder(BorderFactory.createTitledBorder("Choose Duke's Layer and Position")); return controls; }
From source file:LayeredPaneDemo.java
private JPanel createControlPanel() { onTop = new JCheckBox("Top Position in Layer"); onTop.setSelected(true);//from w w w . j av a 2s .c o m onTop.setActionCommand(ON_TOP_COMMAND); onTop.addActionListener(this); layerList = new JComboBox(layerStrings); layerList.setSelectedIndex(2); // cyan layer layerList.setActionCommand(LAYER_COMMAND); layerList.addActionListener(this); JPanel controls = new JPanel(); controls.add(layerList); controls.add(onTop); controls.setBorder(BorderFactory.createTitledBorder("Choose Duke's Layer and Position")); return controls; }