Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips
Tip Bank > Java > Java APIs > AWT

AWT - Page 3

41-60 of 104     Previous     Next
Obtaining the List of Available Fonts
by Brett Spell
Some applications allow the user to select which font is used for displaying text. To do this, you need to be able to dynamically determine which fonts are available so that the user can select the ...
Choosing Colors for Custom Components
by Brett Spell
When creating a custom user interface component, you often face the problem of deciding what colors to use while drawing the component on the screen. However, to a large extent, this decision has ...
Repositioning Viewable Text in TextArea
by DevX Pro
Can I make the text in a TextArea scroll to a given line? For example, I have 100 lines of text in a TextArea with 20 viewable rows. Can I scroll the text (without manipulating the scrollbars physically) so that lines 70-90 are displayed in the TextArea?
Serialize Image Instances
by Brett Spell
The java.awt.Image class does not implement the java.io.Serializable interface. As a result, attempts to serialize or "marshal" instances of the class will fail. For example, they cannot be passed as ...
Determine Absolute Cursor Coordinates
by Brett Spell
When a component event such as a mouse click occurs, Java provides the cursor coordinates relative to the top left corner of the component in which the event took place. However, it can be useful to ...
Detecting Double-Clicks
by Brett Spell
When creating a Java GUI, it is often the case that you want some action to be taken when the user double-clicks on some component. Although there is no simple way to detect double-clicks in Java 1.0.
Generating a Series of Unique Colors
by Trevor Harmon
Graphs, charts, and maps often use color to help the user tell data points apart. For instance, a line graph comparing processor benchmarks might show the Motorola processor in red, the Intel ...
Center Your Windows
by Brett Spell
By default, instances of Window subclasses such as Frame and Dialog appear at the upper-left corner of the screen when made visible. For a more user-friendly interface, you can center the component ...
Timely Capture of Font Metrics
by Tom Yarker
If you extend an AWT class to add text to a GUI component, then you probably need access to the font's metrics so that you can deduce the amount of space required by the text. But the component has ...
Designating Disabled Icons
by Tom Yarker
To show when an icon button is disabled, you need to have a less prominent version of the icon's image. The following class reduces the alpha component of each color in the original image. This is ...
First Visible List Row
by DevX Pro
Is there a way to find out the first visible row in a List?
Designating Disabled Text
by Tom Yarker
A well-developed user interface will make it clear which components in a dialog are available to receive input from the user. The AWT Component class has a setEnabled method for altering the ...
Get Your Graphics Here
by Tom Yarker
If you extend a few AWT classes, you will eventually want to add images to enhance their appearance. Icons for buttons and your own logo in the corner of frames are good examples. But how can you be ...
Avoiding Tab Traversal for Non-Editable TextFields
by Brett Spell
To prevent a component from getting the focus when the Tab or shift-Tab keyboard focus traversal is used, override the isFocusTraversable method. It is often desirable to toggle a TextField in an ...
Button resizing
by DevX Pro
How do I force a java.awt.Button to resize to the size I want, instead of packing according to the size of its string label? I tried button.setSize(x,y) but it didn't work.
Frame Content to Image Object
by DevX Pro
In my application, I want to convert the content of a component into a GIF image. I know how to convert an Image object to a GIF, but I don't know how to convert the contents of a frame into an Image object. Could you help me?
Frame Positioning
by DevX Pro
Is it possible to reposition the frame of a standalone application? My application starts up at the upper left corner of my monitor every time.
Controlling the cursor position in a TextField
by DevX Pro
Is there a way to put the text editing cursor in a specific position, like at the end of the string, in a TextField?
Simplify Creating and Adding Menu Items
by Brett Spell
When creating menu items and adding them to a menu, you can shorten your code by combining two steps into one. Instead of creating the menu item and adding it in separate steps, such ...
Absolute Layout Manager
by DevX Pro
Do you know of any LayoutManager that would allow me to lay out components exactly where I want them, or any other way of doing so?
41-60 of 104     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date