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