Search in sources :

Example 56 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class VolumeSurfaceCalculatorPanel method initialize.

private void initialize() {
    volumeSurfaceCalculatorPanel = new VolSurfCalcCondensedPanel();
    // volumeSurfaceCalculatorPanel.setBorder(new JScrollPane().getBorder());
    // volumeSurfaceCalculatorPanel.setLayout(new GridBagLayout());
    // 
    // int gridy = 0;
    java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
    DefaultComboBoxModel dcb = (DefaultComboBoxModel<String>) volumeSurfaceCalculatorPanel.getShapeComboBox().getModel();
    dcb.addElement(SHAPE_SPHERE);
    dcb.addElement(SHAPE_HEMISPHERE);
    dcb.addElement(SHAPE_CYLINDER);
    dcb.addElement(SHAPE_CONE);
    dcb.addElement(SHAPE_CUBE);
    dcb.addElement(SHAPE_BOX);
    volumeSurfaceCalculatorPanel.getShapeComboBox().setSelectedIndex(-1);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 0.0 };
    gridBagLayout.rowWeights = new double[] { 0.0 };
    setLayout(gridBagLayout);
    // gbc.gridx = 0;
    // gbc.gridy = gridy;
    // gbc.anchor = GridBagConstraints.LINE_END;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // volumeSurfaceCalculatorPanel.add(new JLabel("Shape"), gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 1;
    // gbc.gridy = gridy;
    // gbc.weightx = 0.5;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // shapeComboBox = new JComboBox();
    // shapeComboBox.setModel(dcb);
    // volumeSurfaceCalculatorPanel.add(shapeComboBox, gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 2;
    // gbc.gridy = gridy;
    // gbc.gridheight = 3;
    // gbc.fill = GridBagConstraints.VERTICAL;
    // JPanel panel = new JPanel();
    // panel.setLayout(new GridBagLayout());
    // GridBagConstraints gbc1 = new GridBagConstraints();
    // gbc1.gridx = 0;
    // gbc1.gridy = 0;
    // gbc1.weighty = 1.0;
    // calculateButton = new JButton("Go >>");
    // calculateButton.setBorder(BorderFactory.createEmptyBorder(4,4,4,4));
    // panel.add(calculateButton, gbc1);
    // volumeSurfaceCalculatorPanel.add(panel, gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 3;
    // gbc.gridy = gridy;
    // gbc.anchor = GridBagConstraints.LINE_END;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // volumeSurfaceCalculatorPanel.add(new JLabel("Volume"), gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 4;
    // gbc.gridy = gridy;
    // gbc.weightx = 0.5;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.insets = new java.awt.Insets(4, 4, 0, 4);
    // volumeTextField = new JTextField(20);
    // volumeTextField.setEditable(false);
    // volumeSurfaceCalculatorPanel.add(volumeTextField, gbc);
    // 
    // //
    // gridy ++;
    // volumeFormulaLabel = new JLabel();
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 4;
    // gbc.gridy = gridy;
    // gbc.weightx = 1.0;
    // gbc.anchor = GridBagConstraints.PAGE_START;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.insets = new java.awt.Insets(0, 4, 4, 4);
    // volumeSurfaceCalculatorPanel.add(volumeFormulaLabel, gbc);
    // 
    // //
    // gridy ++;
    // attrLabel = new JLabel("r ");
    // java.awt.Font font = attrLabel.getFont();
    // attrLabel.setFont(font.deriveFont(Font.ITALIC + Font.BOLD));
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 0; gbc.gridy = gridy;
    // gbc.anchor = GridBagConstraints.LINE_END;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // volumeSurfaceCalculatorPanel.add(attrLabel, gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 1;
    // gbc.gridy = gridy;
    // gbc.weightx = 0.5;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // attrTextField = new JTextField(20);
    // volumeSurfaceCalculatorPanel.add(attrTextField, gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 3;
    // gbc.gridy = gridy;
    // gbc.anchor = GridBagConstraints.LINE_END;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // volumeSurfaceCalculatorPanel.add(new JLabel("Surface"), gbc);
    // 
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 4;
    // gbc.gridy = gridy;
    // gbc.weightx = 0.5;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.insets = new java.awt.Insets(4, 4, 0, 4);
    // surfaceTextField = new JTextField(20);
    // surfaceTextField.setEditable(false);
    // volumeSurfaceCalculatorPanel.add(surfaceTextField, gbc);
    // 
    // //
    // gridy ++;
    // surfaceFormulaLabel = new JLabel();
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 4;
    // gbc.gridy = gridy;
    // gbc.weightx = 1.0;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.insets = new java.awt.Insets(0, 4, 4, 4);
    // volumeSurfaceCalculatorPanel.add(surfaceFormulaLabel, gbc);
    // 
    // 
    // setLayout(new GridBagLayout());
    // 
    // volumeSurfaceCalculatorLabel = new JLabel("<html><font color=blue><u>Volume and Surface Calculator &gt;&gt;</u></font></html>");
    // volumeSurfaceCalculatorLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    // gbc = new java.awt.GridBagConstraints();
    // gbc.gridx = 0;
    // gbc.gridy = 0;
    // gbc.weightx = 1.0;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    // gbc.anchor = GridBagConstraints.LINE_END;
    // gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    // add(volumeSurfaceCalculatorLabel, gbc);
    // 
    gbc_1 = new java.awt.GridBagConstraints();
    gbc_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_1.weightx = 1.0;
    gbc_1.gridx = 1;
    gbc_1.gridy = 0;
    gbc_1.insets = new java.awt.Insets(4, 4, 4, 4);
    chckbxNewCheckBox = new JCheckBox("Volume/Surface Calculator");
    chckbxNewCheckBox.setForeground(Color.BLUE);
    chckbxNewCheckBox.setFont(new Font("Tahoma", Font.PLAIN, 9));
    chckbxNewCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            volumeSurfaceCalculatorPanel.setVisible(chckbxNewCheckBox.isSelected());
        }
    });
    GridBagConstraints gbc_chckbxNewCheckBox = new GridBagConstraints();
    gbc_chckbxNewCheckBox.gridx = 0;
    gbc_chckbxNewCheckBox.gridy = 0;
    add(chckbxNewCheckBox, gbc_chckbxNewCheckBox);
    GridBagConstraints gbc_volumeSurfaceCalculatorPanel = new GridBagConstraints();
    gbc_volumeSurfaceCalculatorPanel.insets = new Insets(0, 0, 0, 4);
    gbc_volumeSurfaceCalculatorPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_volumeSurfaceCalculatorPanel.weightx = 1.0;
    gbc_volumeSurfaceCalculatorPanel.gridx = 1;
    gbc_volumeSurfaceCalculatorPanel.gridy = 0;
    add(volumeSurfaceCalculatorPanel, gbc_volumeSurfaceCalculatorPanel);
    volumeSurfaceCalculatorPanel.setVisible(false);
    // 
    // volumeSurfaceCalculatorPanel.setVisible(false);
    // shapeComboBox.setSelectedIndex(-1);
    initConnections();
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) GridBagConstraints(java.awt.GridBagConstraints) Font(java.awt.Font) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener)

