Search in sources :

Example 1 with ValidatingDocument

use of com.servoy.j2db.util.docvalidator.ValidatingDocument in project servoy-client by Servoy.

the class InputDialog method init.

private void init(int maxlength, int identType) {
    getContentPane().setLayout(new BorderLayout());
    field = new JTextField();
    if (maxlength == 0) {
        field.setDocument(new ValidatingDocument(new IdentDocumentValidator(identType)));
    } else {
        field.setDocument(new ValidatingDocument(new ValidatingDocument.IDocumentValidator[] { new IdentDocumentValidator(identType), new LengthDocumentValidator(maxlength) }));
    }
    JPanel pane = new JPanel();
    pane.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    msg = new JLabel();
    msg.setHorizontalAlignment(SwingConstants.LEFT);
    msg.setAlignmentX(Component.LEFT_ALIGNMENT);
    msg.setPreferredSize(new Dimension(170, 15));
    pane.add(msg);
    pane.add(Box.createRigidArea(new Dimension(0, J2DBClient.BUTTON_SPACING)));
    field.setAlignmentX(Component.LEFT_ALIGNMENT);
    pane.add(field);
    // msg.setSize(field.getPreferredSize());
    getContentPane().add(pane, BorderLayout.CENTER);
    // $NON-NLS-1$
    JButton setButton = new JButton(Messages.getString("servoy.button.ok"));
    setButton.addActionListener(this);
    // $NON-NLS-1$
    setButton.setActionCommand("ok");
    // $NON-NLS-1$
    JButton cancelButton = new JButton(Messages.getString("servoy.button.cancel"));
    cancelButton.addActionListener(this);
    // $NON-NLS-1$
    cancelButton.setActionCommand("cancel");
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(setButton);
    buttonPane.add(Box.createRigidArea(new Dimension(J2DBClient.BUTTON_SPACING, 0)));
    buttonPane.add(cancelButton);
    buttonPane.setPreferredSize(new Dimension(300, 50));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    getRootPane().setDefaultButton(setButton);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ValidatingDocument(com.servoy.j2db.util.docvalidator.ValidatingDocument) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) LengthDocumentValidator(com.servoy.j2db.util.docvalidator.LengthDocumentValidator) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) IdentDocumentValidator(com.servoy.j2db.util.docvalidator.IdentDocumentValidator)

Example 2 with ValidatingDocument

use of com.servoy.j2db.util.docvalidator.ValidatingDocument in project servoy-client by Servoy.

the class NumberField method setAllowNegativeValues.

public void setAllowNegativeValues(boolean b) {
    ValidatingDocument doc = (ValidatingDocument) getDocument();
    ((NumberDocumentValidator) doc.getValidator(NUMBER_VALIDATOR_NAME)).setAllowNegativeValues(b);
}
Also used : NumberDocumentValidator(com.servoy.j2db.util.docvalidator.NumberDocumentValidator) ValidatingDocument(com.servoy.j2db.util.docvalidator.ValidatingDocument)

Example 3 with ValidatingDocument

use of com.servoy.j2db.util.docvalidator.ValidatingDocument in project servoy-client by Servoy.

the class NumberField method createDefaultModel.

protected Document createDefaultModel() {
    ValidatingDocument doc = new ValidatingDocument();
    doc.setValidator(NUMBER_VALIDATOR_NAME, new NumberDocumentValidator());
    return doc;
}
Also used : NumberDocumentValidator(com.servoy.j2db.util.docvalidator.NumberDocumentValidator) ValidatingDocument(com.servoy.j2db.util.docvalidator.ValidatingDocument)

Aggregations

ValidatingDocument (com.servoy.j2db.util.docvalidator.ValidatingDocument)3 NumberDocumentValidator (com.servoy.j2db.util.docvalidator.NumberDocumentValidator)2 IdentDocumentValidator (com.servoy.j2db.util.docvalidator.IdentDocumentValidator)1 LengthDocumentValidator (com.servoy.j2db.util.docvalidator.LengthDocumentValidator)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JTextField (javax.swing.JTextField)1