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:de.fhg.iais.asc.ui.parts.TransformersPanel.java
private JPanel createSelectSipMakerBoxes() { TopLabeledElementJPanelBuilder builder = new TopLabeledElementJPanelBuilder("Transform"); this.sourceMetadataComboBox = new JComboBox(this.sipMakerFactory.getMDFormats()); builder.add("Metadata_format", this.sourceMetadataComboBox); this.domainComboBox = new JComboBox(); builder.add("Domain", this.domainComboBox); this.providermappingComboBox = new JComboBox(); builder.add("Provider_Mapping", this.providermappingComboBox); this.collectionmappingComboBox = new JComboBox(); builder.add("Collection_Mapping", this.collectionmappingComboBox); this.versionComboBox = new JComboBox(); builder.add("Version", this.versionComboBox); retrieveVersionsAndSetMaxVersion();//from w w w . j av a 2 s . co m // The Listeners listen for changes in the selections of the comboboxes this.sourceMetadataComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { retrieveDomains(); retrieveVersionsAndSetMaxVersion(); } }); this.domainComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { retrieveProviders(); retrieveVersionsAndSetMaxVersion(); } }); this.providermappingComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { retrieveCollections(); retrieveVersionsAndSetMaxVersion(); } }); this.collectionmappingComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { retrieveVersionsAndSetMaxVersion(); } }); return builder.getResult(); }
From source file:FocusEventDemo.java
public FocusEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; //Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField);//w w w. j av a2 s . c om c.weightx = 0.1; //Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector vector = new Vector(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector listVector = new Vector(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); //It's easier to see the focus change //if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); //We want to prevent the list's scroll bars //from getting the focus - even with the keyboard. //Note that in general we prefer setRequestFocusable //over setFocusable for reasons of accessibility, //but this is to work around bug #4866958. listScrollPane.getVerticalScrollBar().setFocusable(false); listScrollPane.getHorizontalScrollBar().setFocusable(false); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; //Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; //Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); //The method setRequestFocusEnabled prevents a //component from being clickable, but it can still //get the focus through the keyboard - this ensures //user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); //Work around for bug #4866958. displayScrollPane.getHorizontalScrollBar().setFocusable(false); displayScrollPane.getVerticalScrollBar().setFocusable(false); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:electroStaticUI.UserInput.java
public UserInput() { charges = new JLabel("How Many Charges"); getNumberOfCharges = new JTextField(5); enter = new JButton("Enter"); circleRectangle = new JButton("Circle/Rectangle"); calculator = new JButton("Calculator"); graphIt = new JButton("Graph It!"); lengthModLabel = new JLabel("Meters"); lengthModCombo = new JComboBox<String>(lengthModList); add(lengthModCombo);/*w w w . j a va 2 s. c o m*/ add(lengthModLabel); add(charges); add(getNumberOfCharges); add(enter); //add(circleRectangle); add(calculator); add(graphIt); getNumberOfCharges.setEditable(true); graphIt.setVisible(false); //set lengthModCombo default lengthModCombo.setSelectedIndex(0); //set some tool tips circleRectTT = "Plot points in rectangle or circle."; circleRectangle.setToolTipText(circleRectTT); calculatorTT = "Open calculator"; calculator.setToolTipText(calculatorTT); //add event listeners to teh buttonz enter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultValues.setLengthModIndex(lengthModCombo.getSelectedIndex()); getChargeData(); } }); circleRectangle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (DefaultValues.getCircOrRect() == 'c') DefaultValues.setCircOrRect('r'); else if (DefaultValues.getCircOrRect() == 'r') DefaultValues.setCircOrRect('c'); } }); calculator.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { calculatorFrame = new JFrame(); calculatorFrame.setTitle("Calculator"); //set some defaults calculatorFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); calculatorFrame.setPreferredSize(new Dimension(400, 200)); calculatorFrame.add(theCalculator); calculatorFrame.pack(); calculatorFrame.setVisible(true); } }); setPreferredSize(new Dimension(400, 50)); }
From source file:com.eviware.soapui.impl.rest.panels.request.RestRequestDesktopPanel.java
private JPanel addMethodCombo() { JPanel methodPanel = new JPanel(new BorderLayout()); JComboBox methodComboBox = new JComboBox(new RestRequestMethodModel(getRequest())); methodComboBox.setSelectedItem(getRequest().getMethod()); JLabel methodLabel = new JLabel("Method"); methodPanel.add(methodLabel, BorderLayout.NORTH); methodPanel.add(methodComboBox, BorderLayout.SOUTH); methodPanel.setMinimumSize(new Dimension(75, STANDARD_TOOLBAR_HEIGHT)); methodPanel.setMaximumSize(new Dimension(75, STANDARD_TOOLBAR_HEIGHT + 10)); return methodPanel; }
From source file:net.pandoragames.far.ui.swing.FindFilePanel.java
public FindFilePanel(SwingConfig config, ComponentRepository componentRepository) { localizer = config.getLocalizer();//from w w w .j a va 2 s. co m dataModel = componentRepository.getFindForm(); dataModel.addFormUpdateListener(this); baseDirPathTextField = new JComboBox(new NoDuplicatesComboBoxModel()); // baseWindow = componentRepository.getRootWindow(); init(config, componentRepository); }
From source file:com.floreantpos.config.ui.DatabaseConfigurationDialog.java
protected void initUI() { getContentPane().setLayout(new MigLayout("fill", "[][fill, grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ titlePanel = new TitlePanel(); tfServerAddress = new POSTextField(); tfServerPort = new POSTextField(); tfDatabaseName = new POSTextField(); tfUserName = new POSTextField(); tfPassword = new POSPasswordField(); databaseCombo = new JComboBox(Database.values()); String databaseProviderName = AppConfig.getDatabaseProviderName(); if (StringUtils.isNotEmpty(databaseProviderName)) { databaseCombo.setSelectedItem(Database.getByProviderName(databaseProviderName)); }/*from w w w. j a v a 2 s . com*/ getContentPane().add(titlePanel, "span, grow, wrap"); //$NON-NLS-1$ getContentPane().add(new JLabel(Messages.getString("DatabaseConfigurationDialog.8"))); //$NON-NLS-1$ getContentPane().add(databaseCombo, "grow, wrap"); //$NON-NLS-1$ lblServerAddress = new JLabel(Messages.getString("DatabaseConfigurationDialog.10") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblServerAddress); getContentPane().add(tfServerAddress, "grow, wrap"); //$NON-NLS-1$ lblServerPort = new JLabel(Messages.getString("DatabaseConfigurationDialog.13") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblServerPort); getContentPane().add(tfServerPort, "grow, wrap"); //$NON-NLS-1$ lblDbName = new JLabel(Messages.getString("DatabaseConfigurationDialog.16") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblDbName); getContentPane().add(tfDatabaseName, "grow, wrap"); //$NON-NLS-1$ lblUserName = new JLabel(Messages.getString("DatabaseConfigurationDialog.19") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblUserName); getContentPane().add(tfUserName, "grow, wrap"); //$NON-NLS-1$ lblDbPassword = new JLabel(Messages.getString("DatabaseConfigurationDialog.22") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ getContentPane().add(lblDbPassword); getContentPane().add(tfPassword, "grow, wrap"); //$NON-NLS-1$ getContentPane().add(new JSeparator(), "span, grow, gaptop 10"); //$NON-NLS-1$ btnTestConnection = new PosButton(Messages.getString("DatabaseConfigurationDialog.26").toUpperCase()); //$NON-NLS-1$ btnTestConnection.setActionCommand(TEST); btnSave = new PosButton(Messages.getString("DatabaseConfigurationDialog.27").toUpperCase()); //$NON-NLS-1$ btnSave.setActionCommand(SAVE); btnExit = new PosButton(Messages.getString("DatabaseConfigurationDialog.28").toUpperCase()); //$NON-NLS-1$ btnExit.setActionCommand(CANCEL); JPanel buttonPanel = new JPanel(new MigLayout("inset 0, fill", "grow", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ btnCreateDb = new PosButton(Messages.getString("DatabaseConfigurationDialog.29").toUpperCase()); //$NON-NLS-1$ btnCreateDb.setActionCommand(CREATE_DATABASE); btnUpdateDb = new PosButton(Messages.getString("UPDATE_DATABASE").toUpperCase()); //$NON-NLS-1$ btnUpdateDb.setActionCommand(UPDATE_DATABASE); buttonPanel.add(btnUpdateDb); buttonPanel.add(btnCreateDb); buttonPanel.add(btnTestConnection); buttonPanel.add(btnSave); buttonPanel.add(btnExit); getContentPane().add(buttonPanel, "span, grow"); //$NON-NLS-1$ }
From source file:sanger.team16.gui.genevar.eqtl.snp.CisEQTLSNPPane.java
public void setSubmitSNPPanel(SelectedIndex selectedIndex) { BaseJPane panel = new BaseJPane("Query SNPs"); // ------------------ Panel p0 (start) ------------------ // BaseJPane p0 = new BaseJPane(); p0.add(new JLabel("1. Select a study: ")); cbStudy = new JComboBox(this.ui.getStudies("E")); cbStudy.setSelectedIndex(selectedIndex.studyIndex); cbStudy.addActionListener(this); p0.add(cbStudy);//w ww.ja v a 2s . c om p0.add(new JLabel(" ")); p0.setBaseSpringBoxTrailing(); panel.add(p0); // ------------------ Panel p0 (end) ------------------ // panel.add(new JLabel("")); // ------------------ Panel p1 (start) ------------------ // BaseJPane p1 = new BaseJPane(); p1.add(new JLabel("2. Choose a reference: ")); this.study = (Study) cbStudy.getSelectedItem(); cbReference = new JComboBox( this.ui.getReferences(study.getGenotypeAssemblyId(), study.getExpressionPlatformId())); cbReference.setSelectedIndex(selectedIndex.referencesIndex); cbReference.addActionListener(this); p1.add(cbReference); p1.add(new JLabel(" ")); p1.setBaseSpringBoxTrailing(); panel.add(p1); // ------------------ Panel p1 (end) ------------------ // panel.add(new JLabel("")); /* ----------------- Panel p3 (start) ----------------- */ BaseJPane p3 = new BaseJPane(); p3.add(new JLabel("3. Enter rs ID(s): ")); taSNP = new JTextArea(selectedIndex.textArea1, 6, 1); p3.add(new JScrollPane(taSNP)); p3.add(new JLabel(" ")); p3.setBaseSpringBoxTrailing(); panel.add(p3); /* ----------------- Panel p3 (end) ----------------- */ // /* ----------------- Panel p4 (start) ----------------- */ BaseJPane p4 = new BaseJPane(); p4.add(new JLabel(" or read from a text file with list of SNPs: ")); tfSNPFile = new BaseJTextField(5, true, true); tfSNPFile.setText(""); p4.add(tfSNPFile); bSNPFile = new JButton("Browse..."); bSNPFile.addActionListener(this); p4.add(bSNPFile); p4.add(new JLabel(" ")); p4.setBaseSpringBoxTrailing(); panel.add(p4); /* ----------------- Panel p4 (end) ----------------- */ panel.add(new JLabel("")); panel.add(new JLabel("")); panel.add(this.setMatchedFeaturePanel()); panel.setBaseSpringGrid(1); this.add(panel); }
From source file:sanger.team16.gui.genevar.mqtl.snp.CisMQTLSNPPane.java
public void setSubmitSNPPanel(SelectedIndex selectedIndex) { BaseJPane panel = new BaseJPane("Query SNPs"); // ------------------ Panel p0 (start) ------------------ // BaseJPane p0 = new BaseJPane(); p0.add(new JLabel("1. Select a study: ")); cbStudy = new JComboBox(this.ui.getStudies("M")); cbStudy.setSelectedIndex(selectedIndex.studyIndex); cbStudy.addActionListener(this); p0.add(cbStudy);/*from w ww. j av a2 s. c o m*/ p0.add(new JLabel(" ")); p0.setBaseSpringBoxTrailing(); panel.add(p0); // ------------------ Panel p0 (end) ------------------ // panel.add(new JLabel("")); // ------------------ Panel p1 (start) ------------------ // BaseJPane p1 = new BaseJPane(); p1.add(new JLabel("2. Choose a reference: ")); this.study = (Study) cbStudy.getSelectedItem(); cbReference = new JComboBox( this.ui.getReferences(study.getGenotypeAssemblyId(), study.getMethylationPlatformId())); cbReference.setSelectedIndex(selectedIndex.referencesIndex); cbReference.addActionListener(this); p1.add(cbReference); p1.add(new JLabel(" ")); p1.setBaseSpringBoxTrailing(); panel.add(p1); // ------------------ Panel p1 (end) ------------------ // panel.add(new JLabel("")); /* ----------------- Panel p3 (start) ----------------- */ BaseJPane p3 = new BaseJPane(); p3.add(new JLabel("3. Enter rs ID(s): ")); taSNP = new JTextArea(selectedIndex.textArea1, 6, 1); p3.add(new JScrollPane(taSNP)); p3.add(new JLabel(" ")); p3.setBaseSpringBoxTrailing(); panel.add(p3); /* ----------------- Panel p3 (end) ----------------- */ // /* ----------------- Panel p4 (start) ----------------- */ BaseJPane p4 = new BaseJPane(); p4.add(new JLabel(" or read from a text file with list of SNPs: ")); tfSNPFile = new BaseJTextField(5, true, true); tfSNPFile.setText(""); p4.add(tfSNPFile); bSNPFile = new JButton("Browse..."); bSNPFile.addActionListener(this); p4.add(bSNPFile); p4.add(new JLabel(" ")); p4.setBaseSpringBoxTrailing(); panel.add(p4); /* ----------------- Panel p4 (end) ----------------- */ panel.add(new JLabel("")); panel.add(new JLabel("")); panel.add(this.setMatchedFeaturePanel()); panel.setBaseSpringGrid(1); this.add(panel); }
From source file:edu.gmu.cs.sim.util.media.chart.HistogramGenerator.java
public HistogramGenerator() { // buildChart is called by super() first LabelledList list = new LabelledList("Show Histogram..."); DisclosurePanel pan1 = new DisclosurePanel("Show Histogram...", list); final HistogramType[] styles = new HistogramType[] { HistogramType.FREQUENCY, HistogramType.RELATIVE_FREQUENCY, HistogramType.SCALE_AREA_TO_1 }; final JComboBox style = new JComboBox( new String[] { "By Frequency", "By Relative Frequency", "With Area = 1.0" }); style.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { histogramType = styles[style.getSelectedIndex()]; HistogramDataset dataset = (HistogramDataset) (getSeriesDataset()); dataset.setType(histogramType); }/* ww w.jav a 2 s . co m*/ }); list.add(style); addGlobalAttribute(pan1); }
From source file:com.game.ui.views.ItemPanel.java
public void doCommonStuffForDropDown(DefaultComboBoxModel model) { comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1);//from w w w. j a v a 2s . c om comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(Box.createVerticalStrut(10)); add(comboBox); add(Box.createVerticalStrut(10)); }