Hi All,
Has anybody came across the bug 4260595(Please go to Sun Java BugDB).The status says closed and Fixed but I am getting the same problem.Any Ideas.
But any how I am copying the while Bug and pasting i here for your convenience
Bug Id 4260595
Votes 0
Synopsis setLabelFor on JLabel component fails [mnemonic key disp'ing prob<-]
Category java:classes_swing
Reported Against 1.1.7
Release Fixed kestrel
State Closed, fixed
Related Bugs
Submit Date Aug 06, 1999
Description
/*
the [original code below] causes the combo box to grab the focus if you use
the key sequence alt+c. This works great, unless you keep holding the 'c' key
after leting go of the 'alt' key. If this is the case the focus jumps to the
JLabel component and not to the combo box as expected(desired). I verified
this
using the Swing acessability classes...
This is a serious problem for me, this ccmakes keyboard navigation very
tricky...
I am using swing 1.1 and JDK 1.1.7 under winNT 4 +SP3
David Tucker
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyLabel extends JLabel {
public MyLabel(String text) {
super(text);
}
public boolean isFocusTraversable() {
return false;
}
}
public class Blah extends JFrame implements ActionListener {
JComboBox ColName_LBox;
MyLabel tLabel;
public void setVisible(boolean willShow) {
super.setVisible(willShow);
ColName_LBox.requestFocus();
}
public Blah() {
super("naturalthing");
//Add a combo box
ColName_LBox = new JComboBox(
new String[] {
"blah", "DEE", "BLAHBLAH" } );
// ColName_LBox.addItemListener( (ItemListener) this );
//Listener is not important
//Add a JLable
tLabel = new MyLabel("BPANEL_COLLEC");
//Asociate it to Combo Box
tLabel.setLabelFor(ColName_LBox);
//Give it a Key Mnemonic
tLabel.setDisplayedMnemonic(java.awt.event.KeyEvent.VK_C);
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
p.add(tLabel, BorderLayout.NORTH);
p.add(ColName_LBox, BorderLayout.CENTER);
setContentPane(p);
pack();
}
public void actionPerformed(ActionEvent e) {
System.out.println("event e = " + e);
}
public static void main(String[] args) {
Blah f = new Blah();
f.setLocation(300,300);
f.setVisible(true);
}
}
--------- "test case" as originally submitted:
---------------------------------
//Add a combo box
ColName_LBox = new JComboBox(CItems);
ColName_LBox.addItemListener( this ); //Listener is not important
//Add a JLable
tLabel = new JLabel(sRes.getString("BPANEL_COLLEC"));
//Asociate it to Combo Box
tLabel.setLabelFor(ColName_LBox);
//Give it a Key Mnemonic
tLabel.setDisplayedMnemonic(java.awt.event.KeyEvent.VK_C);
the above code causes the combo box to grab the focus if you use
the key sequence alt+c. This works great, unless you keep holding the 'c' key
after leting go of the 'alt' key. If this is the case the focus jumps to the
JLabel component and not to the combo box as expected(desired). I verified
this using the Swing acessability classes...
This is a serious problem for me, this makes keyboard navigation very
tricky...
I am using swing 1.1 and JDK 1.1.7 under winNT 4 +SP3
David Tucker
(Review ID: 54817)
webbug
Workaround None.
Evaluation Lynn -- I kind of consider the labelFor property accessibilities baby. Can
you take a look at this? If you think that I'm misassigned it to you, please
pass it back.
xxxxx@xxxxx 1999-09-19
Should be fixed for kestrel.
xxxxx@xxxxx 1999-10-08
Your Comments & Work-arounds
Include a link with my name & email
THU DEC 26 01:46 A.M. 2002
Is this bug Fixed.The status says "Closed, fixed" but I am
getting the same problem in JDK1.3 and 1.4.1 also.I am having
a serious problem because of this.
Thanks in advance,
Jana