JTextField aTextField = new JTextField("Almost Solved!");
aTextField.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
((JWindow)((JComponent) e.getComponent
()).getTopLevelAncestor()).setFocusableWindowState(true);
}
public void mouseExited(MouseEvent e) {
((JWindow)((JComponent) e.getComponent
()).getTopLevelAncestor()).setFocusableWindowState(false);
}
});
Of course, this is a bad implementation as it depends on the pointer
remaining in the area of aTextField, which is a bit annoying. It
should be implemented with a mouse clicked event that then sets the
focusable window state to true and places the caret in aTextField (if
it doesn't do the latter then another click is required that is also
very annoying). Then when aTextField loses focus(?) the focusable
window state should be set back to false.
I'd have done this but it's getting late here and my event handling
knowledge is a bit shaky!
Try the bad implementation first to check it works for you.
hope this helps.
Ian Cheyne
On 27 Aug 2006, at 18:26, Jerry wrote:
On 27 Aug 2006, at 15:46, Werner Randelshofer wrote:
IMO, in an MDI application, only the outer frame should have a
menu bar, document windows shouldn't have one.
I think it is okay, if palette windows have a menu button, but
they shouldn't have a menu bar.
Thinking about palettes: The framework does not handle them in a
platform independent way. Only DefaultOSXApplication supports
them. Maybe, I should add a Palette interface or something to it.
Also thinking about palettes: If you're using the screen menu bar
and you have floating palettes implemented as JDialogs of a JFrame
that has the global menu bar, there's a problem with keyboard
accelerators: the menu bar works fine with the mouse, but if you
press, say, Command-N for "New", the File menu highlights in the
normal way but the "New" menu item doesn't fire. If you call
setFocusableWindowState(false) on the palettes, then it works, but
then you can't have any text fields in your palettes.I imagine this
is a bug in focus handling for the screen menu bar. Does anyone
know of a workround which allows you to have floating palettes with
text fields and a menu bar which works properly?
Jerry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden