Java Code Examples for javax.swing.JComboBox

The following are top voted examples for showing how to use javax.swing.JComboBox. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: TableRenderDemo.java   Source Code and License 7 votes vote down vote up
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
    // Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Knitting");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Pool");
    comboBox.addItem("None of the above");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));

    // Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
}
 
Example 2
Project: openjdk-jdk10   File: JComboBoxPopupLocation.java   Source Code and License 7 votes vote down vote up
private static void setup(final Point tmp) {
    comboBox = new JComboBox<>();
    for (int i = 1; i < 7; i++) {
        comboBox.addItem("Long-long-long-long-long text in the item-" + i);
    }
    String property = System.getProperty(PROPERTY_NAME);
    comboBox.putClientProperty(PROPERTY_NAME, Boolean.valueOf(property));
    frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setLayout(new FlowLayout());
    frame.add(comboBox);
    frame.pack();
    frame.setSize(frame.getWidth(), SIZE);
    frame.setVisible(true);
    frame.setLocation(tmp.x, tmp.y);
}
 
Example 3
Project: jmt   File: KMeanScatterPanelChoose.java   Source Code and License 6 votes vote down vote up
public KMeanScatterPanelChoose(WorkloadAnalysisSession m) {
	super(new BorderLayout());
	setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Scatter Clustering"));

	model = (ModelWorkloadAnalysis) m.getDataModel();
	this.session = m;

	varXCombo = new JComboBox(model.getMatrix().getVariableNames());
	varYCombo = new JComboBox(model.getMatrix().getVariableNames());
	varXCombo.setSelectedIndex(0);
	varYCombo.setSelectedIndex(1);

	JButton vis = new JButton(VIS_SCATTER);

	JPanel combos = new JPanel(new GridLayout(1, 2, 5, 0));
	combos.add(varXCombo);
	combos.add(varYCombo);

	add(combos, BorderLayout.NORTH);
	add(vis, BorderLayout.SOUTH);
}
 
