Section Index | Page 87
The key to solving this problem is to subclass TextArea and intercept any KeyEvent sent. You need to check to see if the typed key is a lower case character (be careful to keep this independent ...more
The repaint(), revalidate(), and invalidate() methods do not need to execute in the event dispatch thread (also known as the AWT thread). Any other methods which affect the state of a component mu...more
To ensure a specific row (or cell) is visible, you need to get the rectangle surrounding a specific row/column (cell) than make sure that is visible: Rectangle rect = table.getCellRect(row, c...more
There are two "types" of font names you can deal with in Java Logical Font Names System Font Names Logical font names are the names Java uses for platform independence. These are na...more
The answer depends on the model you're using... If you've called setModel() for the JTable in question, you must examine the class of the actual model you're using to see how (and if) it allows r...more
As long as you don't need the window manager adornments, you can use the RepaintManager to capture the image on any Swing component: RepaintManager manager = RepaintManager.currentManager(compone...more
I'm using the Java Plug-in and need to modify the policy file. Why isn't the Plug-in picking up my changes?
The Plug-in reads the policy file and key store only once at startup. If you need to modify either, you need to shutdown and restart the browser.
// Convert urlString into a BufferedReader URL url = new URL(urlString); URLConnection connection = url.openConnection(); InputStream is = connection.getInputStream(); InputStreamReader isr = new...more
For AWT programs, you need to compare the modifiers of the event to the button masks of the INPUT_EVENT. Left InputEvent.BUTTON1_MASK Middle InputE...more
While technically possible to use the Swing components in any Java 1.1-based browser, realistically is another story. The JAR file of Swing classes is approximately 2 MB, which would be required t...more
You can either call the setLookAndFeel() method of the UIManager class or set the swing.defaultlaf property of your Java program before it starts. If you wish to change the look and feel of a runn...more
The AWT Toolkit object provides information about the user's runtime platform. To find out what size in pixels the users's screen is, use the getScreenSize() method. import java.awt.*; public cla...more
All graphical applications require at least 256 colors. Console-based programs like servlets or the compiler are not limited by this capability.
In short, get the applet's context and tell it to show a different document: getAppletContext().showDocument(new URL("http://foo.com/whatever/blah.doc")). You can also provide a target f...more
How can I download a file (for instance, a Microsoft Word document) from a server using a servlet and an applet?
Try telling the applet to call getAppletContext().showDocument("http://foo.com/whatever/blah.doc"). That makes the browser responsible for fetching and saving the document (including pu...more