Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

Eureka Jana

Greenhorn
+ Follow
since Sep 04, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eureka Jana

Hi All,
Normally when we press CTRL+TAB, the focus goes to the next focusable component in the Frame/Window. This has been taken care by FocusManager(jdk1.3.1). But I want to perform some other work when we press CTRL+TAB(I don't want to move the focus to the next component-inshort I don't want the FocusManager to handle that). This I can do by attaching a key listener to the component. But the problem is FocusManager consumes the event and hence my listeners won't get that KeyEvent.
So anybody know how to do that.
Thanks in advance,
Jana
19 years ago
Hi All,
Normally when we press CTRL+TAB, the focus goes to the next focusable component in the Frame/Window. This has been taken care by FocusManager(jdk1.3.1). But I want to perform some other work when we press CTRL+TAB(I don't want to move the focus to the next component-inshort I don't want the FocusManager to handle that). This I can do by attaching a key listener to the component. But the problem is FocusManager consumes the event and hence my listeners won't get that KeyEvent.
So anybody know how to do that.
Thanks in advance,
Jana
19 years ago
I have a paint method for a component in Swing.
I want to make the clip region in the Graphics object of the paint method to be some what larger than the original clipping region. I am using the following lines of code.
Rectangle old = g.getClip();
Rectangle clip = g.getClipBounds();
g.setClip(clip.x, clip.y, clip.width + 20, clip.height + 20);
clip = g.getClipBounds();
g.drawLine(clip.x, clip.y, clip.width, clip.height);
g.setClip(old);
But it seems that it is not working. I am not able to see the line in the new clipping region. The line appears in the old clipping region. What may be the reason.
Thanks,
Jana
19 years ago
I have a paint method for a component in Swing.
I want to make the clip region in the Graphics object of the paint method to be some what larger than the original clipping region. I am using the following lines of code.
Rectangle old = g.getClip();
Rectangle clip = g.getClipBounds();
g.setClip(clip.x, clip.y, clip.width + 20, clip.height + 20);
clip = g.getClipBounds();
g.drawLine(clip.x, clip.y, clip.width, clip.height);
g.setClip(old);
But it seems that it is not working. I am not able to see the line in the new clipping region. The line appears in the old clipping region. What may be the reason.
Thanks,
Jana
19 years ago
I have a paint method for a component in Swing.
I want to make the clip region in the Graphics object of the paint method to be some what larger than the original clipping region. I am using the following lines of code.
Rectangle old = g.getClip();
Rectangle clip = g.getClipBounds();
g.setClip(clip.x, clip.y, clip.width + 20, clip.height + 20);
clip = g.getClipBounds();
g.drawLine(clip.x, clip.y, clip.width, clip.height);
g.setClip(old);
But it seems that it is not working. I am not able to see the line in the new clipping region. The line appears in the old clipping region. What may be the reason.
Thanks,
Jana
19 years ago
Hi Java Gurus,
How do I setup automated tests to test my Swing GUI application? What are the
automated GUI testing applications that you can recommend?
19 years ago
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
19 years ago
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
19 years ago
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

19 years ago
Hi Preetham,
Methods declared as static has some restrictions.
1.It can call only other static methods
2.It can only access static data.
3.It cannot refer to this or super.
Thanks,
Jana
20 years ago
Hi,
Welcome.One thing I want to know, everybody is talking about sun certified cource.I actually joined here to learn java.What is that sun certified exam.is it really useful.how to apply and take exam.can I take it online.
Help me with this information.
Thanks,
Eureka
20 years ago
Hummmmmmm.....
Oh ho Actually I missed that by time constraint.I had a work here after I tried to reply.So I missed the train.
20 years ago
Ha Ha,
I am going to become the precedence king.I just now answered one question(Question about multiple assignments) regarding the precdence and yet again:
System.out.println("A1a is:" + (a==null));
Before that + has higher precedence than == so it concates a with "A1a is :" and then checks for null which is false.If you put the backet then it will work fine.
Got it,
Regards,
Jana
20 years ago
One thing comes to my mind is we can reduce the complexity by having one action listener for the entire toolbar.We can add anything to the toolbar like combobox, checkbox, image, etc.,Lets c what are all the benefits from others,
Thanks,Looking forward,
Jana
20 years ago
Hi,
Yah what you expected is correct, but it is not like that.See the operators precedence.
Higher :[]
Lower: =
So first a[i] gets evaluated and the assignment from right to left.
I would like to convey one message to all.Since we are all beginners, the basic thing in learning any language is to make sure we are well aware of "Operators Precedence".That solves many problems.
Thanks,
Jana
20 years ago