Example 4
Project: incubator-netbeans   File: WizardUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Returns path relative to the root of the SFS. May return
 * <code>null</code> for empty String or user's custom non-string items.
 * Also see {@link Util#isValidSFSPath(String)}.
 */
public static String getSFSPath(final JComboBox lpCombo, final String supposedRoot) {
    Object editorItem = lpCombo.getEditor().getItem();
    String path = null;
    if (editorItem instanceof LayerItemPresenter) {
        path = ((LayerItemPresenter) editorItem).getFullPath();
    } else if (editorItem instanceof String) {
        String editorItemS = ((String) editorItem).trim();
        if (editorItemS.length() > 0) {
            path = searchLIPCategoryCombo(lpCombo, editorItemS);
            if (path == null) {
                // entered by user - absolute and relative are supported...
                path = editorItemS.startsWith(supposedRoot) ? editorItemS :
                    supposedRoot + '/' + editorItemS;
            }
        }
    }
    return path;
}
 
Example 5
Project: OrthancAnonymization   File: AnonActionProfileListener.java   Source Code and License 6 votes vote down vote up
public AnonActionProfileListener(JComboBox<Object> anonProfiles, JLabel profileLabel, JRadioButton radioBodyCharac1, 
		JRadioButton radioBodyCharac2, JRadioButton radioDates1, JRadioButton radioDates2, JRadioButton radioBd2, 
		JRadioButton radioBd1, JRadioButton radioPt1, JRadioButton radioPt2,
		JRadioButton radioSc1, JRadioButton radioSc2, JRadioButton radioDesc1, JRadioButton radioDesc2){
	this.profileLabel = profileLabel;
	this.anonProfiles = anonProfiles;
	this.radioBodyCharac1 = radioBodyCharac1;
	this.radioBodyCharac2 = radioBodyCharac2;
	this.radioDates1 = radioDates1;
	this.radioDates2 = radioDates2;
	this.radioBd2 = radioBd2;
	this.radioBd1 = radioBd1;
	this.radioPt1 = radioPt1;
	this.radioPt2 = radioPt2;
	this.radioSc1 = radioSc1;
	this.radioSc2 = radioSc2;
	this.radioDesc1 = radioDesc1;
	this.radioDesc2 = radioDesc2;
}
 
Example 6
Project: incubator-netbeans   File: GUIRegistrationPanel.java   Source Code and License 6 votes vote down vote up
private void createPositionModel(final JComboBox positionsCombo,
        final FileObject[] files,
        final LayerItemPresenter parent) {
    DefaultComboBoxModel newModel = new DefaultComboBoxModel();
    LayerItemPresenter previous = null;
    for (FileObject file : files) {
        if (file.getNameExt().endsWith(LayerUtil.HIDDEN)) {
            continue;
        }
        LayerItemPresenter current = new LayerItemPresenter(
                file,
                parent.getFileObject());
        newModel.addElement(createPosition(previous, current));
        previous = current;
    }
    newModel.addElement(createPosition(previous, null));
    positionsCombo.setModel(newModel);
    checkValidity();
}
 
Example 7
Project: incubator-netbeans   File: SearchPatternControllerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testMatchTypeComboBoxWithUnsupportedTypes() {
    JComboBox cb = new JComboBox();
    SearchPatternController controller =
            ComponentUtils.adjustComboForSearchPattern(cb);
    JComboBox matchTypeCb = new JComboBox(
            new Object[]{MatchType.LITERAL, MatchType.REGEXP});
    controller.bindMatchTypeComboBox(matchTypeCb);
    assertEquals(MatchType.LITERAL, matchTypeCb.getSelectedItem());
    controller.setSearchPattern(SearchPattern.create("test", false, false,
            MatchType.BASIC));
    assertEquals(MatchType.LITERAL,
            controller.getSearchPattern().getMatchType());
    controller.setSearchPattern(SearchPattern.create("test", false, false,
            MatchType.REGEXP));
    assertEquals(MatchType.REGEXP,
            controller.getSearchPattern().getMatchType());
    controller.setSearchPattern(SearchPattern.create("test", false, false,
            MatchType.BASIC));
    assertEquals(MatchType.REGEXP,
            controller.getSearchPattern().getMatchType());
}
 
Example 8
Project: marathonv5   File: RComboBox2Test.java   Source Code and License 6 votes vote down vote up
public void assertContentDuplicates() throws InterruptedException {
    siw(new Runnable() {
        @Override public void run() {
            combo = (JComboBox) ComponentUtils.findComponent(JComboBox.class, frame);
        }
    });
    final RComboBox rCombo = new RComboBox(combo, null, null, new LoggingRecorder());
    final Object[] content = new Object[] { null };
    siw(new Runnable() {
        @Override public void run() {
            content[0] = rCombo.getContent();
        }
    });
    JSONArray a = new JSONArray(content[0]);
    AssertJUnit.assertEquals("[[\"Phillip\",\"Larry\",\"Lisa\",\"James\",\"Larry(1)\"]]", a.toString());
}
 
Example 9
Project: LogisticApp   File: DiretaPanelBuilder.java   Source Code and License 6 votes vote down vote up
private void initializeComboBoxes() throws Exception {

		List<LocalidadeVO> localidades = this.cadastroRota.recuperarLocalidades();

		this.cboxOrigem = new JComboBox<LocalidadeVO>();
		this.startComboBoxValues(this.cboxOrigem, localidades);

		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox.gridx = 3;
		gbc_comboBox.gridy = 3;
		this.panel.add(this.cboxOrigem, gbc_comboBox);

		this.cboxDestino = new JComboBox<LocalidadeVO>();
		this.startComboBoxValues(this.cboxDestino, localidades);

		GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
		gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox_1.gridx = 3;
		gbc_comboBox_1.gridy = 8;
		this.panel.add(this.cboxDestino, gbc_comboBox_1);
	}
 
Example 10
Project: incubator-netbeans   File: HgHookTest.java   Source Code and License 6 votes vote down vote up
private void setRepository(Repository repository, HookPanel panel) throws IllegalArgumentException, IllegalAccessException {
    Field[] fs = panel.qs.getClass().getDeclaredFields();
    for (Field f : fs) {
        if(f.getType() == QuickSearchPanel.class) {
            f.setAccessible(true);
            QuickSearchPanel qsp = (QuickSearchPanel) f.get(panel.qs);
            fs = qsp.getClass().getDeclaredFields();
            for (Field f2 : fs) {
                if(f2.getType() == JComboBox.class) {
                    f2.setAccessible(true);
                    JComboBox cmb = (JComboBox) f2.get(qsp);
                    DefaultComboBoxModel model = new DefaultComboBoxModel(new Repository[] {repository});
                    cmb.setModel(model);
                    cmb.setSelectedItem(repository);
                    return;
                }
            }
        }
    }
}
 
Example 11
Project: AgentWorkbench   File: Distribution.java   Source Code and License 6 votes vote down vote up
/**
 * Checks if is memory selection error. The initial memory should 
 * always be larger than the maximum memory of the JVM.
 * @return true, if is memory selection error
 */
private boolean isMemorySelectionError(JComboBox<String> combo) {
	
	boolean error = false;
	String initialMemory = (String) getJComboBoxJVMMemoryInitial().getSelectedItem();
	String maximumMemory = (String) getJComboBoxJVMMemoryMaximum().getSelectedItem();
	int initMem = Integer.parseInt(initialMemory.replaceAll("[a-zA-Z]", ""));
	int maxiMem = Integer.parseInt(maximumMemory.replaceAll("[a-zA-Z]", ""));
	if(initialMemory.contains("g")){
		initMem = initMem*1024;
	}
	if(maximumMemory.contains("g")){
		maxiMem = maxiMem*1024;
	}
	
	if (initMem>=maxiMem) {
		combo.hidePopup();
		String head = Language.translate("Initialer Arbeitsspeicher >= Maximaler Arbeitsspeicher !");
		String msg = Language.translate("Der maximale Arbeitsspeicher muss größer als der initiale Arbeitsspeicher sein.");
		JOptionPane.showMessageDialog(Application.getMainWindow(), msg, head, JOptionPane.ERROR_MESSAGE);
		error = true;
	}
	return error;
}
 
Example 12
Project: incubator-netbeans   File: ConfigurationsComboModel.java   Source Code and License 6 votes vote down vote up
private void confirm(EventObject fe) {
    JTextField tf = (JTextField) fe.getSource();
    JComboBox combo = (JComboBox) tf.getParent();
    if (combo==null)
        return;
    if (fe instanceof FocusEvent) {
        combo.getEditor().getEditorComponent().removeFocusListener(this);
    } else {
        combo.getEditor().getEditorComponent().removeKeyListener(this);
    }
    Configuration config = configName==null ? 
            ConfigurationsManager.getDefault().duplicate(lastSelected, tf.getText(), tf.getText()):
            ConfigurationsManager.getDefault().create(tf.getText(), tf.getText());
    combo.setSelectedItem(config);
    combo.setEditable(false);
}
 
Example 13
Project: ats-framework   File: SwingElementState.java   Source Code and License 6 votes vote down vote up
/**
 * Check if the element is editable or not
 *
 * @return if the element is editable or not
 */
@PublicAtsApi
public boolean isElementEditable() {

    try {

        Component component = SwingElementLocator.findFixture(element).component();
        if (component instanceof JTextComponent) {
            return ((JTextComponent) component).isEditable();
        } else if (component instanceof JComboBox) {
            return ((JComboBox) component).isEditable();
        } else if (component instanceof JTree) {
            return ((JTree) component).isEditable();
        }
        throw new NotSupportedOperationException("Component of type \"" + component.getClass().getName()
                                                 + "\" doesn't have 'editable' state!");
    } catch (ElementNotFoundException nsee) {
        lastNotFoundException = nsee;
        return false;
    }
}
 
Example 14
Project: GIFKR   File: FontInterpolator.java   Source Code and License 6 votes vote down vote up
public FontInterpolator(Font selectedFont, GetSet gs, ChangeListener... listeners) {
	super(gs, listeners);
	
	Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
	String[] fontNames = new String[fonts.length];
	for(int i = 0; i < fonts.length; i++)
		fontNames[i] = fonts[i].getFontName();
	
	box = new JComboBox<String>(fontNames) {

		private static final long serialVersionUID = 2454221612986775298L;

		@Override 
		public Dimension getPreferredSize() {
			Dimension ps = super.getPreferredSize();
			return new Dimension(Math.min(ps.width, 120), ps.height);
		}
	};
	
	box.setSelectedItem(selectedFont.getFontName());
	box.addActionListener(ae -> {
		fireChangeEvent();
	});
}
 
Example 15
Project: incubator-netbeans   File: ConfigurationsComboModel.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {
    if (ConfigurationsManager.getDefault().size() == 1) {
        setSelectedItem(getElementAt(0));
        return;
    }
    JComboBox combo = (JComboBox) ae.getSource();
    combo.setSelectedItem(lastSelected);
    combo.hidePopup();
    if (JOptionPane.showConfirmDialog(combo, 
    Bundle.MSG_ReallyDeleteConfig(lastSelected),
    Bundle.DeleteConfigTitle(),
    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        ConfigurationsManager.getDefault().remove(lastSelected);
        setSelectedItem(getElementAt(0));
    }
}
 
Example 16
Project: openjdk-jdk10   File: SelectAllFilesFilterTest.java   Source Code and License 6 votes vote down vote up
private static JComboBox findComboBox(Component comp) {

        if (comp instanceof JLabel) {
            JLabel label = (JLabel) comp;
            if (LABEL_TEXT.equals(label.getText())) {
                return (JComboBox) label.getLabelFor();
            }
        }

        if (comp instanceof Container) {
            Container cont = (Container) comp;
            for (int i = 0; i < cont.getComponentCount(); i++) {

                JComboBox result = findComboBox(cont.getComponent(i));
                if (result != null) {
                    return result;
                }
            }
        }

        return null;
    }
 
Example 17
Project: VASSAL-src   File: StringEnumConfigurer.java   Source Code and License 6 votes vote down vote up
public Component getControls() {
  if (panel == null) {
    panel = Box.createHorizontalBox();
    panel.add(new JLabel(name));
    box = new JComboBox(validValues);
    box.setMaximumSize(new Dimension(box.getMaximumSize().width,box.getPreferredSize().height));
    if (isValidValue(getValue())) {
      box.setSelectedItem(getValue());
    }
    else if (validValues.length > 0) {
      box.setSelectedIndex(0);
    }
    box.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        noUpdate = true;
        setValue(box.getSelectedItem());
        noUpdate = false;
      }
    });
    panel.add(box);
  }
  return panel;
}
 
