Article View: borland.public.jbuilder.java.swing
Article #8486Component focus in Swing is driving me nuts!
From: Gerald Nunn
Date: Tue, 29 Aug 2000 00:00
Date: Tue, 29 Aug 2000 00:00
22 lines
1602 bytes
1602 bytes
I'm in the process of doing some Java work though up to now the bulk of my experience has been in Delphi. The way focus is handled in Swing is driving me nuts and I think I must be missing a paradigm shift or something in going to Java from Windows. 1) How do you determine which component currently has focus in Swing? I wrote a function that iterates through the component tree checking hasFocus(), it works but I figure there must be a better way already provided by Java 2) In Windows, toolbar buttons don't get focus. Thus if you hit a "cut" button, it's easy to determine what control currently has focus and to pass the cut operation onto that control. How do I do the same in java? My toolbar buttons get focus in java thereby causing the current control to lose focus. I then can't determine what control should receive the "cut" operation. The reason I'm doing this is I have a set of editors in JInternalFrames in a JDesktopPane and I want a single set of cut, copy, paste buttons and menus to work with these. Thanks in advance for the help. Gerald
Technical Details
Message-ID:
<8ogg1s$du06@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,39449fb20ddb661e,start X-Google-Attributes: gid111d45,public From: "Gerald Nunn" <gnunn@workbrain.com> Subject: Component focus in Swing is driving me nuts! Date: 2000/08/29 Message-ID: <8ogg1s$du06@bornews.borland.com> X-Deja-AN: 663904940 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing