文档

Java™ 教程-Java Tutorials 中文版
解决常见的组件问题
Trail: Creating a GUI With JFC/Swing
Lesson: Using Swing Components

解决常见的组件问题

This section discusses problems that you might encounter while using components. If you do not find your problem in this section, consult the following sections:

Problem:I am having trouble implementing a model (or some other code that is similar to something already in Java SE Platform, Standard Edition).

Problem:Whenever the text in my text field updates, the text field's size changes.

Problem:Certain areas of the content pane look weird when they are repainted.

Problem:My program is exhibiting weird symptoms that sometimes seem to be related to timing.

Problem:My modal dialog gets lost behind other windows.

Problem:The scroll bar policies do not seem to be working as advertised.

Problem:My scroll pane has no scroll bars.

Problem:The divider in my split pane does not move!

Problem:The setDividerLocation method of JSplitPane does not work.

Problem:The borders on nested split panes look too wide.

Problem:The buttons in my tool bar are too big.

Problem: The components in my layered pane are not layered correctly. In fact, the layers seem to be inversed — the lower the depth the higher the component.

Problem:The method call colorChooser.setPreviewPanel(null) does not remove the color chooser's preview panel as expected.


Previous page: How to Use Borders
Next page: Questions and Exercises: Using Swing Components