Example 18
Project: incubator-netbeans   File: CopyDialogTest.java   Source Code and License 6 votes vote down vote up
public void testProcessRecentFolders_BranchInHistory () throws Exception {
    JComboBox combo = new JComboBox();
    JTextComponent comp = (JTextComponent) combo.getEditor().getEditorComponent();
    Map<String, String> items;
    // combo items should be sorted by name
    
    // file on branch, branches and tags in history
    items = CopyDialog.setupModel(combo, new RepositoryFile(new SVNUrl("file:///home"), "branches/SOMEBRANCH/subfolder/folder", SVNRevision.HEAD), recentUrlsWithBranches, false);
    assertModel(items, combo, Arrays.asList(new String[] {
        "trunk/subfolder/folder", null,
        "----------", null,
        "branches/branch1/subfolder/folder", "<html>branches/<strong>branch1</strong>/subfolder/folder</html>",
        "tags/tag1/subfolder/folder", "<html>tags/<strong>tag1</strong>/subfolder/folder</html>",
        MORE_BRANCHES, null,
        "----------", null,
        "branches/branch1/Project/src/folder", null, 
        "Project/src/folder", null,
        "Project2/src/folder", null,
        "tags/tag1/Project/src/folder", null,
        "trunk/Project/src/folder", null
    }));
    // least recently used branch is preselected
    assertEquals("branches/branch1/subfolder/folder", comp.getText());
    // no branch - no selection
    assertEquals("branch1", comp.getSelectedText());
}
 
Example 19
Project: incubator-netbeans   File: TargetMappingPanel.java   Source Code and License 5 votes vote down vote up
private void initMappings(List<FreeformProjectGenerator.TargetMapping> list, String antScript) {
    for (FreeformProjectGenerator.TargetMapping tm : list) {
        Iterator<JComboBox> combosIt = combos.iterator();
        for (TargetDescriptor desc : targetDescs) {
            JComboBox combo = combosIt.next();
            if (tm.name.equals(desc.getIDEActionName())) {
                selectItem(combo, Collections.singletonList(getListAsString(tm.targets)), true);
                checkAntScript(combo, antScript, tm.script);
            }
        }
    }
    targetMappings = list;
}
 
Example 20
Project: incubator-netbeans   File: DataComboBoxSupport.java   Source Code and License 5 votes vote down vote up
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
    // without the check the previous non-special item would be displayed
    // while calling DataComboBoxModel.newItemActionPerformed() 
    // instead of NEW_ITEM, but this is unwanted. Same for
    // popupMenuWillBecomeImvisible().
    if (!performingNewItemAction) {
        setPreviousNonSpecialItem((JComboBox)e.getSource());
    }
}
 
Example 21
Project: s-store   File: MarkovViewer.java   Source Code and License 5 votes vote down vote up
static JComboBox makeAlphabetizedComboBox(Map<Procedure, MarkovGraph> grafs) {
    List<Procedure> ls = new LinkedList<Procedure>();
    List<String> names = new LinkedList<String>();
    ls.addAll(grafs.keySet());
    for (Procedure p : ls) {
        names.add(p.getName().toLowerCase());
    }
    Collections.sort(names);
    JComboBox jcb = new JComboBox(names.toArray());
    ActionListener l = null; // FIXME(svelagap) new MyActionListener(grafs);
    jcb.addActionListener(l);
    return jcb;
}
 
Example 22
Project: openjdk-jdk10   File: JComboBoxOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JComboBox.removeItemAt(int)} through queue
 */
public void removeItemAt(final int i) {
    runMapping(new MapVoidAction("removeItemAt") {
        @Override
        public void map() {
            ((JComboBox) getSource()).removeItemAt(i);
        }
    });
}
 
Example 23
Project: Tarski   File: OurDialog.java   Source Code and License 5 votes vote down vote up
/** Asks the user to choose a font; returns "" if the user cancels the request. */
public synchronized static String askFont() {
   if (allFonts == null) allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   JComboBox jcombo = new OurCombobox(allFonts);
   Object ans = show("Font", JOptionPane.INFORMATION_MESSAGE,
         new Object[] {"Please choose the new font:", jcombo}, new Object[] {"Ok", "Cancel"}, "Cancel"
   );
   Object value = jcombo.getSelectedItem();
   if (ans=="Ok" && (value instanceof String)) return (String)value; else return "";
}
 
