List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel
public DefaultComboBoxModel(Vector<E> v)
From source file:br.com.bgslibrary.gui.MainFrame.java
private void load() { try {/*from www.ja va 2 s .c om*/ PropertiesConfiguration pc = new PropertiesConfiguration(); pc.load("bgslibrary_gui.properties"); basePath = pc.getString("base.path"); configPath = basePath + pc.getString("config.path"); String paths[] = pc.getStringArray("run.path"); loadConfigComboBox.setModel(new DefaultComboBoxModel(paths)); String methods[] = pc.getStringArray("bgs.methods"); tictocComboBox.setModel(new DefaultComboBoxModel(methods)); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:net.sf.jsignpdf.SignPdfForm.java
/** * @param aCloseOperation//from ww w. j av a2s . c o m */ public SignPdfForm(int aCloseOperation) { initComponents(); options.loadOptions(); translateLabels(); setDefaultCloseOperation(aCloseOperation); getRootPane().setDefaultButton(btnSignIt); // set Icon of frames URL tmpImgUrl = getClass().getResource("/net/sf/jsignpdf/signedpdf32.png"); setIconImage(Toolkit.getDefaultToolkit().getImage(tmpImgUrl)); infoDialog.setIconImage(getIconImage()); infoDialog.getRootPane().setDefaultButton(btnInfoClose); infoDialog.pack(); GuiUtils.center(infoDialog); // setIconImage is available from Java 1.6! // rightsDialog.setIconImage(getIconImage()); rightsDialog.getRootPane().setDefaultButton(btnRightsOK); rightsDialog.pack(); GuiUtils.center(rightsDialog); tsaDialog.pack(); GuiUtils.center(tsaDialog); vsDialog.pack(); GuiUtils.center(vsDialog); options.setListener(this); final Set<String> tmpKsTypes = KeyStoreUtils.getKeyStores(); cbKeystoreType.setModel(new DefaultComboBoxModel(tmpKsTypes.toArray(new String[tmpKsTypes.size()]))); if (tmpKsTypes.contains(Constants.KEYSTORE_TYPE_WINDOWS_MY)) { cbKeystoreType.setSelectedItem(Constants.KEYSTORE_TYPE_WINDOWS_MY); } cbPdfEncryption.setModel(new DefaultComboBoxModel(PDFEncryption.values())); cbCertLevel.setModel(new DefaultComboBoxModel(CertificationLevel.values())); cbHashAlgorithm.setModel(new DefaultComboBoxModel(HashAlgorithm.values())); cbPrinting.setModel(new DefaultComboBoxModel(PrintRight.values())); final JTextAreaAppender jTextAreaAppender = new JTextAreaAppender(infoTextArea); final Logger rootLogger = Logger.getRootLogger(); final Appender appender = rootLogger.getAppender("jsignpdf"); final Layout layout = appender != null ? appender.getLayout() : new SimpleLayout(); jTextAreaAppender.setLayout(layout); rootLogger.addAppender(jTextAreaAppender); updateFromOptions(); }
From source file:de.cebitec.readXplorer.differentialExpression.plot.ExpressTestGraphicsTopComponent.java
/** * TopComponent, which displays all graphics available for the express test. * @param analysisHandler The analysis handler containing the results * @param usedTool The tool used for the analysis (has to be the ExpressTest in this case) */// w ww . j a v a2s .c om public ExpressTestGraphicsTopComponent(DeAnalysisHandler analysisHandler, DeAnalysisHandler.Tool usedTool) { this.analysisHandler = analysisHandler; this.usedTool = usedTool; results = analysisHandler.getResults(); List<String> descriptions = new ArrayList<>(); for (Iterator<ResultDeAnalysis> it = results.iterator(); it.hasNext();) { ResultDeAnalysis currentResult = it.next(); descriptions.add(currentResult.getDescription()); } cbmDataSet = new DefaultComboBoxModel<>(descriptions.toArray(new String[descriptions.size()])); initComponents(); initAdditionalComponents(); }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
public void prepareInstall(List<PackDescription> packs) { availablePacks = packs;/*w ww .j ava2 s . c om*/ String[] names; names = packs.stream().map(s -> s.name).toArray(s -> new String[s]); modpackChooser.setModel(new DefaultComboBoxModel<>(names)); modpackChooserActionPerformed(null); packs.stream().forEach((PackDescription p) -> { Manifest mf = manifest.get(p.name); if (mf != null) { p.addons.forEach((Addon a) -> { a.install = mf.containsKey(a.name); }); } }); force.setSelected(false); }
From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttributeDialog.java
private void init() { thisDialog = this; setBounds(100, 100, 820, 335);/*from ww w . j ava2 s.c om*/ getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { JLabel lblAttributeType = new JLabel("Attribute Type"); panel.add(lblAttributeType, "2, 2, right, default"); } { comboBoxType = new JComboBox(); comboBoxType.setModel(new DefaultComboBoxModel( new String[] { "caste", "scientific name", "sex", "life stage", "part association" })); comboBoxType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String item = comboBoxType.getSelectedItem().toString(); if (item != null) { comboBoxValue.setEditable(false); if (item.equals("scientific name")) { comboBoxValue.setEditable(true); } if (item.equals("sex")) { comboBoxValue.setModel(new DefaultComboBoxModel(Sex.getSexValues())); } if (item.equals("life stage")) { comboBoxValue.setModel(new DefaultComboBoxModel(LifeStage.getLifeStageValues())); } if (item.equals("caste")) { comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); } if (item.equals("part association")) { comboBoxValue .setModel(new DefaultComboBoxModel(PartAssociation.getPartAssociationValues())); } } } }); panel.add(comboBoxType, "4, 2, fill, default"); } { JLabel lblValue = new JLabel("Value"); panel.add(lblValue, "2, 4, right, default"); } { comboBoxValue = new JComboBox(); comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); panel.add(comboBoxValue, "4, 4, fill, default"); } { JLabel lblUnits = new JLabel("Units"); panel.add(lblUnits, "2, 6, right, default"); } { textFieldUnits = new JTextField(); panel.add(textFieldUnits, "4, 6, fill, default"); textFieldUnits.setColumns(10); } { JLabel lblRemarks = new JLabel("Remarks"); panel.add(lblRemarks, "2, 8, right, default"); } contentPanel.setLayout(new BorderLayout(0, 0)); contentPanel.add(panel, BorderLayout.WEST); { textFieldRemarks = new JTextField(); panel.add(textFieldRemarks, "4, 8, fill, default"); textFieldRemarks.setColumns(10); } { JButton btnAdd = new JButton("Add"); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SpecimenPartAttribute newAttribs = new SpecimenPartAttribute(); newAttribs.setAttributeType(comboBoxType.getSelectedItem().toString()); newAttribs.setAttributeValue(comboBoxValue.getSelectedItem().toString()); newAttribs.setAttributeUnits(textFieldUnits.getText()); newAttribs.setAttributeRemark(textFieldRemarks.getText()); newAttribs.setSpecimenPartId(parentPart); newAttribs.setAttributeDeterminer(Singleton.getSingletonInstance().getUserFullName()); parentPart.getAttributeCollection().add(newAttribs); SpecimenPartAttributeLifeCycle sls = new SpecimenPartAttributeLifeCycle(); try { sls.attachDirty(newAttribs); } catch (SaveFailedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ((AbstractTableModel) table.getModel()).fireTableDataChanged(); } }); panel.add(btnAdd, "4, 10"); } try { JLabel lblNewLabel = new JLabel(parentPart.getSpecimenId().getBarcode() + ":" + parentPart.getPartName() + " " + parentPart.getPreserveMethod() + " (" + parentPart.getLotCount() + ") Right click on table to edit attributes."); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } catch (Exception e) { JLabel lblNewLabel = new JLabel("No Specimen"); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } JComboBox comboBox = new JComboBox(); comboBox.addItem("caste"); JComboBox comboBox1 = new JComboBox(); for (int i = 0; i < Caste.getCasteValues().length; i++) { comboBox1.addItem(Caste.getCasteValues()[i]); } JScrollPane scrollPane = new JScrollPane(); table = new JTable(new SpecimenPartsAttrTableModel( (Collection<SpecimenPartAttribute>) parentPart.getAttributeCollection())); //table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox)); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); popupMenu = new JPopupMenu(); JMenuItem mntmCloneRow = new JMenuItem("Edit Row"); mntmCloneRow.setMnemonic(KeyEvent.VK_E); mntmCloneRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Launch a dialog to edit the selected row. SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog( ((SpecimenPartsAttrTableModel) table.getModel()).getRowObject(clickedOnRow)); popup.setVisible(true); } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to edit a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmCloneRow); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.setMnemonic(KeyEvent.VK_D); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (clickedOnRow >= 0) { ((SpecimenPartsAttrTableModel) table.getModel()).deleteRow(clickedOnRow); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to delete a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmDeleteRow); // TODO: Enable controlled value editing of selected row. // table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox1)); scrollPane.setViewportView(table); contentPanel.add(scrollPane, BorderLayout.EAST); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton.grabFocus(); thisDialog.setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { thisDialog.setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java
public SedStackerFrame(IrisApplication app, IWorkspace ws) { initComponents();/*from w w w .ja v a2 s . co m*/ this.rootFrame = ws.getRootFrame(); this.app = app; this.controller = app.getSAMPController(); this.manager = (SedlibSedManager) ws.getSedManager(); this.ws = ws; if (stacks.isEmpty()) { SedStack stack = new SedStack("Stack"); updateStackList(stack, true); } // normalization comboBoxes. Chooses the list of units available // based on the normalization type chosen (Value, Median, or Average). // Also disable Y value text box if using Average or Median. //TODO: cleanup unused code. integrationNormType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String normType = (String) integrationNormType.getSelectedItem(); String[] model; if (normType.equals("Value") && getSelectedConfig().getNormConfiguration().isIntegrate()) { model = new String[] { "erg/s/cm2", "Jy-Hz", "Watt/m2", "erg/s", "Watt" }; integrationValueText.setEnabled(true); } else { model = loadEnum(SPVYUnit.class); integrationValueText.setEnabled(false); } try { Object yunit = integrationYUnit.getSelectedItem(); integrationYUnit.setModel(new DefaultComboBoxModel(model)); integrationYUnit.setSelectedItem(yunit); } catch (IllegalArgumentException ex) { integrationYUnit.setModel(new DefaultComboBoxModel(model)); } catch (Exception ex) { integrationYUnit.setModel(new DefaultComboBoxModel(model)); } } }); // atPointYType.addActionListener( new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // // String normType = (String) atPointYType.getSelectedItem(); // if (normType.equals("Value")) { // atPointYText.setEnabled(true); // } else { // atPointYText.setEnabled(false); // } // // } // }); jRadioButton1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean selected = jRadioButton1.isSelected(); if (selected && integrationNormType.getSelectedItem().equals("Value")) { integrationValueText.setEnabled(true); } else { integrationValueText.setEnabled(false); } atPointYText.setEnabled(false); } }); jRadioButton2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean selected = jRadioButton2.isSelected(); if (selected && atPointYType.getSelectedItem().equals("Value")) { atPointYText.setEnabled(true); } else { atPointYText.setEnabled(false); } integrationValueText.setEnabled(false); // good - keep! } }); /* The following four statements add Action Listeners to the unit combo boxes in the normalization options. These are so that whatever units the user uses for normalization will be selected for stacking. THIS CODE WORKS!! Commenting it out because this might not be desired functionality. (01/20/2015) */ // integrationYUnit.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // String unitName = (String) integrationYUnit.getSelectedItem(); // for (int i=0; i<stackYUnitComboBox.getModel().getSize(); i++) { // if (stackYUnitComboBox.getModel().getElementAt(i).equals(unitName)) { // stackYUnitComboBox.setSelectedItem(unitName); // } // } // } // }); // atPointYUnit.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // int unit = (int) atPointYUnit.getSelectedIndex(); // stackYUnitComboBox.setSelectedIndex(unit); // } // }); // integrationMinMaxUnit.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // int unit = (int) integrationMinMaxUnit.getSelectedIndex(); // stackBinSizeUnitsComboBox.setSelectedIndex(unit); // } // }); // atPointXUnit.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // int unit = (int) atPointXUnit.getSelectedIndex(); // stackBinSizeUnitsComboBox.setSelectedIndex(unit); // } // }); // // undo management items // ExtendedUndoManager undoManager = new ExtendedUndoManager(); // UndoableEditSupport undoSupport = new UndoableEditSupport(); // undoSupport.addUndoableEditListener(new UndoAdapter()); // refreshUndoRedo(); // // Action redshift = new RedshiftAction(); // Action normalize = new NormalizeAction(); // Action stack = new StackAction(); }
From source file:de.cebitec.readXplorer.differentialExpression.plot.BaySeqGraphicsTopComponent.java
/** * TopComponent, which displays all graphics available for a baySeq analysis. * @param handler The analysis handler containing the results *///from w w w . ja va 2 s . c o m public BaySeqGraphicsTopComponent(DeAnalysisHandler handler) { baySeqAnalysisHandler = (BaySeqAnalysisHandler) handler; List<ResultDeAnalysis> results = handler.getResults(); this.result = results.get(results.size() - 1); groups = baySeqAnalysisHandler.getGroups(); cbm = new DefaultComboBoxModel<>(BaySeqAnalysisHandler.Plot.values()); initComponents(); iSymbol.setVisible(false); iSymbol.setToolTipText(org.openide.util.NbBundle.getMessage(BaySeqGraphicsTopComponent.class, "GraphicsTopComponent.iSymbol.toolTipText")); setName(Bundle.CTL_BaySeqGraphicsTopComponent()); setToolTipText(Bundle.HINT_BaySeqGraphicsTopComponent()); svgCanvas = new JSVGCanvas(); jPanel1.add(svgCanvas, BorderLayout.CENTER); svgCanvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderListener() { @Override public void documentLoadingStarted(SVGDocumentLoaderEvent e) { progressHandle.start(); progressHandle.switchToIndeterminate(); } @Override public void documentLoadingCompleted(SVGDocumentLoaderEvent e) { progressHandle.switchToDeterminate(100); progressHandle.finish(); saveButton.setEnabled(true); plotButton.setEnabled(true); } @Override public void documentLoadingCancelled(SVGDocumentLoaderEvent e) { } @Override public void documentLoadingFailed(SVGDocumentLoaderEvent e) { messages.setText("Could not load SVG file. Please try again."); } }); SVGCanvasActive = true; }
From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java
private void detectDevices() { List<String> devices = Adb.getSerialProduct().entrySet().stream() .map(entry -> entry.getKey() + ":" + entry.getValue()).collect(Collectors.toList()); ComboBoxModel<String> model = new DefaultComboBoxModel<>(devices.toArray(new String[0])); jcbDevices.setModel(model);/*from w ww . ja va 2 s. com*/ if (model.getSize() == 0) { JOptionPane.showMessageDialog(jcbDevices.getTopLevelAncestor(), "No attached Android device found."); this.jbLaunch.setEnabled(false); } else { this.jbLaunch.setEnabled(true); } }
From source file:com.epiq.bitshark.ui.FrequencyDomainPanel.java
/** Creates new form FrequencyDomainPanel */ public FrequencyDomainPanel() { initComponents();//from w w w. ja va 2s . com initGraph(); headerPanel.setBackgroundPainter(Common.getHeaderPainter()); JPanel holderPanel = new JPanel() { @Override public void paint(Graphics g) { if (plot.getDomainAxis().isAutoRange()) { plot.getDomainAxis().setAutoRange(false); Range newDomain = new Range(0, FMCUartClient.BLOCK_SIZE - 1); plot.getDomainAxis().setRange(newDomain, true, false); } if (plot.getRangeAxis().isAutoRange()) { plot.getRangeAxis().setAutoRange(false); Range newRange = new Range(-50, 70); plot.getRangeAxis().setRange(newRange, true, false); } super.paint(g); } }; holderPanel.setLayout(new BorderLayout()); holderPanel.add(chartPanel, BorderLayout.CENTER); this.mainPanel.add(holderPanel, BorderLayout.CENTER); windowComboBox.setModel(new DefaultComboBoxModel(WindowFunction.values())); windowComboBox.setSelectedItem(WindowFunction.BLACKMAN_HARRIS); windowComboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (c instanceof JLabel && value instanceof WindowFunction) { JLabel l = (JLabel) c; WindowFunction cw = (WindowFunction) value; l.setText(cw.getName()); } return c; } }); graphLabel.setUI(new BasicLabelUI()); alphaLabel.setUI(new BasicLabelUI()); windowLabel.setUI(new BasicLabelUI()); }
From source file:com.cch.aj.entryrecorder.frame.EntryJFrame.java
private void UpdateTabEntry(int id) { //entry//w w w. j a v a2 s . com Entry currentEntry = new Entry(); int selectedIndex = FillEntryComboBox(this.cbEntry, id); if (selectedIndex >= 0) { currentEntry = ((ComboBoxItem<Entry>) this.cbEntry.getSelectedItem()).getItem(); this.UpdateEntryUI(currentEntry); } else { this.cbEntry.setModel(new DefaultComboBoxModel(new ComboBoxItem[] {})); this.UpdateEntryUI(new Entry()); } if (this.cbEntry.getSelectedItem() == null || ((ComboBoxItem<Entry>) this.cbEntry.getSelectedItem()).getId() == 0) { this.pnlEditEntry.setVisible(false); this.btnEntryDelete.setVisible(false); this.btnEntrySave.setVisible(false); this.btnEntryUndo.setVisible(false); } else { this.pnlEditEntry.setVisible(true); this.btnEntryDelete.setVisible(true); this.btnEntrySave.setVisible(true); this.btnEntryUndo.setVisible(true); } }