Example 57 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project vcell by virtualcell.

the class StructurePasteMappingPanel method initialize.

private void initialize() {
    Structure structFrom = rsCopy.getFromStructure();
    List<String> membranesTo = new ArrayList<>();
    List<String> compartmentsTo = new ArrayList<>();
    membranesTo.add(CHOOSE_STRUCT);
    membranesTo.add(MAKE_NEW);
    compartmentsTo.add(CHOOSE_STRUCT);
    compartmentsTo.add(MAKE_NEW);
    for (Structure struct : modelTo.getStructures()) {
        if (struct == structTo) {
            continue;
        }
        if (struct instanceof Membrane) {
            membranesTo.add(struct.getName());
        } else {
            compartmentsTo.add(struct.getName());
        }
    }
    for (Structure from : rsCopy.getStructuresArr()) {
        if (from == structFrom) {
            // skip the structure from where we copy, it's already mapped
            continue;
        }
        JComboBox<String> comboTo = new JComboBox<>();
        if (from instanceof Membrane) {
            comboTo.setModel(new DefaultComboBoxModel(membranesTo.toArray()));
            int index = membranesTo.indexOf(from.getName());
            comboTo.setSelectedIndex(index >= 0 ? index : 0);
        } else {
            comboTo.setModel(new DefaultComboBoxModel(compartmentsTo.toArray()));
            int index = compartmentsTo.indexOf(from.getName());
            comboTo.setSelectedIndex(index >= 0 ? index : 0);
        }
        structureMap.put(from, comboTo);
        comboTo.addActionListener(eventHandler);
    }
    JPanel structPanel = new JPanel();
    // structPanel.setPreferredSize(new Dimension(220, 180));
    structPanel.setLayout(new GridBagLayout());
    // header
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    // top, left, bottom, right
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    structPanel.add(new JLabel("<html><b>Structures to Paste</b></html>"), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    // gbc.fill = GridBagConstraints.HORIZONTAL;
    structPanel.add(new JLabel("<html><b>Mapped to: </b></html>"), gbc);
    // the first row shows the source and destination structures (not customizable)
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(1, 10, 1, 10);
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    structPanel.add(new JLabel("<html>" + structFrom.getName() + "</html>"), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.insets = new Insets(1, 12, 1, 10);
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    structPanel.add(new JLabel("<html>" + structTo.getName() + "</html>"), gbc);
    for (Map.Entry<Structure, JComboBox<String>> entry : structureMap.entrySet()) {
        // the first row shows the source and destination structures (not customizable)
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.insets = new Insets(1, 10, 2, 10);
        gbc.weightx = 1;
        gbc.anchor = GridBagConstraints.WEST;
        structPanel.add(new JLabel("<html>" + entry.getKey().getName() + "</html>"), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.insets = new Insets(2, 10, 1, 10);
        gbc.weightx = 1;
        gbc.anchor = GridBagConstraints.WEST;
        structPanel.add(entry.getValue(), gbc);
    }
    gridy++;
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 4;
    gbc.weightx = 1;
    // fake cell used for filling all the vertical empty space
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;
    structPanel.add(new JLabel(""), gbc);
    // JPanel issuesPanel = new JPanel();
    // issuesPanel.setLayout(new BorderLayout());
    // issuesPanel.add(issuesPane, BorderLayout.CENTER);
    JScrollPane upper = new JScrollPane(structPanel);
    upper.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    upper.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JScrollPane lower = new JScrollPane(issuesPane);
    lower.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    lower.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    setLayout(new BorderLayout());
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, lower);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);
    add(splitPane, BorderLayout.CENTER);
    recalculateIssues();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JComboBox(javax.swing.JComboBox) GridBagLayout(java.awt.GridBagLayout) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) BorderLayout(java.awt.BorderLayout) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) JSplitPane(javax.swing.JSplitPane) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 58 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project jgnash by ccavanaugh.