Example 24
Project: xdman   File: ConfigDialog.java   Source Code and License 5 votes vote down vote up
Box createGeneralPanel() {
	chkDwnldPrg = new JCheckBox(getString("SHOW_DWNLD_PRG"));
	chkDwnldPrg.setContentAreaFilled(false);
	chkDwnldPrg.setFocusPainted(false);
	chkDwnldNotify = new JCheckBox(getString("SHOW_DWNLD_PRG_NOTIFY"));
	chkDwnldPrg.setContentAreaFilled(false);
	chkDwnldPrg.setFocusPainted(false);
	chkFinishedDlg = new JCheckBox(getString("SHOW_DWNLD_DLG"));
	chkFinishedDlg.setContentAreaFilled(false);
	chkFinishedDlg.setFocusPainted(false);
	chkFinishedNotify = new JCheckBox(getString("SHOW_DWNLD_NOTIFY"));
	chkFinishedNotify.setContentAreaFilled(false);
	chkFinishedNotify.setFocusPainted(false);
	// chkAllowBrowser = new JCheckBox(getString("ALLOW_BROWSER"));
	// chkAllowBrowser.setContentAreaFilled(false);
	// chkAllowBrowser.setFocusPainted(false);
	cmbDupAction = new JComboBox(new String[] {
			StringResource.getString("DUP__OP1"),
			StringResource.getString("DUP__OP2"),
			StringResource.getString("DUP__OP3"),
			StringResource.getString("DUP__OP4") });
	cmbDupAction.setBorder(null);
	cmbDupAction.setMaximumSize(new Dimension(chkDwnldPrg
			.getPreferredSize().width,
			cmbDupAction.getPreferredSize().height));

	Box box = Box.createVerticalBox();
	box.setOpaque(false);
	box.setBorder(new EmptyBorder(10, 0, 0, 10));

	Box b0 = Box.createHorizontalBox();
	b0.add(chkDwnldPrg);
	b0.add(Box.createHorizontalGlue());
	box.add(b0);
	Box b1 = Box.createHorizontalBox();
	b1.add(chkFinishedDlg);
	b1.add(Box.createHorizontalGlue());
	box.add(b1);
	
	Box b31 = Box.createHorizontalBox();
	b31.add(chkDwnldNotify);
	b31.add(Box.createHorizontalGlue());
	box.add(b31);

	Box b3 = Box.createHorizontalBox();
	b3.add(chkFinishedNotify);
	b3.add(Box.createHorizontalGlue());
	box.add(b3);
	// Box b2 = Box.createHorizontalBox();
	// b2.add(chkAllowBrowser);
	// b2.add(Box.createHorizontalGlue());
	// box.add(b2);

	Box b4 = Box.createHorizontalBox();
	b4.add(new JLabel(getString("SHOW_DUP_ACTION")));
	b4.add(Box.createHorizontalGlue());
	b4.add(cmbDupAction);
	box.add(Box.createVerticalStrut(10));
	box.add(b4);

	return box;
}
 
Example 25
Project: Equella   File: Z3950Plugin.java   Source Code and License 5 votes vote down vote up
private void populateRecordSchema(JComboBox<NameValue> schemaCombo)
{
	for( RecordFormat format : RecordFormat.values() )
	{
		String uri = format.getUri();
		String name = format.getName() + " - " + uri; //$NON-NLS-1$
		schemaCombo.addItem(new NameValue(name, uri));
	}
}
 
Example 26
Project: openjdk-jdk10   File: JComboBoxOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JComboBox.getUI()} through queue
 */
public ComboBoxUI getUI() {
    return (runMapping(new MapAction<ComboBoxUI>("getUI") {
        @Override
        public ComboBoxUI map() {
            return ((JComboBox) getSource()).getUI();
        }
    }));
}
 
Example 27
Project: scorekeeperfrontend   File: SelectionBar.java   Source Code and License 5 votes vote down vote up
private <E> JComboBox<E> createCombo(String name)
{
    JComboBox<E> combo = new JComboBox<E>();
    combo.setActionCommand(name);
    combo.addActionListener(this);
    return combo;
}
 
Example 28
Project: jmt   File: StatsPanel.java   Source Code and License 5 votes vote down vote up
private void createComboTransf() {
	transfs = new JComboBox();
	transfs.setToolTipText(TRANSF_COMBO);
	transfs.addItem("Logarithmic");
	transfs.addItem("Mix - Max");
	transfs.addItem("z-score (Standard Deviation)");
}
 
Example 29
Project: incubator-netbeans   File: ComboBoxUpdater.java   Source Code and License 5 votes vote down vote up
/** Creates a new instance of TextComponentUpdater */
@SuppressWarnings("LeakingThisInConstructor")
public ComboBoxUpdater(JComboBox comp, JLabel label) {
    component = comp;
    component.addAncestorListener(this);
    this.label = label;
}
 
Example 30
Project: jaer   File: ParameterControlPanel.java   Source Code and License 5 votes vote down vote up
public EnumControl(final Class<? extends Enum> c, final Object f, PropertyDescriptor p) {
            super();
            final String name = p.getName();
            final Method r = p.getReadMethod(), w = p.getWriteMethod();

            setterMap.put(name, this);
            clazz = f;
            write = w;
            read = r;
            setLayout(new GridLayout(1, 0));
//            setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
            setAlignmentX(ALIGNMENT);
            final JLabel label = new JLabel(name);
            label.setAlignmentX(ALIGNMENT);
            label.setFont(label.getFont().deriveFont(fontSize));
            addTip(p, label);
            add(label);

            control = new JComboBox(c.getEnumConstants());
            control.setFont(control.getFont().deriveFont(fontSize));
//            control.setHorizontalAlignment(SwingConstants.LEADING);

            add(label);
            add(control);
            refresh();
            control.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    try {
                        w.invoke(clazz, control.getSelectedItem());
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
            });
        }
 
Example 31
Project: ramus   File: LineStyleAttributePlugin.java   Source Code and License 5 votes vote down vote up
@Override
public TableCellEditor getTableCellEditor(final Engine engine,
                                          final AccessRules rules, final Attribute attribute) {
    final JComboBox box = new JComboBox();
    box.setRenderer(comboBoxRenderer);

    for (Stroke stroke : LineStyleChooser.getStrokes()) {
        box.addItem(stroke);
    }

    return new DefaultCellEditor(box) {
        private Pin pin;

        @Override
        public boolean stopCellEditing() {
            if (box.getSelectedItem() instanceof Stroke) {
                ((Journaled) engine).startUserTransaction();
                apply((BasicStroke) box.getSelectedItem(), pin);
                return super.stopCellEditing();
            }
            return false;
        }

        @Override
        public Component getTableCellEditorComponent(JTable table,
                                                     Object value, boolean isSelected, int row, int column) {
            pin = (Pin) ((MetadataGetter) table).getMetadata();
            return super.getTableCellEditorComponent(table, value,
                    isSelected, row, column);
        }
    };
}
 
