Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages
Started by prunesquallor
Tue, 09 Aug 2005 13:28
Inconsistent Masking in JFormattedTextField?
Author: prunesquallor
Date: Tue, 09 Aug 2005 13:28
Date: Tue, 09 Aug 2005 13:28
58 lines
3468 bytes
3468 bytes
Is this a bug or am I missing something? I did the following in JB2005:
1. Created a simple application with just a content pane.
2. Added a JFormattedTextField with a mask. Code looks as so:
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(400, 300));
setTitle("Field Problem");
MaskFormatter msk = new MaskFormatter("#");
JFormattedTextField jFormattedTextField1 = new
JFormattedTextField(msk);
jFormattedTextField1.setFont(new java.awt.Font("SansSerif",
Font.BOLD,28));
jFormattedTextField1.setText("0");
jFormattedTextField1.setBounds(new Rectangle(142, 119, 60, 30));
contentPane.add(jFormattedTextField1);
}
3. Ran the above. Application worked, with a largeish field that only allows
one number to be entered.
4. Added a second field - code looks as so:
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(400, 300));
setTitle("Field Problem");
MaskFormatter msk = new MaskFormatter("#");
JFormattedTextField jFormattedTextField1 = new
JFormattedTextField(msk);
jFormattedTextField1.setFont(new java.awt.Font("SansSerif",
Font.BOLD,28));
jFormattedTextField1.setText("0");
jFormattedTextField1.setBounds(new Rectangle(142, 119, 60, 30));
contentPane.add(jFormattedTextField1);
JFormattedTextField jFormattedTextField2 = new
JFormattedTextField(msk);
jFormattedTextField2.setFont(new java.awt.Font("SansSerif",
Font.BOLD,28));
jFormattedTextField2.setText("0");
jFormattedTextField2.setBounds(new Rectangle(1, 1, 60, 30));
contentPane.add(jFormattedTextField2);
}
5. System now places me on the jFormattedTextField2 when I run the
application. If I immediately tab to the other field, and start entering
data, then the mask is completely ignored in the other field
(jFormattedTextField1). If I the exit and return to the field, the mask
suddenly starts working!
Am I doing something completely dumb? Note that this came up because I was
trying to set up an array of jFormattedTextFields, and found that the masks
were inconsistently applied!
ATB
John B
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads