Java Utililty Methods Swing UIManager

List of utility methods to do Swing UIManager

Description

The list of methods to do Swing UIManager are organized into topic(s).

Method

voidsetSystemUi()
set System Ui
try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch (Exception e) {
    e.printStackTrace();
voidsetTheme()
set Theme
final Color color = new Color(85, 142, 119);
final Color colorBackground = new Color(247, 247, 247);
Image error_dialog_icon = new ImageIcon("/images/error_dialog.png").getImage();
UIManager.getLookAndFeelDefaults().put("nimbusOrange", color);
UIManager.getLookAndFeelDefaults().put("control", colorBackground);
UIManager.getLookAndFeelDefaults().put("OptionPane.errorIcon", error_dialog_icon);
UIManager.getLookAndFeelDefaults().put("OptionPane.background", colorBackground);
UIManager.getLookAndFeelDefaults().put("Panel.background", new Color(245, 245, 245));
...
voidsetupComponent(JComponent comp)
setup Component
comp.setOpaque(false);
if (comp instanceof JButton) {
    comp.putClientProperty("JButton.buttonType", "textured");
if (comp instanceof JComboBox) {
    comp.putClientProperty("JComboBox.isPopDown", Boolean.TRUE);
if (comp instanceof JTextArea) {
...
voidsetupUI()
Set up the user interface.
try {
    final String classname = UIManager.getSystemLookAndFeelClassName();
    UIManager.setLookAndFeel(classname);
} catch (Exception e) {
    e.printStackTrace();
final UIDefaults defaults = UIManager.getDefaults();
defaults.put("PopupMenu.border", new BorderUIResource.EtchedBorderUIResource(EtchedBorder.RAISED,
...
booleanshouldUpdateStyle(PropertyChangeEvent event)
Returns true if the Style should be updated in response to the specified PropertyChangeEvent.
String eName = event.getPropertyName();
if ("name" == eName) {
    return true;
} else if ("componentOrientation" == eName) {
    return true;
} else if ("ancestor" == eName && event.getNewValue() != null) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    return (laf instanceof SynthLookAndFeel
...
StringshowDirSelect()
show Dir Select
try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
...
PopupshowToolTip(Component contents, int x, int y, final int dismissDelay, int initialDelay)
show Tool Tip
final Popup popup = PopupFactory.getSharedInstance().getPopup(null, contents, x, y);
final Timer timer = new Timer(initialDelay, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        Timer hideTimer = new Timer(dismissDelay, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                popup.hide();
        });
        hideTimer.setRepeats(false);
        popup.show();
        hideTimer.start();
});
timer.setRepeats(false);
timer.start();
return popup;
voidsystemLF()
system LF
try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
    e.printStackTrace();
} catch (InstantiationException e) {
    e.printStackTrace();
} catch (IllegalAccessException e) {
    e.printStackTrace();
...
voidtraceSubstanceApiUsage(Component comp, String message)
trace Substance Api Usage
Window w = SwingUtilities.getWindowAncestor(comp);
String wTitle = null;
if (w instanceof Frame) {
    wTitle = ((Frame) w).getTitle();
if (w instanceof Dialog) {
    wTitle = ((Dialog) w).getTitle();
throw new IllegalArgumentException(message + " [component " + comp.getClass().getSimpleName()
        + " in window " + w.getClass().getSimpleName() + ":'" + wTitle + "' under "
        + UIManager.getLookAndFeel().getName() + "]");
voiduseLNF()
use LNF
try {
    javax.swing.UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
} catch (Exception e) {
    e.printStackTrace();