Example 32
Project: incubator-netbeans   File: QueryParameterTest.java   Source Code and License 5 votes vote down vote up
public void testComboParameters() {
    JComboBox combo = new JComboBox();
    ComboParameter cp = new QueryParameter.ComboParameter(combo, PARAMETER, "UTF-8");
    assertEquals(PARAMETER, cp.getParameter());
    assertNull(combo.getSelectedItem());
    assertEquals(cp.get(false).toString(), "&" + PARAMETER + "=");
    assertFalse(cp.isChanged());
    cp.setParameterValues(VALUES);
    cp.setValues(new ParameterValue[] {PV2});

    Object item = combo.getSelectedItem();
    assertNotNull(item);
    assertEquals(PV2, item);

    ParameterValue[] v = cp.getValues();
    assertEquals(1, v.length);
    assertEquals(PV2, v[0]);

    assertEquals(cp.get(false).toString(), "&" + PARAMETER + "=" + PV2.getValue());

    combo.setSelectedItem(PV3);
    assertEquals(cp.get(false).toString(), "&" + PARAMETER + "=" + PV3.getValue());
    
    assertTrue(cp.isChanged());
    cp.reset();
    assertFalse(cp.isChanged());
}
 
Example 33
Project: javaportfolio   File: TaxReportPane.java   Source Code and License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	JComboBox<Integer> cb = (JComboBox<Integer>) e.getSource();
	Integer selectedYear = (Integer) cb.getSelectedItem();
	setYearData(selectedYear);

}
 
Example 34
Project: geomapapp   File: CustomDB.java   Source Code and License 5 votes vote down vote up
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
//		GMA 1.4.8: Now check which combo box event is coming from
		if ( e.getSource() == box ) {

//			***** Changed by A.K.M. 6/23/06 *****
//			setPrototypeDisplayValue restricts the size of the box to a fixed 
//			length of eight characters
			box.setPrototypeDisplayValue("WWWWWWWW");
//			The popup listener adjusts the size of the popup to match the size 
//			of the text being displayed
			JComboBox tempBox = (JComboBox) e.getSource();
			Object comp = tempBox.getUI().getAccessibleChild(tempBox, 0);
			if (!(comp instanceof JPopupMenu)) {
				return;
			}
			JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
			Dimension size = scrollPane.getPreferredSize();
			UnknownDataSet tester1 = (UnknownDataSet)tempBox.getSelectedItem();
			CustomBRGTable.setReverseYAxis(false);
			CustomBRGTable.setIgnoreZeros(false);
//			6.5 is a hardcoded value that approximates the size of a 
//			character in pixels
//			TODO: Find exact size of text in pixels and adjust 
//			size.width accordingly
			if (tester1 != null) {
				if (maxDBNameLength < tester1.desc.name.length())	{
						maxDBNameLength = tester1.desc.name.length();
				}
				size.width = (int)(maxDBNameLength * 6.5);
				scrollPane.setPreferredSize(size);
			}
//			***** Changed by A.K.M. 6/23/06 *****
		}
	}
 
Example 35
Project: gate-core   File: LuceneDataStoreSearchGUI.java   Source Code and License 5 votes vote down vote up
protected void updateAnnotationSetsList() {
  String corpusName =
          (corpusToSearchIn.getSelectedItem()
                  .equals(Constants.ENTIRE_DATASTORE))
                  ? null
                  : (String)corpusIds
                          .get(corpusToSearchIn.getSelectedIndex() - 1);
  TreeSet<String> ts = new TreeSet<String>(stringCollator);
  ts.addAll(getAnnotationSetNames(corpusName));
  DefaultComboBoxModel<String> dcbm = new DefaultComboBoxModel<String>(ts.toArray(new String[ts.size()]));
  dcbm.insertElementAt(Constants.ALL_SETS, 0);
  annotationSetsToSearchIn.setModel(dcbm);
  annotationSetsToSearchIn.setSelectedItem(Constants.ALL_SETS);

  // used in the ConfigureStackViewFrame as Annotation type column
  // cell editor
  TreeSet<String> types = new TreeSet<String>(stringCollator);
  types.addAll(getTypesAndFeatures(null, null).keySet());
  // put all annotation types from the datastore
  // combobox used as cell editor
  JComboBox<String> annotTypesBox = new JComboBox<String>();
  annotTypesBox.setMaximumRowCount(10);
  annotTypesBox.setModel(new DefaultComboBoxModel<String>(types.toArray(new String[types.size()])));
  DefaultCellEditor cellEditor = new DefaultCellEditor(annotTypesBox);
  cellEditor.setClickCountToStart(0);
  configureStackViewFrame.getTable().getColumnModel()
          .getColumn(ANNOTATION_TYPE).setCellEditor(cellEditor);
}
 
Example 36
Project: incubator-netbeans   File: PersistenceProviderComboboxHelper.java   Source Code and License 5 votes vote down vote up
private void initCombo(JComboBox providerCombo) {
    
    DefaultComboBoxModel providers = new DefaultComboBoxModel();
    
    for(Provider each : providerSupplier.getSupportedProviders()){
       providers.addElement(each);
    }

    if (providers.getSize() == 0 && providerSupplier.supportsDefaultProvider()){
        providers.addElement(ProviderUtil.DEFAULT_PROVIDER);
    } 

    if (providers.getSize() == 0){
        providers.addElement(EMPTY);
    }
    
    providerCombo.setModel(providers);
    providerCombo.addItem(SEPARATOR);
    providerCombo.addItem(new NewPersistenceLibraryItem());
    providerCombo.addItem(new ManageLibrariesItem());
    providerCombo.setRenderer(new PersistenceProviderCellRenderer(getDefaultProvider(providers)));
    //select either default or first or preferred provider depending on project details
    int selectIndex = 0;
    if(providers.getSize()>1 && providers.getElementAt(0) instanceof Provider){
        String defProviderVersion = ProviderUtil.getVersion((Provider) providers.getElementAt(0));
        boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider
        if(specialCase){
            for (int i = 1; i<providers.getSize() ; i++){
                if(preferredProvider.equals(providers.getElementAt(i))){
                    selectIndex = i;
                    break;
                }
            }
        }
    }
    providerCombo.setSelectedIndex(selectIndex);
}
 
