Hi everyone,
I read the info on: about masking a textfield. Unfortunately i didn't plan to mask the textfields beforehand so i created the textfields as such; The last 2 textfields(fields[3]and fields[4]) will have dates in them, In the database i created those as 'nvarchar'. Anyway how do i mask the textfield as that it accepts inputs like 'xx/xx/xxxx' only in the last 2 textfields...Is it possible to do this in this code; I made several attempts but it seems that Java hates me. And thats the end of my essay thanks for your time.
private void placeLabelsAndFields(String[] labels) {
int[] widths = {10, 15, 15, 15, 15};
fields = new JTextField[labels.length];
for (int i = 0; i < labels.length; i++) {
fields = new JTextField();
if (i < widths.length) {
fields.setColumns(widths);
}
JLabel lab = new JLabel(labels, JLabel.RIGHT);
lab.setLabelFor(fields);
labelPanel.add(lab);
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
if (i == labels.length - 1) {
isOnlineCheckbox = new JCheckBox();
p.add(isOnlineCheckbox);
} else {
p.add(fields);
}
fieldPanel.add(p);
}
}
Mille grazie
yigit
Don't just do something, stand there!
I read the info on: about masking a textfield. Unfortunately i didn't plan to mask the textfields beforehand so i created the textfields as such; The last 2 textfields(fields[3]and fields[4]) will have dates in them, In the database i created those as 'nvarchar'. Anyway how do i mask the textfield as that it accepts inputs like 'xx/xx/xxxx' only in the last 2 textfields...Is it possible to do this in this code; I made several attempts but it seems that Java hates me. And thats the end of my essay thanks for your time.
private void placeLabelsAndFields(String[] labels) {
int[] widths = {10, 15, 15, 15, 15};
fields = new JTextField[labels.length];
for (int i = 0; i < labels.length; i++) {
fields = new JTextField();
if (i < widths.length) {
fields.setColumns(widths);
}
JLabel lab = new JLabel(labels, JLabel.RIGHT);
lab.setLabelFor(fields);
labelPanel.add(lab);
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
if (i == labels.length - 1) {
isOnlineCheckbox = new JCheckBox();
p.add(isOnlineCheckbox);
} else {
p.add(fields);
}
fieldPanel.add(p);
}
}
Mille grazie
yigit
Don't just do something, stand there!