List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel
public DefaultComboBoxModel(Vector<E> v)
From source file:de.cebitec.readXplorer.differentialExpression.plot.DeSeqGraphicsTopComponent.java
/** * TopComponent, which displays all graphics available for a DESeq analysis. * @param analysisHandler The analysis handler containing the results * @param usedTool The tool used for the analysis (has to be DESeq in this * case)/* www .java 2 s . c o m*/ */ public DeSeqGraphicsTopComponent(DeAnalysisHandler handler, boolean moreThanTwoConditions) { analysisHandler = handler; this.result = handler.getResults().get(0); cbm = new DefaultComboBoxModel(DeSeqAnalysisHandler.Plot.getValues(moreThanTwoConditions)); initComponents(); setupGraphics(); iSymbol.setVisible(false); iSymbol.setToolTipText(org.openide.util.NbBundle.getMessage(DeSeqGraphicsTopComponent.class, "GraphicsTopComponent.iSymbol.toolTipText")); }
From source file:OAT.ui.util.UiUtil.java
public static void fillCombo(JComboBox comboBox, Collection items) { comboBox.setModel(new DefaultComboBoxModel(items.toArray())); }
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:gda.gui.beans.EnumPositionerComboBean.java
/** * Must be called after the positions array has been populated. * //from w w w . j a v a 2 s . c o m * @return JComboBox */ private JComboBox getCmbChoices() { if (cmbChoices == null && commandPositions != null) { ComboBoxModel cmbChoicesModel = new DefaultComboBoxModel(commandPositions); cmbChoices = new JComboBox(); cmbChoices.setModel(cmbChoicesModel); cmbChoices.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { uk.ac.gda.util.ThreadManager.getThread(new Runnable() { @Override public void run() { cmbChoicesActionPerformed(); } }).start(); } }); } return cmbChoices; }
From source file:dbmods.InsertTemplateName.java
private void addUserName() { //START >> jTechnologyLabel jTechnologyLabel = new JLabel(); getContentPane().add(jTechnologyLabel); jTechnologyLabel.setText("Technology"); jTechnologyLabel.setBounds(28, 78, 152, 16); //END << jTechnologyLabel //START >> jUserList ComboBoxModel<String> jUserListModel = new DefaultComboBoxModel<String>(USERS); jUserList = new JComboBox<String>(); getContentPane().add(jUserList);/*from w w w. j a v a 2 s . c om*/ jUserList.setModel(jUserListModel); jUserList.setBounds(192, 110, 118, 23); //END << jUserList }
From source file:net.sf.jsignpdf.VisibleSignatureDialog.java
/** Creates new form VisibleSignatureDialog */ public VisibleSignatureDialog(java.awt.Frame parent, boolean modal, final BasicSignerOptions anOptions, final SignerFileChooser aFC) { super(parent, modal); options = anOptions;/*from ww w . j ava2s . c om*/ fc = aFC; p2i = new Pdf2Image(options); initComponents(); translateLabels(); tfPage.getDocument().addDocumentListener(new PageNrDocumentListener()); selectionImage.getRelRect().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (previewListenerDisabled) return; final RelRect tmpRect = selectionImage.getRelRect(); if (pdfPageInfo == null || !tmpRect.isValid()) { return; } Float[] coords = tmpRect.getCoords(); tfPosLLX.setText(String.valueOf(coords[0] * pdfPageInfo.getWidth())); tfPosLLY.setText(String.valueOf(coords[1] * pdfPageInfo.getHeight())); tfPosURX.setText(String.valueOf(coords[2] * pdfPageInfo.getWidth())); tfPosURY.setText(String.valueOf(coords[3] * pdfPageInfo.getHeight())); } }); cbDisplayMode.setModel(new DefaultComboBoxModel(RenderMode.values())); extraInfo = new PdfExtraInfo(anOptions); previewDialog.add(selectionImage, java.awt.BorderLayout.CENTER); previewDialog.setModal(true); previewDialog.getRootPane().setDefaultButton(btnPreviewClose); GuiUtils.resizeAndCenter(previewDialog); getRootPane().setDefaultButton(btnClose); }
From source file:eu.ggnet.dwoss.redtape.position.PositionUpdateCask.java
@Override public void accept(Position position) { if (position == null) return;//from ww w . j a va 2 s. c o m PostLedger postLedger = lookup(MandatorSupporter.class).loadPostLedger(); List bookingAccounts = new ArrayList(); bookingAccounts.add(postLedger.get(position.getType()).orElse(-1)); bookingAccounts.addAll(postLedger.getPossible(position.getType()).orElse(Collections.EMPTY_LIST)); bookingAccountBox.setModel(new DefaultComboBoxModel(bookingAccounts.toArray())); this.position = position; this.setPositionName(position.getName()); this.setPrice(position.getPrice()); this.setDescription(position.getDescription()); this.setAmount(position.getAmount()); this.setPreDecimal((int) (position.getAmount() - (position.getAmount() % 1))); this.setPostDecimal((int) ((position.getAmount() % 1) * 100)); this.setBookingAccount(position.getBookingAccount()); System.out.println("Pre: " + this.getPreDecimal()); System.out.println("Post: " + this.getPostDecimal()); this.accessCos = lookup(Guardian.class); if (position.getDocument() != null && EnumSet.of(DocumentType.ANNULATION_INVOICE, DocumentType.CREDIT_MEMO) .contains(position.getDocument().getType())) { disableComponents(preDecimalSpinner, postDecimalSpinner, nameArea, bookingAccountBox, priceField, afterTaxPriceField, descriptionArea); accessCos.add(priceSumField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT); accessCos.add(afterTaxSumField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT); accessCos.add(priceField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT); accessCos.add(afterTaxPriceField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT); } else { if (position.getType() == PRODUCT_BATCH || position.getType() == UNIT) { disableComponents(postDecimalSpinner); accessCos.add(priceField, UPDATE_PRICE_OF_UNITS_AND_PRODUCT_BATCH); accessCos.add(afterTaxPriceField, UPDATE_PRICE_OF_UNITS_AND_PRODUCT_BATCH); } if (position.getType() == UNIT) { disableComponents(preDecimalSpinner); bookingAccountBox.setEnabled(true); } if (position.getType() == COMMENT) { disableComponents(priceField, priceSumField, afterTaxPriceField, afterTaxSumField, preDecimalSpinner, postDecimalSpinner); } if (position.getType() == SHIPPING_COST) { disableComponents(nameArea, afterTaxPriceField, afterTaxSumField, preDecimalSpinner, postDecimalSpinner); } if (EnumSet.of(COMMENT, SERVICE, PRODUCT_BATCH).contains(position.getType())) { nameArea.setEditable(true); if (position.getType() == SERVICE) bookingAccountBox.setEnabled(true); } } }
From source file:forms.frDados.java
/** * Instancia o form./*from w ww . j a va 2s. co m*/ */ public frDados() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //SwingUtilities.updateComponentTreeUI(this); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(frDados.class.getName()).log(Level.SEVERE, null, ex); } initComponents(); this.setLocationRelativeTo(null); inicializarTemas(); initSatGrafico(); initSatVelox(); initMapPanel(); init3DMapPanel(); carregarListaUsers(); initOsmPanel(); cmbPortas.setModel(new DefaultComboBoxModel(ComunicadorSerial.getPortasDisponiveis())); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { setVisible(true); } }); }
From source file:com.emr.schemas.TableRelationsForm.java
/** * Constructor//from w w w .ja v a 2 s .c om * @param tables {@link List} List of source tables */ public TableRelationsForm(List tables, SchemerMapper parent) { fileManager = null; dbManager = null; emrConn = null; this.parent = parent; this.tables = tables; //source tables //Create KenyaEMR DB connection fileManager = new FileManager(); String[] settings = fileManager.getConnectionSettings("emr_database.properties", "emr"); if (settings == null) { //Connection settings not found JOptionPane.showMessageDialog(null, "Database Settings not found. Please set the connection settings for the database first.", "KenyaEMR Database settings", JOptionPane.ERROR_MESSAGE); //Open KenyaEMRConnectionForm form } else { if (settings.length < 1) { JOptionPane.showMessageDialog(null, "Database Settings not found. Please set the connection settings for the database first.", "KenyaEMR Database settings", JOptionPane.ERROR_MESSAGE); //Open KenyaEMRConnectionForm form } else { //Connection settings are ok //We establish a connection dbManager = new DatabaseManager(settings[0], settings[1], settings[3], settings[4], settings[5]); emrConn = dbManager.getConnection(); if (emrConn == null) { JOptionPane.showMessageDialog(null, "Test Connection Failed", "Connection Test", JOptionPane.ERROR_MESSAGE); } } } //get all columns and add them to the columns list for (Object table : tables) { String tablename = (String) table; populateTableColumnsToList(tablename); } model = new DefaultTableModel( new Object[] { "Primary Table", "Column", "Reference Table", "Foreign Column" }, 10); initComponents(); this.setClosable(true); foreignTables = tables; combo1 = new JComboBox();//Combobox for the primary tables combo2 = new JComboBox(); combo3 = new JComboBox(); combo4 = new JComboBox(); combo1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { String selectedTable = (String) event.getItem(); //populate primary table columns primaryColumns = getTableColumns(selectedTable); DefaultComboBoxModel combo2_model = new DefaultComboBoxModel( primaryColumns.toArray(new String[primaryColumns.size()])); JComboBox comboBox = new JComboBox(); comboBox.setModel(combo2_model); relationsTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox)); } } }); combo3.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { String selectedTable = (String) event.getItem(); //populate foreign table columns foreignColumns = getTableColumns(selectedTable); DefaultComboBoxModel combo3_model = new DefaultComboBoxModel( foreignColumns.toArray(new String[foreignColumns.size()])); JComboBox comboBox = new JComboBox(); comboBox.setModel(combo3_model); relationsTable.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(comboBox)); } } }); ComboBoxTableCellEditor primaryTableEditor = new ComboBoxTableCellEditor(tables, combo1); ComboBoxTableCellEditor primaryTableColumns = new ComboBoxTableCellEditor(primaryColumns, combo2); ComboBoxTableCellEditor foreignTableEditor = new ComboBoxTableCellEditor(foreignTables, combo3);//TODO: remove selected primary table from list ComboBoxTableCellEditor foreignTableColumns = new ComboBoxTableCellEditor(foreignColumns, combo4); relationsTable.getColumnModel().getColumn(0).setCellEditor(primaryTableEditor); relationsTable.getColumnModel().getColumn(1).setCellEditor(primaryTableColumns); relationsTable.getColumnModel().getColumn(2).setCellEditor(foreignTableEditor); relationsTable.getColumnModel().getColumn(3).setCellEditor(foreignTableColumns); columnsList.setCellRenderer(new CheckboxListCellRenderer()); SourceTablesListener listSelectionListener = new SourceTablesListener(new JTextArea(), selected_columns); columnsList.addListSelectionListener(listSelectionListener); columnsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); columnsList.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if (isSelectedIndex(index0)) super.removeSelectionInterval(index0, index1); else super.addSelectionInterval(index0, index1); } }); }
From source file:de.codesourcery.gittimelapse.MyFrame.java
public MyFrame(File file, GitHelper gitHelper) throws RevisionSyntaxException, MissingObjectException, IncorrectObjectTypeException, AmbiguousObjectException, IOException, GitAPIException { super("GIT timelapse: " + file.getAbsolutePath()); if (gitHelper == null) { throw new IllegalArgumentException("gitHelper must not be NULL"); }/*from www .j av a 2 s . co m*/ this.gitHelper = gitHelper; this.file = file; this.diffPanel = new DiffPanel(); final JDialog dialog = new JDialog((Frame) null, "Please wait...", false); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add(new JLabel("Please wait, locating revisions..."), BorderLayout.CENTER); dialog.pack(); dialog.setVisible(true); final IProgressCallback callback = new IProgressCallback() { @Override public void foundCommit(ObjectId commitId) { System.out.println("*** Found commit " + commitId); } }; System.out.println("Locating commits..."); commitList = gitHelper.findCommits(file, callback); dialog.setVisible(false); if (commitList.isEmpty()) { throw new RuntimeException("Found no commits"); } setMenuBar(createMenuBar()); diffModeChooser.setModel(new DefaultComboBoxModel<MyFrame.DiffDisplayMode>(DiffDisplayMode.values())); diffModeChooser.setSelectedItem(DiffDisplayMode.ALIGN_CHANGES); diffModeChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1); try { diffPanel.showRevision(commit); } catch (IOException | PatchApplyException e1) { e1.printStackTrace(); } } }); diffModeChooser.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); DiffDisplayMode mode = (DiffDisplayMode) value; switch (mode) { case ALIGN_CHANGES: setText("Align changes"); break; case REGULAR: setText("Regular"); break; default: setText(mode.toString()); } return result; } }); revisionSlider = new JSlider(1, commitList.size()); revisionSlider.setPaintLabels(true); revisionSlider.setPaintTicks(true); addKeyListener(keyListener); getContentPane().addKeyListener(keyListener); if (commitList.size() < 10) { revisionSlider.setMajorTickSpacing(1); revisionSlider.setMinorTickSpacing(1); } else { revisionSlider.setMajorTickSpacing(5); revisionSlider.setMinorTickSpacing(1); } final ObjectId latestCommit = commitList.getLatestCommit(); if (latestCommit != null) { revisionSlider.setValue(1 + commitList.indexOf(latestCommit)); revisionSlider.setToolTipText(latestCommit.getName()); } revisionSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (!revisionSlider.getValueIsAdjusting()) { final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1); long time = -System.currentTimeMillis(); try { diffPanel.showRevision(commit); } catch (IOException | PatchApplyException e1) { e1.printStackTrace(); } finally { time += System.currentTimeMillis(); } if (Main.DEBUG_MODE) { System.out.println("Rendering time: " + time); } } } }); getContentPane().setLayout(new GridBagLayout()); GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.gridx = 0; cnstrs.gridy = 0; cnstrs.gridwidth = 1; cnstrs.gridheight = 1; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.fill = GridBagConstraints.NONE; getContentPane().add(new JLabel("Diff display mode:"), cnstrs); cnstrs = new GridBagConstraints(); cnstrs.gridx = 1; cnstrs.gridy = 0; cnstrs.gridwidth = 1; cnstrs.gridheight = 1; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.fill = GridBagConstraints.NONE; getContentPane().add(diffModeChooser, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.gridx = 2; cnstrs.gridy = 0; cnstrs.gridwidth = 1; cnstrs.gridheight = 1; cnstrs.weightx = 1.0; cnstrs.weighty = 0; cnstrs.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(revisionSlider, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.gridx = 0; cnstrs.gridy = 1; cnstrs.gridwidth = 3; cnstrs.gridheight = 1; cnstrs.weightx = 1; cnstrs.weighty = 1; cnstrs.fill = GridBagConstraints.BOTH; getContentPane().add(diffPanel, cnstrs); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (latestCommit != null) { diffPanel.showRevision(latestCommit); } }