Example 37
Project: incubator-netbeans   File: TargetMappingPanel.java   Source Code and License 5 votes vote down vote up
@Override
public Class<?> getColumnClass(int column) {
    switch (column) {
        case 0: return String.class;
        default: return JComboBox.class;
    }
}
 
Example 38
Project: incubator-netbeans   File: RepositoryComboSupportTest.java   Source Code and License 5 votes vote down vote up
/**
 * Tests that the routine for determination if initial repository selection
 * is performed (not skipped) if there is only one repository available
 * and method {@code setup()} was passed {@code false} as its third
 * argument. It also tests that the routine correctly determines no
 * repository should be preselected if there is no node selected that
 * would refer to the repository.
 */
@Test(timeout=10000)
public void testSingleRepoNoMatchingNodeFalse() throws InterruptedException {
    printTestName("testSingleRepoNoMatchingNodeFalse");
    runRepositoryComboTest(new SingleRepoComboTezt() {
        @Override
        protected void setUpEnvironment() {
            selectNodes(node1);
        }
        @Override
        RepositoryComboSupport setupComboSupport(JComboBox comboBox) {
            return RepositoryComboSupport.setup(null, comboBox, false);
        }
        @Override
        protected void scheduleTests(ProgressTester progressTester) {
            super.scheduleTests(progressTester);
            progressTester.scheduleResumingTest  (Progress.DISPLAYED_REPOS, AWT,
                                                    new ComboBoxItemsTezt(
                                                            SELECT_REPOSITORY,
                                                            repository1),
                                                    new SelectedItemtezt(
                                                            SELECT_REPOSITORY));
            progressTester.scheduleTest          (Progress.WILL_DETERMINE_DEFAULT_REPO, NON_AWT);
            progressTester.scheduleTest          (Progress.DETERMINED_DEFAULT_REPO, NON_AWT);
        }
    });
}
 
Example 39
Project: AgentWorkbench   File: ThreadMonitorToolBar.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes jComboBoxInterval.
 * @return javax.swing.JComboBox
 */
public JComboBox<TimeSelection> getJComboBoxInterval() {
	if (jComboBoxInterval == null) {
		jComboBoxInterval = new JComboBox<TimeSelection>(this.getComboBoxModelRecordingInterval());
		jComboBoxInterval.setMaximumRowCount(comboBoxModelInterval.getSize());
		jComboBoxInterval.setModel(comboBoxModelInterval);
		jComboBoxInterval.setToolTipText(Language.translate("Abtastintervall"));
		jComboBoxInterval.addActionListener(this);
	}
	return jComboBoxInterval;
}
 
Example 40
Project: incubator-netbeans   File: ReturnTypeUIHelper.java   Source Code and License 5 votes vote down vote up
private static List populate(List<String> types, boolean creationSupported, final JComboBox combo, final String selectedType, boolean selectItemLater) {    

        
        List<Object> items = (types == null ? new LinkedList<Object>() : new LinkedList<Object>(types));
        
        if (items.size() > 0) {
            items.add(SEPARATOR_ITEM);
        }   
        
        if (creationSupported) {
            items.add(NEW_ITEM);
        }
        
        
        ReturnTypeComboBoxModel model = new ReturnTypeComboBoxModel(types, items);

        combo.setModel(model);
        
        if (selectedType != null) {

            // Ensure that the correct item is selected before listeners like FocusListener are called.
            // ActionListener.actionPerformed() is not called if this method is already called from 
            // actionPerformed(), in that case selectItemLater should be set to true and setSelectedItem()
            // below is called asynchronously so that the actionPerformed() is called
            setSelectedItem(combo, selectedType); 

            if (selectItemLater) {
                SwingUtilities.invokeLater(new Runnable() { // postpone item selection to enable event firing from JCombobox.setSelectedItem()
                    public void run() {
                        setSelectedItem(combo, selectedType); 
//                        populate(LVALUE_TYPES, true, combo, "Object", false);
                    }
                });
            }

        }
        
        return types;
    }
 
Example 41
Project: incubator-netbeans   File: EditLayoutSpacePanel.java   Source Code and License 5 votes vote down vote up
private static boolean applyGapValues(EditableGap eg, JComboBox sizeCombo, JCheckBox resCheckBox) {
    int newSize = Integer.MIN_VALUE;
    LayoutConstants.PaddingType newPadding = null;
    Object selSize = sizeCombo.getSelectedItem();
    if (eg.canHaveDefaultValue()) {
        for (int i=0, n=eg.getPaddingDisplayNames().length; i < n; i++) {
            String pdn = eg.getPaddingDisplayNames()[i];
            if (pdn.equals(selSize)) {
                newSize = LayoutConstants.NOT_EXPLICITLY_DEFINED;
                if (eg.getPossiblePaddingTypes() != null) {
                    newPadding = eg.getPossiblePaddingTypes()[i];
                }
                break;
            }
        }
    }
    if (newSize == Integer.MIN_VALUE) {
        try {
            newSize = Integer.parseInt((String)selSize);
            if (newSize < 0) { // Negative
                notify("MSG_NegativeSpaceSize"); // NOI18N
                return false;
            }
            if (newSize > Short.MAX_VALUE) { // Too large
                notify("MSG_TooLargeSpaceSize"); // NOI18N
                return false;
            }
        } catch (NumberFormatException nfex) { // Not a nubmer
            notify("MSG_CorruptedSpaceSize"); // NOI18N
            return false;
        }            
    }
    eg.definedSize = newSize;
    eg.paddingType = newPadding;
    eg.resizing = resCheckBox.isSelected();
    return true;
}
 
Example 42
Project: AgentWorkbench   File: AddComponentDialog.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes jComboBoxFilter	
 * @return javax.swing.JComboBox	
 */
private JComboBox<String> getJComboBoxFilter() {
	if (jComboBoxFilter == null) {
		jComboBoxFilter = new JComboBox<String>(this.getNewComboBoxModelFilter());
		jComboBoxFilter.setPreferredSize(new Dimension(100, 26));
		jComboBoxFilter.addActionListener(this);
	}
	return jComboBoxFilter;
}
 
