Swing Section Index
How do I know what size icon to use for an application on the system tray?
If you don't want to size the icon yourself, you can call setImageAutoSize() with a value of true for the TrayIcon. By default, the property is false. When true, the icon will be automatically res...more
How do I place a tooltip over a system tray icon?
The TrayIcon class offers a setToolTip() method to provide a string for the message.
How do I show a popup message over a system tray icon/application?
The displayMessage() method of TrayIcon allows you to show a timed message, if supported on the platform.
How do I specify an icon to include with a message over a system tray application icon?
The TrayIcon.MessageType enumeration allows you to specify an ERROR, INFO, or WARNING icon, in addition to NONE when displaying a message with displayMessage(). You cannot specify a custom icon.more
How do I specify the popup menu to show for an application on the system tray?
When you create the TrayIcon for the SystemTray, you specify the PopupMenu.
TrayIcon trayIcon = new TrayIcon(anImage, "Tooltip", aPopupMenu);
Just don't forget to fill it with MenuItem objects.
more
How do you find out if the user's platform supports adding applications to the system tray?
Ask the SystemTray class with its static isSupported() method. The javadoc for the class includes a warning when true is returned. Just because the system tray is supported, doesn't mean all funct...more
If I want to manually size my icon for the system tray, how do I find out the correct size for the platform?
The getTrayIconSize() method of SystemTray will return the appropriate Dimension for the icon. This allows you to either pick the most appropriate size from available icons or generate an icon of ...more
How do I clear the selection in a ButtonGroup such that no elements of the associated set of abstract buttons are selected?
Early versions required a hack with a hidden button. In Java 6, you can use the new clearSelection() method.
When dropping an object over a JTree, how do you determine the node being dropped over?
The importData() method of your TransferHandler has a TransferSupport argument. From this support object, you can ask for the drop location with getDropLocation(). This returns an implementation o...more
When having a droppable JTree, how do I change the default behavior of using selection to see the active drop target?
JTree has a setDropMode() method to change the default setting of USE_SELECTION. Other valid modes are ON, INSERT, and ON_OR_INSERT. ON lets you drop something onto another node. INSERT is for bet...more
When creating a Yes/No JOptionPane, how do I default the value to No instead of Yes?
You need to explicitly pass in the button labels and initial value via the showOptionDialog() method (or constructor).
int selection = JOptionPane.showOptionDialog(CreditDefaultLegPanel.this,
...more
How can I find out if my application is being used with a screen magnifier?
The javax.accessibility.screen_magnifier_present property is available. When true, the magnifier is present, and your application can be altered accordingly.
What accessible roles were added to the 1.4 J2SE accessibility API?
Class AccessibleRole Added the following constants:
DATE_EDITOR
FONT_CHOOSER
GROUP_BOX
SPIN_BOX
STATUS_BAR
Which accessible interfaces were added for J2SE 1.4?
The 1.4 API increased the accessibility API by adding the following:
javax.accessibility.AccessibleEditableText
javax.accessibility.AccessibleExtendedComponent
javax.accessibility.AccessibleExt...more
What is the purpose of AccessibleExtendedComponent?
The original accessible API set missed some features in the AccessibleComponent interface. Since the main interface couldn't be altered, Sun introduced a secondary interface AccessibleExtendedComp...more