use of javax.swing.event.DocumentListener in project vcell by virtualcell.
the class EditConstraintsPanel method initialize.
private void initialize() {
try {
setName("EditConstraintsPanel");
setLayout(new GridBagLayout());
maxIterationTextField = new JTextField();
maxMolTextField = new JTextField();
maxIterationTextField.addActionListener(eventHandler);
maxMolTextField.addActionListener(eventHandler);
maxIterationTextField.addFocusListener(eventHandler);
maxMolTextField.addFocusListener(eventHandler);
maxIterationTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
if (isChanged()) {
getApplyButton().setEnabled(true);
} else {
getApplyButton().setEnabled(false);
}
}
public void removeUpdate(DocumentEvent e) {
if (isChanged()) {
getApplyButton().setEnabled(true);
} else {
getApplyButton().setEnabled(false);
}
}
public void insertUpdate(DocumentEvent e) {
if (isChanged()) {
getApplyButton().setEnabled(true);
} else {
getApplyButton().setEnabled(false);
}
}
public boolean isChanged() {
NetworkConstraints nc = owner.getSimulationContext().getNetworkConstraints();
String s1 = maxIterationTextField.getText();
String s2 = nc.getMaxIteration() + "";
if (!s1.equals(s2)) {
return true;
}
return false;
}
});
maxMolTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
if (isChanged()) {
getApplyButton().setEnabled(true);
} else {
getApplyButton().setEnabled(false);
}
}
public void removeUpdate(DocumentEvent e) {
if (isChanged()) {
getApplyButton().setEnabled(true);
} else {
getApplyButton().setEnabled(false);
}
}
public void insertUpdate(DocumentEvent e) {
if (isChanged()) {
getApplyButton().setEnabled(true);
} else {
getApplyButton().setEnabled(false);
}
}
public boolean isChanged() {
NetworkConstraints nc = owner.getSimulationContext().getNetworkConstraints();
String s1 = maxMolTextField.getText();
String s2 = nc.getMaxMoleculesPerSpecies() + "";
if (!s1.equals(s2)) {
return true;
}
return false;
}
});
int gridy = 0;
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
// top, left, bottom, right
gbc.insets = new Insets(6, 8, 0, 0);
add(new JLabel("Max. Iterations"), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets(6, 0, 0, 10);
add(maxIterationTextField, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(0, 8, 6, 0);
add(new JLabel("Max. Molecules / Species"), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets(0, 0, 6, 10);
add(maxMolTextField, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(6, 8, 8, 2);
add(getRunButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(6, 2, 8, 2);
add(getApplyButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(6, 2, 8, 10);
add(getCancelButton(), gbc);
maxIterationTextField.setText(owner.getSimulationContext().getNetworkConstraints().getMaxIteration() + "");
maxMolTextField.setText(owner.getSimulationContext().getNetworkConstraints().getMaxMoleculesPerSpecies() + "");
getApplyButton().setEnabled(false);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of javax.swing.event.DocumentListener in project knime-core by knime.
the class DecimalSeparatorPanel method createEditPanel.
private JPanel createEditPanel() {
m_decSeparator.setColumns(5);
m_decSeparator.setPreferredSize(new Dimension(100, 25));
m_decSeparator.setMaximumSize(new Dimension(100, 25));
m_decSeparator.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(final DocumentEvent e) {
decSepChanged();
}
@Override
public void insertUpdate(final DocumentEvent e) {
decSepChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
decSepChanged();
}
});
JPanel editPanel = new JPanel();
editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.Y_AXIS));
Box editBox = Box.createHorizontalBox();
editBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, m_decSeparator.getMaximumSize().height));
editBox.add(new JLabel("Enter decimal separator character:"));
editBox.add(Box.createHorizontalStrut(5));
editBox.add(m_decSeparator);
editBox.add(Box.createHorizontalGlue());
editPanel.add(editBox);
return editPanel;
}
use of javax.swing.event.DocumentListener in project knime-core by knime.
the class MissingValuePanel method getPanel.
private Container getPanel() {
Box missValBox = Box.createHorizontalBox();
missValBox.add(Box.createHorizontalGlue());
missValBox.add(new JLabel("StringType missing value pattern:"));
missValBox.add(Box.createHorizontalStrut(5));
m_missingValue = new JTextField(15);
m_missingValue.setPreferredSize(new Dimension(150, 25));
m_missingValue.setMinimumSize(new Dimension(150, 25));
m_missingValue.setMaximumSize(new Dimension(150, 25));
missValBox.add(m_missingValue);
m_missingValue.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(final DocumentEvent e) {
updateWarnBox();
}
public void removeUpdate(final DocumentEvent e) {
updateWarnBox();
}
public void changedUpdate(final DocumentEvent e) {
updateWarnBox();
}
});
Box result = Box.createHorizontalBox();
result.add(Box.createHorizontalGlue());
result.add(missValBox);
result.add(Box.createHorizontalGlue());
return result;
}
use of javax.swing.event.DocumentListener in project knime-core by knime.
the class QuotePanel method getQEditField.
/**
* This method initializes qEditField.
*
* @return javax.swing.JTextField
*/
private JTextField getQEditField() {
if (m_qEditField == null) {
m_qEditField = new JTextField();
m_qEditField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(final DocumentEvent e) {
clearErrorText();
}
public void removeUpdate(final DocumentEvent e) {
clearErrorText();
}
public void insertUpdate(final DocumentEvent e) {
clearErrorText();
}
});
m_qEditField.setMinimumSize(new Dimension(100, 25));
m_qEditField.setMaximumSize(new Dimension(100, 25));
m_qEditField.setPreferredSize(new Dimension(100, 25));
}
return m_qEditField;
}
use of javax.swing.event.DocumentListener in project knime-core by knime.
the class LimitRowsPanel method getSkipPanel.
private Container getSkipPanel() {
m_skipLines = new JCheckBox("Skip the first");
m_skipNumber = new JTextField();
m_skipNumber.setColumns(6);
m_skipNumber.setPreferredSize(new Dimension(125, 25));
m_skipNumber.setMaximumSize(new Dimension(125, 25));
m_skipLines.setSelected(false);
m_skipNumber.setEnabled(false);
// make sure we always have a valid value. Reject invalid characters.
m_skipNumber.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(final DocumentEvent e) {
checkAndFixSkipCount();
}
@Override
public void insertUpdate(final DocumentEvent e) {
checkAndFixSkipCount();
}
@Override
public void changedUpdate(final DocumentEvent e) {
checkAndFixSkipCount();
}
});
m_skipNumber.addFocusListener(new FocusListener() {
@Override
public void focusLost(final FocusEvent e) {
if (m_skipNumber.getText().trim().length() == 0) {
// can't handle no empty strings.
m_lastValidSkips = "0";
m_skipNumber.setText(m_lastValidSkips);
}
}
@Override
public void focusGained(final FocusEvent e) {
}
});
m_skipLines.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
// en/disable the textfield
m_skipNumber.setEnabled(m_skipLines.isSelected());
// also - if the textfield is enabled and empty set a value
if (m_skipNumber.isEnabled()) {
if ((m_skipNumber.getText() == null) || (m_skipNumber.getText().trim().length() == 0)) {
// set a valid value, so we can safely assume that if there is a value in there it's always valid.
m_skipNumber.setText("0");
m_lastValidSkips = "0";
}
}
}
});
Box result = Box.createHorizontalBox();
result.add(m_skipLines);
result.add(Box.createHorizontalStrut(3));
result.add(m_skipNumber);
result.add(Box.createHorizontalStrut(3));
result.add(new JLabel("lines from the beginning of the file."));
result.add(Box.createHorizontalGlue());
return result;
}
Aggregations