Example 43
Project: Logisim   File: Attributes.java   Source Code and License 5 votes vote down vote up
@Override
public java.awt.Component getCellEditor(Object value) {
	JComboBox<Object> combo = new JComboBox<Object>(vals);
	combo.setRenderer(new OptionComboRenderer<V>(this));
	if (value == null)
		combo.setSelectedIndex(-1);
	else
		combo.setSelectedItem(value);
	return combo;
}
 
Example 44
Project: incubator-netbeans   File: IssuePanel.java   Source Code and License 5 votes vote down vote up
private void storeFieldValue(IssueField field, JComboBox combo) {
    Object value = combo.getSelectedItem();
    // It (normally) should not happen that value is null, but issue 159804 shows that
    // some strange configurations (or other bugs) can lead into this situation
    if (value != null) {
        storeFieldValue(field, value.toString());
    }
}
 
Example 45
Project: AgentWorkbench   File: Distribution.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes jComboBoxInterval.
 * @return javax.swing.JComboBox
 */
private JComboBox<TimeSelection> getJComboBoxRecordingInterval() {
	if (jComboBoxRecordingInterval == null) {
		jComboBoxRecordingInterval = new JComboBox<TimeSelection>(this.getComboBoxModelRecordingInterval());
		jComboBoxRecordingInterval.setMaximumRowCount(this.getComboBoxModelRecordingInterval().getSize());
		jComboBoxRecordingInterval.setSelectedItem(this.getComboBoxModelRecordingInterval().getElementAt(0));
		jComboBoxRecordingInterval.setPreferredSize(new Dimension(60, 26));
		jComboBoxRecordingInterval.setToolTipText(Language.translate("Abtastintervall"));
		jComboBoxRecordingInterval.addActionListener(this);
	}
	return jComboBoxRecordingInterval;
}
 
Example 46
Project: jmeter-prometheus-plugin   File: PrometheusListenerGui.java   Source Code and License 5 votes vote down vote up
protected JPanel createAssertionClassDropDown(){
	JPanel panel = new JPanel(new BorderLayout(5, 0));
	JLabel label = new JLabel("Assertion Type:");
	
	this.assertionComboBox = new JComboBox<>(availableAssertionClasses);
	
	panel.add(label, BorderLayout.WEST);
	panel.add(this.assertionComboBox, BorderLayout.CENTER);
	
	return panel;
}
 
Example 47
Project: javaportfolio   File: TaxDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Set up and show the dialog. The first Component argument determines which
 * frame the dialog depends on; it should be a component in the dialog's
 * controlling frame. The second Component argument should be null if you
 * want the dialog to come up with its left corner in the center of the
 * screen; otherwise, it should be the component on top of which the dialog
 * should appear.
 */

public TaxDialog(Component frameComp, Component locationComp,
		String title,  I_TickerManager tickerManager) {
	super(frameComp, locationComp, title, tickerManager);

	String[] currencies = {"EUR", "USD", "SEK" , "NOK"};
	currencyList = new JComboBox(currencies);
	currencyList.setEditable(true);
	currencyList.addActionListener(this);
	currencyList.setSelectedIndex(0);
	currencyList.setActionCommand(CURRENCY_CHANGED);
	
	totalCostField = new JTextField(FIELD_LEN);
	totalCostField.setEditable(true);
	totalCostField.setText("");		
	totalCostField.addKeyListener(this);
	
	dateFieldLabel = new JLabel("Maksupäivä: ");
	dateFieldLabel.setLabelFor(dateChooser);


	totalCostFieldLabel = new JLabel("yhteensä: ");
	totalCostFieldLabel.setLabelFor(totalCostField);

	currencyFieldLabel = new JLabel("Valuutta: ");
	
	updateRateFieldCcy((String) currencyList.getSelectedItem(), true);
	init(getDialogLabels(), getDialogComponents());
}
 
Example 48
Project: Equella   File: MapperTab.java   Source Code and License 5 votes vote down vote up
private JComponent createTop()
{
	JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
	mappingBox = new JComboBox();
	mappingBox.addItem(new IMSMapping(schema));
	mappingBox.addItem(new HTMLMapping(schema));
	mappingBox.addItem(new ScriptedLiteralMapping(schema));
	mappingBox.addItemListener(this);
	panel1.add(mappingBox);
	return panel1;
}
 
Example 49
Project: openjdk-jdk10   File: JComboBoxOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JComboBox.setMaximumRowCount(int)} through queue
 */
public void setMaximumRowCount(final int i) {
    runMapping(new MapVoidAction("setMaximumRowCount") {
        @Override
        public void map() {
            ((JComboBox) getSource()).setMaximumRowCount(i);
        }
    });
}
 
Example 50
Project: sumo   File: ActionDialog.java   Source Code and License 5 votes vote down vote up
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    this.setVisible(false);
    try {
        //String[] args = new String[components.size() ];
        this.actionArgs=new HashMap<>();
        int i = 0;
        for (JComponent c : components.values()) {
            if (c instanceof JTextField) {
                //args[i++]= ((JTextField) c).getText();
                actionArgs.put(((JTextField) c).getName(), ((JTextField) c).getText());
            } else if (c instanceof JComboBox) {
                //args[i++] = ((JComboBox) c).getSelectedItem() + "";
                actionArgs.put(((JComboBox) c).getName(),  ((JComboBox) c).getSelectedItem() + "");
            }
            else if (c instanceof JCheckBox) {
               // args[i++] = ((JCheckBox) c).isSelected() + "";
                actionArgs.put(((JCheckBox) c).getName(), ((JCheckBox) c).isSelected() + "");
            }
            /* else if (c instanceof DateControl) {
                args[i++] = new Timestamp(((DateControl) c).getDate().getTime()).toString();
            }*/
        }
        ok=true;
    } catch (Exception ex) {
    	logger.error(ex.getMessage(),ex);
    	ok=false;
    }
}
 
Example 51
Project: Progetto-I   File: ExecutePage.java   Source Code and License 5 votes vote down vote up
private void setComboBox()
{
    percorso = new JComboBox(progetto.percorsoArray());
    percorso.setPreferredSize(new Dimension(200, 30));
    ComboBoxListener cbl = new ComboBoxListener(progetto, this, percorso);
    percorso.addActionListener(cbl);
}
 
