Swing Section Index | Page 30
How do I validate a TextField/JTextField to only accept valid IP addresses?
[FAQ Manager Note]There are two answers submitted for this question. The second appears at the end of the page.
Here is a possible soltion. I wrote this last night using a generic bounded text fi...more
How can I make a column header of a JTable span over two columns?
For a few examples of this, see
http://codeguru.developer.com/java/articles/125.shtml
http://codeguru.developer.com/java/articles/124.shtml
more
How do I cut and paste between a JTable and Microsoft Excel?
This is answered in JavaWorld tip # 77 at http://www.javaworld.com/javaworld/javatips/jw-javatip77.html.
How can I make a JLabel whose size is just big enough for the text, with no borders?
JLabel actually does provide just enough space for the text plus the leading (space between lines).
You can do something like the following, though it is not recommended. This subclass of JLabel ...more
How do I select a row (or rows) in a JTable?
In the Model-View-Controller (MVC) world of Swing, the JTable
is just a display mechanism. Instead of selecting rows in the table (view), you select rows in the selection model:
ListSelectionMode...more
How do I let my Swing text component support undo/redo?
The Swing text components come with built in support for undoing and redoing text operations. All you have to do is associate an UndoManager to the Document of the text component:
JTextField textF...more
What is a peer?
AWT uses native code (code specific to a single operating system) to display its components. Each implementation of the Jave Runtime Environment (JRE) must provide native implementations of Button...more
Why can't I use the Windows and Mac look and feels on other platforms?
These look and feels are locked to only work on their native operating system. Sun felt there were copyright-related issues with running these on other than their native operating system.
If you ...more
What's the deal with the different Swing package names?
History
When Swing first came out, Sun wanted to make it available for JDK 1.1.x, but have it be part of the core Java class libraries for the Java 2 platform (then known as JDK 1.2).
This presen...more
How can I setup a JTextField to only accept valid dates?
It depends what you mean by 'accept'.
You can validate the choice at three times:
As the user types characters
After the user is done with the field
After the user is done with the GUI
...more
How do I display a multi-line tooltip?
Check out the tooltip example from the Swing samples application that ships with the JDK. You can use embedded html tags in the text of the tooltip to produce the desired result in a platform inde...more
Do the Swing components support displaying international character sets?
Yes.
Assuming you have the proper font installed, the following will display Kanji characters for the Japanese numbers:
import javax.swing.*;
import java.awt.*;
public class TableSample {
publi...more
How do you create custom cursors with the Java 2 platform?
The createCustomCursor() method of the Toolkit class provides for the ability to create a cursor out of an Image.
When creating custom cursors, be sure to take advantage of the hints available fro...more
Where can I find additional look and feel implementations?
The slaf look and feel (http://www.memoire.com/guillaume-desnoix/slaf/index-en.html is one such that look and feel that is itself customizable.
The Up to Speed with Swing book includes a (partial)...more
What's the difference between the swing.jar and swingall.jar files?
The swingall.jar file contains all of the various,
standard Swing Look & Feel implementations. The
swing.jar file only contains the default Swing
Look & Feel implementation.
more