AWT Section Index | Page 7
If I want a user to modify the font.properties file for an applet to display a non-standard font, what do I need to tell the user to do so they modify the Java runtime that comes with the browser (no Plugin)?
For Netscape users, the font.properties file is located in the NetscapeCommunicatorProgramjavaclasses directory. For IE users, running clspack -auto will put all your Java classes into a classes.z...more
How can I add depth to my AWT components to allow components to overlap each other when needed like JLayeredPane in Swing components?
You were always able to overlap AWT components. (You just needed to click your heels...)
You can manage the overlapped components on the basis of 'layers' by adapting the code from JLayeredPane. ...more
Can I use wildcards(like *) inside Runtime.exec() to execute grep command?
Can I use wildcards(like *) inside Runtime.exec() to execute grep command?
Because its not working with :
Process pr=Runtime.getRuntime().exec("grep -l 'string' *");
How can I find out which component is in which region of a BorderLayout? Is there any way to ask?
Not directly. If all the five components are
present with non-zero widths and heights you can deduce that information based on the
return value of getBounds() method on each
of them (i.e. x, y, wi...more
How can I draw smooth curves for graphs using the Graphics class?
For smooth curves, use antialiasing (see http://www.jguru.com/jguru/faq/view.jsp?EID=79646). If you're not sure about drawing curves, use the drawArc() method of the Graphics class (see http://jav...more
Can a Java application detect 2 keys pressed at the same time?
If one of those keys is a meta-key (shift, ctrl, or alt) then use the getModifiers() method to determine which one is pressed. For example, to check for Ctrl+A write:
public void keyPressed(KeyE...more
How can I make editable combo boxes in AWT?
It is not directly supported by the AWT library. You can use Swing's JComboBox (if you don't have a restriction on using Swing).
In AWT, you can use a combination of a TextField, Button and a Lis...more
Is it possible to identify the numeric pad enter key has been pressed without using native mechanisms?
No.
Check out http://java.sun.com/products/jdk/1.2/docs/api/java/awt/event/KeyEvent.html for what is supported.more
How can I detect that a Polygon is intersects with a Rectangle?
If your Polygon Class inherits from java.awt.Shape, you can use the intersects() method to determine if the polygon intersects the rectangle. Something like this:
if (myPolygon.interesects(myRe...more
What is event polling?
Event polling is (in very broad terms) a lot like the way people
handle email. The messages pile up in a box as they arrive,
and the user periodically checks to see if anything new is in
the box...more
When trying to use double buffering, method createImage(int,int) returns null image object if used from within constructor. Why?
In order to do its thing, createImage(int, int) relies on the component's peer. However, the peer is not created until the component is made displayable for the first time. During your component's...more
What are the most common exceptions that occur when you are writing a program using AWT?
What are the most common exceptions that occur
when you are writing a program using AWT?
How can I run a Java Application without running MS DOS window in Windows?
Use one of the following -
<jdk-1.1-dir>/bin/javaw
<jre-1.1-dir>/bin/jrew
<jdk-1.2-and-above-dir>/jre/bin/javaw
launcher based on you Java version.more
I have a frame containing a JPanel with many components on it (like JLabel, JTextField etc.). But when I try to print the page like a print screen, it only draw part of the screen as if it has another page. How can I fit the components on the JPanel to be drawn into one page only?
The Print Screen simply copies the screen
or active frame only (if alt+Print Screen
was used) to the system clipboard in a native
format. Run any native program (paint.exe
on MS widnows), paste th...more
How can I find the position of the mouse without a MouseEvent?
The JVM provides all information regarding the system's mouse within an applet (or application) via mouse events. There is no way to pole the JVM for mouse information directly. An easy way arou...more