Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Problem: I'm seeing weird problems that seem either intermittent or dependent on timing.
- Does your main thread modify the GUI after it's visible? If so, either move the code so that it executes before the GUI is shown, or execute the GUI-modifying code in the event-dispatching thread.
- Does your program have multiple threads or query/modify the GUI in response to messages from other programs? If so, you should ensure that all GUI-related code is executed in the event-dispatching thread.
- If your program is an applet that implements the
stop
andstart
methods, make sure that any GUI work performed by those methods is executed in the event-dispatching thread.- The preceding suggestions assume that your problem is caused by code that isn't thread safe. See Threads and Swing for information about thread safety, and How to Use Threads for information about API you can use to help make your programs thread safe.
Problem: My applet/dialog/frame is blank.
- Does the applet/frame/dialog perform custom drawing? If so, you need to move the custom drawing code out of the
JApplet
/JDialog
/JFrame
subclass and into a custom component that you add to the content pane. For more information, see Step 8 of the 12-step conversion plan.- Do you either set the applet/frame/dialog's content pane or add components to the existing content pane? You should. See Using Top-Level Containers for more information.
Problem: In the Swing version of my program, the list/text component is missing its scroll bars.
- Swing list and text components don't have automatic scroll bars. Instead, you need to add the list or text component to a scroll pane, as described in Component-Specific Conversion Tips.
Problem: Although I'm using the same grid bag layout code as before, one scrollable component is tiny.
- Make sure you set constraints on the scroll pane, rather than on its client.
Problem: I'm not getting the kinds of events I expected for the Swing component I'm using.
- Read both the conversion tips and how-to section for the component you're using. Chances are that the relevant event details are covered in those sections.
- If you think the problem might be a bug, search the bug database at the Java Developer Connection: http://developer.java.sun.com/ .
If you can't find your problem on this page, check Solving Common Component Problems.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.