Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Problem: My application isn't showing the look and feel I've requested viaUIManager.setLookAndFeel
.You probably either set the look and feel to an invalid look and feel or set it after the UI manager loaded the default look and feel. If you're sure that the look and feel you specified is valid and setting the look and feel is the first thing your program does (at the top of its main method, for example), check whether you have a static field that references a Swing class. This reference can cause the default look and feel to be loaded if none has been specified. For more information, including how to set a look and feel after the GUI has been created, see the look and feel section.
Problem: Why isn't my component getting the focus?
- Is it a custom component (for example, a direct subclass of
JComponent
) that you created? If so, you may need to give your component an input map and mouse listener. See How to Make a Custom Component Focusable for more information and a demo.
- Is the component inside of a
JWindow
? The focus system requires aJWindow
's owning frame to be visible for any components in theJWindow
to get the focus. By default, if you don't specify an owning frame for aJWindow
, an invisible owning frame is created for it. The solution is to either specify a visible owning frame when creating theJWindow
or to use aJDialog
orJFrame
instead.Problem: Why can't my dialog receive the event generated when the user hits the Escape key? This worked until I ported to release 1.4.
If your dialog contains a text field, it may be consuming the event. (Prior to release 1.4.0, the text field didn't get the focus.)
- If you want to get the Escape event regardless of whether a component consumes it, you should use a
.
KeyEventDispatcher
- If you want to get the Escape event only if a component hasn't consumed it, then register a key binding on any
JComponent
in theJDialog
, using theWHEN_IN_FOCUSED_WINDOW
input map. For more information, see the How to Use Key Bindings page.If you don't find your problem in this section, consult Solving Common Component Problems.
If there's a problem you'd like to see mentioned on this page, please send us feedback.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.