FileDocCategorySizeDatePackage
MotifInternalFrameTitlePane.javaAPI DocJava SE 6 API11258Tue Jun 10 00:21:56 BST 2008com.sun.java.swing.plaf.motif

MotifInternalFrameTitlePane

public class MotifInternalFrameTitlePane extends BasicInternalFrameTitlePane implements ActionListener, PropertyChangeListener, LayoutManager
Class that manages a Motif title bar
version
1.35 11/17/05
since
1.3

Fields Summary
SystemButton
systemButton
MinimizeButton
minimizeButton
MaximizeButton
maximizeButton
JPopupMenu
systemMenu
Title
title
Color
color
Color
highlight
Color
shadow
public static final int
BUTTON_SIZE
static Dimension
buttonDimension
Constructors Summary
public MotifInternalFrameTitlePane(JInternalFrame frame)

  // 17 + 1 pixel border


       
        super(frame);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

    
public voidaddLayoutComponent(java.lang.String name, java.awt.Component c)

protected voidaddSubComponents()

        title = new Title(frame.getTitle());
        title.setFont(getFont());

	add(systemButton);
        add(title);
	add(minimizeButton);
	add(maximizeButton);
    
protected voidassembleSystemMenu()

	systemMenu = new JPopupMenu();
	JMenuItem mi = (JMenuItem)systemMenu.add(new JMenuItem(restoreAction));
        mi.setMnemonic('R");
	mi = (JMenuItem) systemMenu.add(new JMenuItem(moveAction));
        mi.setMnemonic('M");
	mi = (JMenuItem) systemMenu.add(new JMenuItem(sizeAction));
        mi.setMnemonic('S");
	mi = (JMenuItem) systemMenu.add(new JMenuItem(iconifyAction));
        mi.setMnemonic('n");
	mi = (JMenuItem) systemMenu.add(new JMenuItem(maximizeAction));
        mi.setMnemonic('x");
	systemMenu.add(new JSeparator());
	mi = (JMenuItem) systemMenu.add(new JMenuItem(closeAction));
        mi.setMnemonic('C");
	
        systemButton = new SystemButton();
	systemButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                systemMenu.show(systemButton, 0, BUTTON_SIZE);
            }
        });

        systemButton.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent evt) {
                try {
                    frame.setSelected(true);
                } catch (PropertyVetoException pve) {
                }
                if ((evt.getClickCount() == 2)) {
                    closeAction.actionPerformed(new
                        ActionEvent(evt.getSource(),
                            ActionEvent.ACTION_PERFORMED,
                            null, evt.getWhen(), 0));
                    systemMenu.setVisible(false);
                }
            }
        });
    
protected voidcreateButtons()

	minimizeButton = new MinimizeButton();
	minimizeButton.addActionListener(iconifyAction);

	maximizeButton = new MaximizeButton();
	maximizeButton.addActionListener(maximizeAction);
    
protected java.awt.LayoutManagercreateLayout()

        return this;
    
protected java.beans.PropertyChangeListenercreatePropertyChangeListener()

        return this;
    
javax.swing.JPopupMenugetSystemMenu()

        return systemMenu;
    
protected voidhideSystemMenu()

      systemMenu.setVisible(false);
    
protected voidinstallDefaults()

        setFont(UIManager.getFont("InternalFrame.titleFont"));
	setPreferredSize(new Dimension(100, BUTTON_SIZE));
    
public voidlayoutContainer(java.awt.Container c)

	int w = getWidth();
	systemButton.setBounds(0, 0, BUTTON_SIZE, BUTTON_SIZE);
	int x = w - BUTTON_SIZE;

	if(frame.isMaximizable()) {
	    maximizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE);
	    x -= BUTTON_SIZE;
	} else if(maximizeButton.getParent() != null) {
	    maximizeButton.getParent().remove(maximizeButton);
	}
        
	if(frame.isIconifiable()) {
	    minimizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE);
	    x -= BUTTON_SIZE;
	} else if(minimizeButton.getParent() != null) {
	    minimizeButton.getParent().remove(minimizeButton);
	}

        title.setBounds(BUTTON_SIZE, 0, x, BUTTON_SIZE);
    
public java.awt.DimensionminimumLayoutSize(java.awt.Container c)

	return new Dimension(100, BUTTON_SIZE);
    
public voidpaintComponent(java.awt.Graphics g)

    
public java.awt.DimensionpreferredLayoutSize(java.awt.Container c)

        return minimumLayoutSize(c);
    
public voidpropertyChange(java.beans.PropertyChangeEvent evt)

	String prop = (String)evt.getPropertyName();
	JInternalFrame f = (JInternalFrame)evt.getSource();
	boolean value = false;
	if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
	    repaint();
        } else if (prop.equals("maximizable")) {
            if ((Boolean)evt.getNewValue() == Boolean.TRUE)
                add(maximizeButton);
            else
                remove(maximizeButton);
            revalidate();
            repaint();
        } else if (prop.equals("iconable")) {
            if ((Boolean)evt.getNewValue() == Boolean.TRUE)
                add(minimizeButton);
            else
                remove(minimizeButton);
            revalidate();
            repaint();
        } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
            repaint();
        }
        enableActions();
    
public voidremoveLayoutComponent(java.awt.Component c)

voidsetColors(java.awt.Color c, java.awt.Color h, java.awt.Color s)

        color = c;
        highlight = h;
        shadow = s;
    
protected voidshowSystemMenu()

      systemMenu.show(systemButton, 0, BUTTON_SIZE);
    
protected voiduninstallListeners()

        // Get around protected method in superclass
        super.uninstallListeners();