Posted by Darryl Burke on December 29, 2008
Thanks for the various comments. We’ll try to keep you updated here when changes are made to the code so you can get a new copy.
- Updated to allow default double clicking behaviour which is to select the entire text.
If you are interested in receiving an RSS feed whenever this posting is updated click on the “Read the rest of this entry” link below for more information on how to do this.
Read the rest of this entry »
Posted in Uncategorized | 27 Comments »
Posted by Rob Camick on October 23, 2011
We have been taught that you should always use a layout manager to layout components on a container. But what about the times when you want the ability to randomly position components on a panel by dragging them with a mouse? Should we use a null layout or can we still use a layout manager?
Read the rest of this entry »
Posted in Classes, Swing | 2 Comments »
Posted by Rob Camick on May 8, 2011
When using a JTable the user has some control over the view of the columns in the table. The columns can be resized and they can be reordered. One feature that is not supported is the ability to hide and reshow a column.
Read the rest of this entry »
Posted in Classes, Swing | 12 Comments »
Posted by Rob Camick on April 24, 2011
A marquee is used to scroll a text message across the screen. The marquee components I’ve seen generally take a text string as a parameter for the marquee class. Then the plain text is scrolled across the screen. Wouldn’t it be nice to jazz up your marquee by using stylized text or by adding images to the marquee?
Read the rest of this entry »
Posted in Classes, Swing | 10 Comments »
Posted by Rob Camick on November 28, 2010
The standard popup for a JComboBox is displayed below the combo box and is fixed to the actual width of the combo box. In most cases this the desired behaviour as the width of the combo box is determined by the items in the combo box. However there might be times when the combo box is not displayed at its preferred width. In these cases the rendering of the text in the popup may cause some items to be truncated. I’m sure this is not desireable.
Read the rest of this entry »
Posted in Classes, Swing | 5 Comments »
Posted by Rob Camick on October 17, 2010
In some applications that use dialogs the Escape key can be used to close the dialog. This feature is not support in the base JDK but can easily be added.
Read the rest of this entry »
Posted in Classes, Swing | 2 Comments »
Posted by Darryl Burke on September 12, 2010
The default behavior of menus on all platforms, not just in Java, is for the menu to disappear when any item is selected. But once in a way, one comes across a situation where keeping the menu open could improve the user experience. For example, in the “Quick Preferences” submenu in Opera browser, a user who wants to set more than one option is forced to navigate the menu repeatedly.
Fortunately, the flexibility afforded in terms of extending the JDK classes makes this possible in Java.
Read the rest of this entry »
Posted in Classes, Extensions, Swing, Tips | 4 Comments »
Posted by Darryl Burke on August 29, 2010
It’s easy to make a JTable sortable by invoking setAutoCreateRowSorter(true). Clicking on the header of a column will then sort the rows on the basis of the contents of the cell in that column, and display an appropriate arrow icon. A little known fact is that the default, automatically created, RowSorter actually uses the last three sort indexes. Unfortunately, the only way the user can know which columns are involved in the subordinate sorting is by remembering the sequence in which the columns were clicked.
MultisortTableHeaderCellRenderer addresses this deficiency by showing the sort icons with decreasing opacity on all columns involved in the sort, making use of the AlphaIcon class published earlier.
Read the rest of this entry »
Posted in Classes, Extensions, Swing, Table | 2 Comments »
Posted by Darryl Burke on August 22, 2010
These Alpha Icons wrap any Icon and paint it with the specified transparency. As Swing does not play well with an Icon that is not itself an ImageIcon but requires to show an animated GIF, two implementations are provided: AlphaIcon, which is good for wrapping any Icon, including an ImageIcon with a static image, and AlphaImageIcon which extends ImageIcon and can provide transparency for an ImageIcon that holds an animated image.
Read the rest of this entry »
Posted in Classes, Swing | 2 Comments »
Posted by Rob Camick on May 9, 2010
It is easy to create a form, you just create a panel and add some components to it. It is also easy to make the form scrollable, you just add the panel to a scroll pane. However, maybe you’ve noticed that as you tab from component to component the viewport of the scroll pane does not scroll automatically when the focused component is no longer in the viewport? In many cases the form would be more usefull to the user if it would scroll automatically as focus changes from component to component.
Read the rest of this entry »
Posted in Classes, Swing | 2 Comments »
Posted by Rob Camick on March 14, 2010
When a JDialog (or JFrame for that matter) is made visible, focus is placed on the first focusable component by default. There may be times when you want to change this behaviour. The obvious solution would be to invoke the requestFocusInWindow() method on the component you wish to receive focus. The problem is that this doesn’t work all the time.
Read the rest of this entry »
Posted in Application, Swing, Tips | 18 Comments »