the class InvestmentTransactionPanel method initComponents.

private void initComponents() {
    actionCombo = new JComboBox<>(new DefaultComboBoxModel<>(actions));
    cardPanel = new JPanel();
    cardPanel.setLayout(new CardLayout());
    enterButton = new JButton(rb.getString("Button.Enter"));
    cancelButton = new JButton(rb.getString("Button.Cancel"));
    cancelButton.addActionListener(this);
    enterButton.addActionListener(this);
    actionCombo.addActionListener(this);
}
Also used : JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) JButton(javax.swing.JButton) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 59 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project gephi by gephi.

the class DataTableTopComponent method refreshFilterColumns.

private void refreshFilterColumns() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            ArrayList columns = new ArrayList();
            if (isShowingNodesTable()) {
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                for (int i = 0; i < nodeTable.getTable().getColumnCount(); i++) {
                    if (nodeTable.getTable().getColumnExt(i).isVisible()) {
                        model.addElement(nodeTable.getTable().getColumnExt(i).getTitle());
                        columns.add(nodeTable.getTable().getColumnExt(i).getTitle());
                    }
                }
                columnComboBox.setModel(model);
                Integer previousNodeColumnsFilterIndex = filterColumnIndexByDisplayTable.get(DisplayTable.NODE);
                if (columns.equals(previousNodeFilterColumns) && previousNodeColumnsFilterIndex != null && previousNodeColumnsFilterIndex < columnComboBox.getItemCount()) {
                    //Preserve user selected column when the columns list does not change
                    columnComboBox.setSelectedIndex(previousNodeColumnsFilterIndex);
                }
                previousNodeFilterColumns = columns;
            } else if (isShowingEdgesTable()) {
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                for (int i = 0; i < edgeTable.getTable().getColumnCount(); i++) {
                    if (edgeTable.getTable().getColumnExt(i).isVisible()) {
                        model.addElement(edgeTable.getTable().getColumnExt(i).getTitle());
                        columns.add(edgeTable.getTable().getColumnExt(i).getTitle());
                    }
                }
                columnComboBox.setModel(model);
                Integer previousEdgeColumnsFilterIndex = filterColumnIndexByDisplayTable.get(DisplayTable.EDGE);
                if (columns.equals(previousEdgeFilterColumns) && previousEdgeColumnsFilterIndex != null && previousEdgeColumnsFilterIndex < columnComboBox.getItemCount()) {
                    //Preserve user selected column when the columns list does not change
                    columnComboBox.setSelectedIndex(previousEdgeColumnsFilterIndex);
                }
                previousEdgeFilterColumns = columns;
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 60 with DefaultComboBoxModel

use of javax.swing.DefaultComboBoxModel in project gephi by gephi.

the class ReportPanel method initMergeStrategyCombo.

private void initMergeStrategyCombo() {
    DefaultComboBoxModel mergeStrategryModel = new DefaultComboBoxModel(new String[] { NbBundle.getMessage(ReportPanel.class, "ReportPanel.mergeStrategy.sum"), NbBundle.getMessage(ReportPanel.class, "ReportPanel.mergeStrategy.avg"), NbBundle.getMessage(ReportPanel.class, "ReportPanel.mergeStrategy.min"), NbBundle.getMessage(ReportPanel.class, "ReportPanel.mergeStrategy.max") });
    edgesMergeStrategyCombo.setModel(mergeStrategryModel);
}
Also used : DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)119 JComboBox (javax.swing.JComboBox)22 JPanel (javax.swing.JPanel)21 JLabel (javax.swing.JLabel)17 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 JButton (javax.swing.JButton)15 Insets (java.awt.Insets)14 GridBagConstraints (java.awt.GridBagConstraints)13 GridBagLayout (java.awt.GridBagLayout)12 Dimension (java.awt.Dimension)11 JTextField (javax.swing.JTextField)11 JCheckBox (javax.swing.JCheckBox)10 JScrollPane (javax.swing.JScrollPane)10 ArrayList (java.util.ArrayList)9 Vector (java.util.Vector)9 JList (javax.swing.JList)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 BorderLayout (java.awt.BorderLayout)8 ItemEvent (java.awt.event.ItemEvent)8