• Post Reply Bookmark Topic Watch Topic
  • New Topic

setLabelFor() not working URGENT

 
Eureka Jana
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's weird... I ran the code on JDK 1.4.1_01 on Win2K and it worked fine...
 
Eureka Jana
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nate,
Did u try that on jdk1.3.1
And in jdk1.4.1 also I am getting the problem.One thing I noticed is, in the previous code the mnemonic is not working it seems.I am not Sure.So try out this modified code pls.
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;
JLabel 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 JLabel("BPANEL_COLLEC");
//Asociate it to Combo Box
tLabel.setLabelFor(ColName_LBox);
//Give it a Key Mnemonic
tLabel.setDisplayedMnemonic('c');
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
p.add(tLabel, BorderLayout.NORTH);
p.add(ColName_LBox, BorderLayout.CENTER);
JButton b = new JButton("Ok");
b.setMnemonic('k');
p.add(b, BorderLayout.WEST);
JLabel l = new JLabel("Temp");
JTextField jtf = new JTextField(20);
l.setDisplayedMnemonic('m');
l.setLabelFor(jtf);
JPanel p1 = new JPanel();
p1.add(l, "North");
p1.add(jtf, "Center");
p.add(p1, "South");
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);
}
}
Thanks,
Jana
 
Eureka Jana
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see it again.I am posting so that every body will get noticed.Atleast try testing it and say whether the bug is fixed or not.
Thanks,
Jana
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!