Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RequestFocus between two frames

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have jframe A with a JPanel pA . When the user selects an item in a list on pA, frame B must open, but the focus must remain on pA.

I have tried this

//in constructor
setRequestFocusEnabled(true); //on the pA

//in list select method
st.openScreen(); //opens the other frame
this.requestFocus(); //this is the pA

Why does the focus not go back to the pA?

Cheers,
Rachel
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that focus is not necessarily the same concept as being at the front of your screen in your windowing system. That is, I think your panel can have focus even if it's not visible on your screen. (I think!)

What does have the focus ?
What version of jdk are you using ? (the focus subsystem changed loads in 1.4)

hth, D
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Don

I'm using jdk 1.4.1_01 at the moment.

When the user clicks on the item in the list, the new frame pops up and it has the focus. (It's window is highlighted). Now, I want the frame that has the list inside to be highlighted instead.

This is because below the list is a jtable which I'm wanting to edit. If the user clicks on the list and then on the table, he has to click twice on the table to be able to edit. The first click highlights that frame and the second click activates the edit in the table.

I hope that makes sense. It's kind of late on a friday and I'm feeling a little sunburnt so I might not be explaining very well today.


Cheers,
Rachel
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned which Window is at front is different from focus.

You could try JFrame.toFront() - it's not guarenteed to work though, depends on your platform.


I hope that makes sense. It's kind of late on a friday and I'm feeling a little sunburnt so I might not be explaining very well today.


Sounds like beer oclock to me...
D.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Don - that toFront() works like a charm!

Cheers,
Rachel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!