AWT Section Index | Page 6
Can I set the cursor larger than 32x32 pixels?
You cannot change the cursor size arbitrarily. You can use Toolkit's method createCustomCursor, to create your own cursors from an image.
Toolkits implementation uses getBestCursorSize to get th...more
How can I get an Image's resolution (dpi)?
A (Java) image does not have a resolution so it is not possible to get the resolution of an image.
Resolution (dpi) is not really an attribute of an image. An image is
simply a rectangle of pixel...more
If multiple listeners are added to a button, in which order they will be processed?
The order is not defined by the JavaBean specification. You cannot assume the order.
If you need an order to the listeners, you should add a single listener that performs all of the necssary proc...more
How do I develop a resize mechanisim for a Java GUI?
You don't need to!
The standard Java AWT library provides layout management classes that you can use to automatically resize the components in your GUI based on window size, font changes, or any ...more
Is it possible to show a a modal dialog in the destroy() method of an applet? If so, how?
Yes, you will have to overwrite the method destroy() of the derived applet and call destroy method of an applet in there. Like
public void destroy(){
JOptionPane.showMessageDialog (null,
&q...more
Where can I find good information on GUI design guidelines?
http://java.sun.com/products/jlf/dg/index.htm
http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/visualc/vccore/_core_the_user_interface_guidelines_for_microsoft_windows.ht...more
How can I display a rectangle with centered text?
Note: You can do this most easily by using a JLabel component. Just set its border property to a LineBorder.
The trick to doing this with Graphics is to use the FontMetrics class to determine th...more
How can I get the position of the mouse pointer in a TextArea so that I can insert a String at that position?
The mouse position is represented by the caret in the text area. You can use the following code to insert at the caret position.
textArea.addMouseListener(
new MouseAdapter() {
public voi...more
I have a Frame filled with components (including panels filled with components) -- the nesting gets deep. How can I make the same pop-up menu show no matter where I click within the frame, preferably without registering with every nested component?
You could do it very easily using the following method -
addAWTEventListener
public void addAWTEventListener(AWTEventListener listener,
long eventMask)
Adds an AW...more
Are there any third-party Java classes that support reading and interacting with SVG files?
The Batik Toolkit from Apache lets you do this. See
http://xml.apache.org/batik/.
How can I come back to the default situation after using setEchoChar('*') in AWT's TextField?
Use setEchoChar((char)0).
How can I read the status of the Caps Lock key?
Maybe this isn't the "cleanest" solution, but it works.
Assuming you'll have an AWT component visible (a Frame for instance) and you're using JDK 1.3:
Handle the component keyPressed ev...more
Can I prevent a frame from being maximized?
To keep a frame from being resized by the user, simply invoque its setResizable(boolean) method with a false argument.
import java.awt.*;
import java.awt.event.*;
public class MyFrame extends Fr...more
How do you change the cursor over a JApplet? It seems to be different than for an Applet.
Setting the cursor over a JApplet is no different than an Applet. Just change the parent class from the Applet cursor changing FAQ.
import java.awt.*;
import java.applet.*;
import javax.swing.*;
...more
How do I change the cursor over an Applet?
You can use java.awt.Component's setCursor(java.awt.Cursor) method.
Create a (system-looking) cursor with the java.awt.Cursor constructor and class constants (DEFAULT_CURSOR, HAND_CURSOR, WAIT_CUR...more