Java Code Examples for javax.swing.text.PlainDocument#setDocumentFilter()
The following examples show how to use
javax.swing.text.PlainDocument#setDocumentFilter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextFieldDataBind.java From iec61850bean with Apache License 2.0 | 5 votes |
@Override protected JComponent init() { inputField = new JTextField(); PlainDocument doc = (PlainDocument) inputField.getDocument(); doc.setDocumentFilter(filter); resetImpl(); return inputField; }
Example 2
Source File: JTextFieldFactory.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public static JTextField createIntegerOnlyJTextField() { JTextField textField = new JFormattedTextField(); PlainDocument doc = (PlainDocument) textField.getDocument(); doc.setDocumentFilter(new DocumentIntFilter()); setTextFieldProperties(textField); return textField; }
Example 3
Source File: ClassNameTextField.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Document createDefaultModel() { PlainDocument doc = (PlainDocument) super.createDefaultModel(); doc.setDocumentFilter(new SpaceIgnoringDocumentFilter()); return doc; }
Example 4
Source File: PollIntervalDialog.java From sql-developer-keepalive with MIT License | 4 votes |
private void initDialog() { textField = new JTextField(20); PlainDocument doc = (PlainDocument) textField.getDocument(); doc.setDocumentFilter(new NumberFilter()); Object[] controls = { "Specify poll interval (in seconds):", textField }; Object[] options = { OK_STRING, CANCEL_STRING }; optionPane = new JOptionPane(controls, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); setContentPane(optionPane); addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent ce) { textField.requestFocusInWindow(); } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { if (isVisible() && JOptionPane.VALUE_PROPERTY.equals(e.getPropertyName())) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { return; } switch (value.toString()) { case OK_STRING: String v = textField.getText(); if (checkValue(v)) { pollInterval = Integer.parseInt(v, 10); setVisible(false); } else { //to let PropertyChangeEvent fire next time the user presses button optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); } break; case CANCEL_STRING: pollInterval = null; setVisible(false); break; } } } }); }