Example 52
Project: incubator-netbeans   File: DataComboBoxSupport.java   Source Code and License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    final JComboBox comboBox = (JComboBox)e.getSource();

    Object selectedItem = comboBox.getSelectedItem();
    if (selectedItem == NEW_ITEM) {
        performingNewItemAction = true;
        try {
            comboBox.setPopupVisible(false);
            dataModel.newItemActionPerformed();
        } finally {
            performingNewItemAction = false;
        }

        setPreviousNonSpecialItem(comboBox);
        // we (or maybe the client) have just selected an item inside an actionPerformed event,
        // which will not send another actionPerformed event for the new item. 
        // We need to make sure all listeners get an event for the new item,
        // thus...
        final Object newSelectedItem = comboBox.getSelectedItem();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                comboBox.setSelectedItem(newSelectedItem);
            }
        });
    }
}
 
Example 53
Project: incubator-netbeans   File: ComboBoxAutoCompleteSupport.java   Source Code and License 5 votes vote down vote up
private static JList getPopupList( JComboBox combo ) {
    Accessible a = combo.getUI().getAccessibleChild(combo, 0);

    if( a instanceof ComboPopup ) {
        return ((ComboPopup) a).getList();
    }
    return null;
}
 
Example 54
Project: OpenJSharp   File: MultiComboBoxUI.java   Source Code and License 5 votes vote down vote up
/**
 * Invokes the <code>isFocusTraversable</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public boolean isFocusTraversable(JComboBox a) {
    boolean returnValue =
        ((ComboBoxUI) (uis.elementAt(0))).isFocusTraversable(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComboBoxUI) (uis.elementAt(i))).isFocusTraversable(a);
    }
    return returnValue;
}
 
Example 55
Project: propan-jogl-examples   File: Example.java   Source Code and License 5 votes vote down vote up
public static JComponent createComponent() {
	JPanel panel = new JPanel(new BorderLayout());
	panel.setDoubleBuffered(false);

	panel.add(new JButton("Press me!"), BorderLayout.NORTH);

	JProgressBar bar = new JProgressBar() {
		protected void paintComponent(java.awt.Graphics g) {
			if (g instanceof GLGraphics2D
					) {
				super.paintComponent(g);
			} else {
				System.out.println(g.getClass());
			}
		}
	};
	bar.setIndeterminate(true);
	panel.add(bar, BorderLayout.SOUTH);
	panel.add(new JSlider(SwingConstants.VERTICAL, 0, 10, 3), BorderLayout.EAST);

	ButtonGroup grp = new ButtonGroup();
	JRadioButton radio1 = new JRadioButton("FM");
	JRadioButton radio2 = new JRadioButton("AM");
	grp.add(radio1);
	grp.add(radio2);

	JPanel panel2 = new JPanel(new GridLayout(0, 1));
	panel2.add(radio1);
	panel2.add(radio2);

	JComboBox b = new JComboBox(new String[] {"3", "4"});

	panel.add(b, BorderLayout.WEST);

	panel.setBorder(BorderFactory.createTitledBorder("Border"));

	return panel;
}
 
Example 56
Project: incubator-netbeans   File: TagsAndEditorsTest.java   Source Code and License 5 votes vote down vote up
public void testEditableSingleTagEditor() throws Exception {
    if (!canSafelyRunFocusTests()) {
        return;
    }
    Node n = new TNode(new EditableSingleTagEditor());
    setCurrentNode(n, ps);
    clickCell(ps.table, 1, 1);
    Component c = focusComp();
    assertTrue("Clicking on an editable property that returns a 1 element " +
            "array from getTags() should send focus to a combo box's child editor component",
            c.getParent() instanceof JComboBox);
}
 
Example 57
Project: VASSAL-src   File: FormattedStringConfigurer.java   Source Code and License 5 votes vote down vote up
public java.awt.Component getControls() {
  if (p == null) {
    super.getControls();

    nameField.addFocusListener(this);
    dropList = new JComboBox(optionsModel);
    dropList.setSelectedIndex(0);
    dropList.setEnabled(false);
    dropList.addActionListener(this);

    setListVisibility();
    p.add(dropList);
  }
  return p;
}
 
Example 58
Project: MTG-Card-Recognizer   File: SetGenerator.java   Source Code and License 5 votes vote down vote up
public SetGenerator()
{
	super("Set generator");
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	gen = new JButton("Generate sets");
	typeBox = new JComboBox<>(setTypes);
	JScrollPane scroll = new JScrollPane();
	gen.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e) {
			runThread = true;
			genSets = new Thread(){
				public void run()
				{
					typeBox.setEnabled(false);
					gen.setEnabled(false);
					ArrayList<Set> sets = MTGCardQuery.getSets();
					for(Set s:sets){
						writeSet(s,SavedConfig.PATH,true);
						if(!runThread){
							System.out.println("stopped");
							return;
						}
					}
					gen.setEnabled(true);
					typeBox.setEnabled(true);
				}
			};
			genSets.start();
		}
	});
	jt=new JTextArea(10,50);
	jt.setEditable(false);
	scroll.setViewportView(jt);
	setLayout(new BorderLayout());
	add(scroll,BorderLayout.NORTH);
	add(typeBox,BorderLayout.CENTER);
	add(gen,BorderLayout.SOUTH);
	pack();
	setVisible(true);
}
 
Example 59
Project: openjdk-jdk10   File: JComboBoxOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JComboBox.contentsChanged(ListDataEvent)} through queue
 */
public void contentsChanged(final ListDataEvent listDataEvent) {
    runMapping(new MapVoidAction("contentsChanged") {
        @Override
        public void map() {
            ((JComboBox) getSource()).contentsChanged(listDataEvent);
        }
    });
}
 
Example 60
Project: incubator-netbeans   File: UiUtils.java   Source Code and License 5 votes vote down vote up
public static void loadRepositories(final DockerInstance instance, final JComboBox<String> combo) {
    assert SwingUtilities.isEventDispatchThread();

    if (!(combo.getEditor().getEditorComponent() instanceof JTextComponent)) {
        return;
    }

    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            DockerAction facade = new DockerAction(instance);
            List<DockerImage> images = facade.getImages();
            final Set<String> repositories = new TreeSet<>();
            for (DockerImage image : images) {
                for (DockerTag tag : image.getTags()) {
                    int index = tag.getTag().lastIndexOf(':'); // NOI18N
                    if (index > 0) {
                        repositories.add(tag.getTag().substring(0, index));
                    }
                }
            }
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    // FIXME can we load items without clearing editor
                    if (UiUtils.getValue(combo) == null) {
                        int i = 0;
                        for (String repo : repositories) {
                            combo.insertItemAt(repo, i++);
                        }
                    }
                }
            });
        }
    });
}