AWT Section Index | Page 20
How can I explicitly display a tooltip in AWT?
Here's some sample code that can display a tooltip in an AWT GUI.
Users can see information each time they move the mouse on a GUI. This little class displays tips given by a String. The String c...more
How can I iconify/deiconify my Frame/JFrame?
The setState() method introduced to Java 1.2 provides support for iconifying and deiconifying.
frame.setState(Frame.ICONIFIED);
frame.setState(Frame.NORMAL);
How do I maximize a Frame/JFrame ?
There is no direct support for this. The best you can do is make sure the frame is deiconified then set its size to the screen size.
frame.setState(Frame.NORMAL);
Toolkit toolkit = Toolkit.getDef...more
How do I create multi-line labels in AWT / Swing?
The AWT Label does not support multiple lines on Label. You would need to
create multiple Label components and place them in a Panel (or create your own
component).
In Swing 1.1.1 and later, yo...more
How can I display images in an TextArea?
AWT TextArea components only support displaying text. You cannot display images in them. If you don't mind using the Swing components, you can use either the JEditorPane or JTextPane to display im...more
How can I display Text strings of different style on different lines of an TextArea.
How can I display Text strings of different style on different lines of an TextArea.
i.e I want Hello on first line as PLAIN String.
Hello World on second line as BOLD. or might be in different Color.
How do I overcome the 32K limit of TextArea?
On Windows 95 machines, the AWT TextArea is limited to about 32K characters. This is a limitation of the underlying operating system. Since AWT components rely on native components, you cannot ove...more
What is the difference between JFC & WFC?
JFC supports robust and portable user interfaces. The Swing classes are robust, compatible with AWT, and provide you with a great deal of control over a user interface. Since source code is availa...more
Where can I get information about writing a layout manager?
Sun's online tutorial describes what you need to do to create a layout manager at http://java.sun.com/docs/books/tutorial/uiswing/layout/custom.html.more
Can I use menus and a menu bar in an applet?
AWT applets (those that subclass java.applet.Applet) cannot include an AWT MenuBar. Swing applets (those that subclass javax.swing.JApplet) can use the JMenuBar. To display menus in an AWT you wou...more
How can I limit the size of my window?
You can register a ComponentListener with the window and have the componentResized() method validate the window size. If the window is outside acceptable limits, you can return things to the desir...more
How do I force drawImage() to refetch an image?
If you flush() an Image between calls to drawImage(), the Image will be refetched instead of using the local cached version.
I tried adding the same menu item to multiple menus. Why doesn't it work properly?
When adding a component to a container, it is removed from any previous container. Because of this, you cannot have the same component/menu items in multiple containers/menus.
How can I capture the image of an AWT GUI?
You can use the printAll() method of Component to accomplish this.
As an example
Component comp = ... ; // the top-level component
// you want to capture
// create an im...more
How do I convert an in-memory bitmap to something that is usable by JAVA?
Jef Poskanzer has a 1.1-compliant GIF writer:
http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html