File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JInternalFrames and focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JInternalFrames and focus" Watch "JInternalFrames and focus" New topic
Author

JInternalFrames and focus

Chris Robertson
Greenhorn

Joined: Sep 19, 2002
Posts: 3
Hi all,
I've got a doozy, least I think it is hopefully there is an insanely simple fix.
Here is the setup. I have an application which contains a JTabbedPane with two tabs. The first tab is a search area with a JTable for results and lots of little fields and buttons for buliding your search.
The second tab contains a JDesktopArea which I've extended to do the scroll bar thing. Now, here is where I am confused. In VA which runs 1.2.2 everything works just fine but in JDK 1.3.1 which the company is using I get the following problem.
1. If I highlight text ANYWHERE other than in one of the internal frames and use the copy menu item or copy button the copy occurs just fine. However! If I have text selected in an internal frame and try the menu item it gives an error that the selected component is not a text field. (However the button works for some odd reason.)
Through debugging I've found this:
When text is seleced in teh JInternalFrame and menu item is then triggered events happen like this:
Menu Item gains focus
Menu Item action is run
Menu Itme looses focus
When the text is selected anywhere that ISN'T a JInternalFrame the events go like this:
Menu Item gains focus
Menu Item looses focus
Field with selected text regains focus
Menu Item action is run.
2. This one is even stranger. I start the application and open a new JInternalFrame. If I do this I can type in a text field BUT I can not highlight text with the mouse, i can do it using the SHIFT and arrow keys but not the mouse, I also can not use the mouse to scroll the JInterlaFrame's scroll bar. However if I swtich focus to another frame and then back again everything works as its supposed to from then on out until the program is closed.
I'm thinking the problem has to be something with how focus is handled with the JInternalFrames and that 1 and 2 may be relate? I've tried just about everything I can think of with now luck, anyone have an ideas?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Chris Robertson:
2. This one is even stranger. I start the application and open a new JInternalFrame. If I do this I can type in a text field BUT I can not highlight text with the mouse, i can do it using the SHIFT and arrow keys but not the mouse, I also can not use the mouse to scroll the JInterlaFrame's scroll bar. However if I swtich focus to another frame and then back again everything works as its supposed to from then on out until the program is closed.

I am not sure about the first problem you are having, but I may have some insight on this one...After you open a new Internal Frame, I have noticed that even though you can click on components in the Internal Frame, the Frame itself doesn't seem to have focus.
Try this, when you open a new Internal Frame, click on the Title Bar at the top of the Internal Frame, and then see if it functions properly without having to go from one frame to another.


GenRocket - Experts at Building Test Data
Chris Robertson
Greenhorn

Joined: Sep 19, 2002
Posts: 3
No, that doesn't fix it. I can even double click on the title bar (which maximizes the frame) but I STILL can't use the mouse to highlight or to drag the scroll bar.
For the first problem I just added a popup menu to my InternalFrame class and called it good, the popup menu works with the internal frame just fine. The second problem still has me stumped.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JInternalFrames and focus