Search in sources :

Example 31 with JFormattedTextField

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

the class MovingBoundarySolverOptionsPanel method getFrontTrackingPanel.

private JPanel getFrontTrackingPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(BorderFactory.createTitledBorder(GuiConstants.TAB_PANEL_BORDER, "Front Tracking"));
    int gridy = 0;
    GridBagConstraints gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Front To Volume Nodes Ratio"), gbc);
    textFieldFrontToNodeRatio = new JFormattedTextField(DecimalFormat.getInstance());
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    panel.add(textFieldFrontToNodeRatio, gbc);
    ++gridy;
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Front Redistribution Method"), gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    panel.add(comboBoxRedistMode, gbc);
    ++gridy;
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Full Redistribution Mode"), gbc);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    panel.add(comboBoxRedistVersion, gbc);
    ++gridy;
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    panel.add(new JLabel("Redistribution Frequency"), gbc);
    NumberFormatter integerFormatter = new NumberFormatter(NumberFormat.getInstance());
    integerFormatter.setValueClass(Integer.class);
    integerFormatter.setMinimum(1);
    integerFormatter.setMaximum(Integer.MAX_VALUE);
    textFieldRedistributionFrequency = new JFormattedTextField(integerFormatter);
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new java.awt.Insets(4, 4, 4, 4);
    textFieldRedistributionFrequency.setToolTipText("integer only");
    panel.add(textFieldRedistributionFrequency, gbc);
    comboBoxRedistMode.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            // TODO Auto-generated method stub
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (c instanceof JLabel) {
                JLabel lbl = (JLabel) c;
                lbl.setText(((RedistributionMode) value).getLabel());
            }
            return c;
        }
    });
    comboBoxRedistVersion.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            // TODO Auto-generated method stub
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (c instanceof JLabel) {
                JLabel lbl = (JLabel) c;
                lbl.setText(((RedistributionVersion) value).getLabel());
            }
            return c;
        }
    });
    comboBoxExtrapolationMethod.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            // TODO Auto-generated method stub
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (c instanceof JLabel) {
                JLabel lbl = (JLabel) c;
                lbl.setText(((ExtrapolationMethod) value).getLabel());
            }
            return c;
        }
    });
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) RedistributionMode(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionMode) GridBagLayout(java.awt.GridBagLayout) RedistributionVersion(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) GridBagConstraints(java.awt.GridBagConstraints) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) ExtrapolationMethod(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.ExtrapolationMethod) Component(java.awt.Component) NumberFormatter(javax.swing.text.NumberFormatter)

Example 32 with JFormattedTextField

use of javax.swing.JFormattedTextField in project smile by haifengl.

the class DoubleArrayCellEditor method stopCellEditing.

// Override to check whether the edit is valid,
// setting the value if it is and complaining if
// it isn't.  If it's OK for the editor to go
// away, we need to invoke the superclass's version 
// of this method so that everything gets cleaned up.
@Override
public boolean stopCellEditing() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    if (ftf.isEditValid()) {
        try {
            ftf.commitEdit();
        } catch (java.text.ParseException ex) {
        }
    } else {
        //text is invalid
        Toolkit.getDefaultToolkit().beep();
        textField.selectAll();
        //don't let the editor go away
        return false;
    }
    return super.stopCellEditing();
}
Also used : JFormattedTextField(javax.swing.JFormattedTextField) ParseException(java.text.ParseException)

Example 33 with JFormattedTextField

use of javax.swing.JFormattedTextField in project smile by haifengl.

the class DoubleCellEditor method stopCellEditing.

// Override to check whether the edit is valid,
// setting the value if it is and complaining if
// it isn't.  If it's OK for the editor to go
// away, we need to invoke the superclass's version 
// of this method so that everything gets cleaned up.
@Override
public boolean stopCellEditing() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    if (ftf.isEditValid()) {
        try {
            ftf.commitEdit();
        } catch (java.text.ParseException ex) {
        }
    } else {
        //text is invalid
        Toolkit.getDefaultToolkit().beep();
        textField.selectAll();
        //don't let the editor go away
        return false;
    }
    return super.stopCellEditing();
}
Also used : JFormattedTextField(javax.swing.JFormattedTextField) ParseException(java.text.ParseException)

Example 34 with JFormattedTextField

use of javax.swing.JFormattedTextField in project smile by haifengl.

the class IntegerArrayCellEditor method stopCellEditing.

// Override to check whether the edit is valid,
// setting the value if it is and complaining if
// it isn't.  If it's OK for the editor to go
// away, we need to invoke the superclass's version 
// of this method so that everything gets cleaned up.
@Override
public boolean stopCellEditing() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    if (ftf.isEditValid()) {
        try {
            ftf.commitEdit();
        } catch (java.text.ParseException ex) {
        }
    } else {
        //text is invalid
        Toolkit.getDefaultToolkit().beep();
        textField.selectAll();
        //don't let the editor go away
        return false;
    }
    return super.stopCellEditing();
}
Also used : JFormattedTextField(javax.swing.JFormattedTextField) ParseException(java.text.ParseException)

Example 35 with JFormattedTextField

use of javax.swing.JFormattedTextField in project smile by haifengl.

the class IntegerArrayCellEditor method getCellEditorValue.

@Override
public Object getCellEditorValue() {
    JFormattedTextField ftf = (JFormattedTextField) getComponent();
    Object o = ftf.getValue();
    if (o instanceof int[]) {
        return o;
    } else {
        LOGGER.log(Level.FINE, "getCellEditorValue: can't parse {0}", o);
        return null;
    }
}
Also used : JFormattedTextField(javax.swing.JFormattedTextField)

Aggregations

JFormattedTextField (javax.swing.JFormattedTextField)55 JLabel (javax.swing.JLabel)17 JPanel (javax.swing.JPanel)16 ParseException (java.text.ParseException)10 DecimalFormat (java.text.DecimalFormat)9 JButton (javax.swing.JButton)9 ActionListener (java.awt.event.ActionListener)8 NumberFormatter (javax.swing.text.NumberFormatter)8 ActionEvent (java.awt.event.ActionEvent)7 PropertyChangeEvent (java.beans.PropertyChangeEvent)7 JComboBox (javax.swing.JComboBox)7 Dimension (java.awt.Dimension)6 PropertyChangeListener (java.beans.PropertyChangeListener)6 GroupLayout (javax.swing.GroupLayout)6 Component (java.awt.Component)5 GridBagConstraints (java.awt.GridBagConstraints)5 GridBagLayout (java.awt.GridBagLayout)5 JCheckBox (javax.swing.JCheckBox)5 JScrollPane (javax.swing.JScrollPane)5 JSpinner (javax.swing.JSpinner)5