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;
}
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();
}
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();
}
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();
}
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;
}
}
Aggregations