FileDocCategorySizeDatePackage
SynthInternalFrameTitlePane.javaAPI DocJava SE 5 API11302Fri Aug 26 14:58:12 BST 2005javax.swing.plaf.synth

SynthInternalFrameTitlePane

public class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane implements sun.swing.plaf.synth.SynthUI, PropertyChangeListener
The class that manages a synth title bar
version
1.22 09/10/04
author
David Kloba
author
Joshua Outwater
author
Steve Wilson

Fields Summary
protected JPopupMenu
systemPopupMenu
protected JButton
menuButton
private SynthStyle
style
Constructors Summary
public SynthInternalFrameTitlePane(JInternalFrame f)

        super(f);
    
Methods Summary
protected voidaddSubComponents()

	menuButton.setName("InternalFrameTitlePane.menuButton");
        iconButton.setName("InternalFrameTitlePane.iconifyButton");
        maxButton.setName("InternalFrameTitlePane.maximizeButton");
        closeButton.setName("InternalFrameTitlePane.closeButton");

	add(menuButton);
	add(iconButton);
	add(maxButton);
	add(closeButton);
    
protected voidaddSystemMenuItems(javax.swing.JPopupMenu menu)

        // PENDING: this should all be localizable!
        JMenuItem mi = (JMenuItem)menu.add(restoreAction);
	mi.setMnemonic('R");
	mi = (JMenuItem)menu.add(moveAction);
	mi.setMnemonic('M");
	mi = (JMenuItem)menu.add(sizeAction);
	mi.setMnemonic('S");
	mi = (JMenuItem)menu.add(iconifyAction);
	mi.setMnemonic('n");
	mi = (JMenuItem)menu.add(maximizeAction);
	mi.setMnemonic('x");
	menu.add(new JSeparator());
	mi = (JMenuItem)menu.add(closeAction);
	mi.setMnemonic('C");
    
protected voidassembleSystemMenu()

        systemPopupMenu = new JPopupMenuUIResource();
        addSystemMenuItems(systemPopupMenu);
	enableActions();
        menuButton = createNoFocusButton();
	menuButton.setIcon(frame.getFrameIcon());
        menuButton.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                showSystemMenu();
            }
        });
	JPopupMenu p = frame.getComponentPopupMenu();
	if (p == null || p instanceof UIResource) {
	    frame.setComponentPopupMenu(systemPopupMenu);
	}
	if (frame.getDesktopIcon() != null) {
	    p = frame.getDesktopIcon().getComponentPopupMenu();
	    if (p == null || p instanceof UIResource) {
		frame.getDesktopIcon().setComponentPopupMenu(systemPopupMenu);
	    }
	}
	setInheritsPopupMenu(true);
    
protected java.awt.LayoutManagercreateLayout()

        SynthContext context = getContext(this);
	LayoutManager lm =
	    (LayoutManager)style.get(context, "InternalFrameTitlePane.titlePaneLayout");
	context.dispose();
        return (lm != null) ? lm : new SynthTitlePaneLayout();
    
private javax.swing.JButtoncreateNoFocusButton()

        JButton button = new JButton();
        button.setFocusable(false);
        button.setMargin(new Insets(0,0,0,0));
        return button;
    
private intgetComponentState(javax.swing.JComponent c)

        if (frame != null) {
            if (frame.isSelected()) {
                return SELECTED;
            }
        }
        return SynthLookAndFeel.getComponentState(c);
    
public javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c)

        return getContext(c, getComponentState(c));
    
public javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c, int state)

        return SynthContext.getContext(SynthContext.class, c,
                    SynthLookAndFeel.getRegion(c), style, state);
    
private javax.swing.plaf.synth.RegiongetRegion(javax.swing.JComponent c)

        return SynthLookAndFeel.getRegion(c);
    
public java.lang.StringgetUIClassID()

        return "InternalFrameTitlePaneUI";
    
protected voidinstallDefaults()

        super.installDefaults();
        updateStyle(this);
    
protected voidinstallListeners()

        super.installListeners();
        frame.addPropertyChangeListener(this);
    
public voidpaint(java.awt.Graphics g, javax.swing.JComponent c)

        SynthContext context = getContext(c);

        paint(context, g);
        context.dispose();
    
protected voidpaint(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g)

    
public voidpaintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)

        context.getPainter().paintInternalFrameTitlePaneBorder(context,
                                                            g, x, y, w, h);
    
public voidpaintComponent(java.awt.Graphics g)

        SynthContext context = getContext(this);
        SynthLookAndFeel.update(context, g);
        context.getPainter().paintInternalFrameTitlePaneBackground(context,
                          g, 0, 0, getWidth(), getHeight());
        paint(context, g);
        context.dispose();
    
public voidpropertyChange(java.beans.PropertyChangeEvent evt)

        if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
            updateStyle(SynthInternalFrameTitlePane.this);
        }
    
protected voidshowSystemMenu()

        Dimension dim = new Dimension();
        Insets insets = frame.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.bottom + insets.top;
        if (!frame.isIcon()) {
            systemPopupMenu.show(menuButton,
                getX() - dim.width,
                getY() + getHeight() - dim.height);
        } else {
            systemPopupMenu.show(menuButton,
                getX() - dim.width,
                getY() - systemPopupMenu.getPreferredSize().height -
                    dim.height);
        }
    
protected voiduninstallDefaults()

        SynthContext context = getContext(this, ENABLED);
        style.uninstallDefaults(context);
        context.dispose();
        style = null;
        JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
        if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
            // Release link to systemMenu from the JInternalFrame
            di.setComponentPopupMenu(null);
        }
        super.uninstallDefaults();
    
protected voiduninstallListeners()

        frame.removePropertyChangeListener(this);
        super.uninstallListeners();
    
private voidupdateStyle(javax.swing.JComponent c)

        SynthContext context = getContext(this, ENABLED);
        SynthStyle oldStyle = style;
        style = SynthLookAndFeel.updateStyle(context, this);
        if (style != oldStyle) {
            maxIcon =
                style.getIcon(context,"InternalFrameTitlePane.maximizeIcon");
            minIcon =
                style.getIcon(context,"InternalFrameTitlePane.minimizeIcon");
            iconIcon =
                style.getIcon(context,"InternalFrameTitlePane.iconifyIcon");
            closeIcon =
                style.getIcon(context,"InternalFrameTitlePane.closeIcon");
        }
        context.dispose();