FileDocCategorySizeDatePackage
UIHelper.javaAPI DocExample2161Mon Jan 09 11:02:00 GMT 2006None

UIHelper

public final class UIHelper extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidcenterOnScreen(java.awt.Component component)

        Dimension paneSize = component.getSize();
        Dimension screenSize = component.getToolkit().getScreenSize();
        component.setLocation(
            (screenSize.width - paneSize.width) / 2,
            (screenSize.height - paneSize.height) / 2);
    
public static javax.swing.JButtoncreateButton(java.lang.String text)

        JButton button = new JButton(text);
        button.setFocusPainted(true);
        button.setBorderPainted(true);
        button.setContentAreaFilled(true);
        return button;
    
public static javax.swing.JButtoncreateButton(java.lang.String text, java.lang.String icon)

        return createButton(text, icon, false);
    
public static javax.swing.JButtoncreateButton(java.lang.String text, java.lang.String icon, boolean flat)

        ImageIcon iconNormal = readImageIcon(icon + ".png");
        ImageIcon iconHighlight = readImageIcon(icon + "_highlight.png");
        ImageIcon iconPressed = readImageIcon(icon + "_pressed.png");

        JButton button = new JButton(text, iconNormal);
        button.setFocusPainted(!flat);
        button.setBorderPainted(!flat);
        button.setContentAreaFilled(!flat);
        if (iconHighlight != null) 
        {
            button.setRolloverEnabled(true);
            button.setRolloverIcon(iconHighlight);
        }
        if (iconPressed != null)
            button.setPressedIcon(iconPressed);
        return button;
    
public static java.awt.ImagereadImage(java.lang.String fileName)

        URL url = UIHelper.class.getResource("images/" + fileName);
        if (url == null)
            return null;

        return java.awt.Toolkit.getDefaultToolkit().getImage(url);
    
public static javax.swing.ImageIconreadImageIcon(java.lang.String fileName)

        Image image = readImage(fileName);
        if (image == null)
            return null;

        return new ImageIcon(image);