API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.swing.plaf.basic. DefaultMenuLayout View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

/*
 * @(#)DefaultMenuLayout.java	1.13 06/12/15
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.swing.plaf.basic;

import javax.swing.*;
import javax.swing.plaf.UIResource;

import java.awt.Container;
import java.awt.Dimension;
import static sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET;

/**
 * The default layout manager for Popup menus and menubars.  This
 * class is an extension of BoxLayout which adds the UIResource tag
 * so that plauggable L&Fs can distinguish it from user-installed
 * layout managers on menus.
 *
 * @version 1.13 12/15/06
 * @author Georges Saab
 */

public class DefaultMenuLayout extends BoxLayout implements UIResource {
    public DefaultMenuLayout(Container target, int axis) {
	super(target, axis);
    }

    public Dimension preferredLayoutSize(Container target) {
        if (target instanceof JPopupMenu) {
          ((JPopupMenu)target).putClientProperty(
                                 BasicMenuItemUI.MAX_ARROW_ICON_WIDTH, null);
          ((JPopupMenu)target).putClientProperty(
                                 BasicMenuItemUI.MAX_CHECK_ICON_WIDTH, null); 
          ((JPopupMenu)target).putClientProperty(
                                 BasicMenuItemUI.MAX_ICON_WIDTH, null);
          ((JPopupMenu)target).putClientProperty(
                                 BasicMenuItemUI.MAX_TEXT_WIDTH, null); 
          ((JPopupMenu)target).putClientProperty(
                                 BasicMenuItemUI.MAX_ACC_WIDTH, null);
          ((JPopupMenu)target).putClientProperty(
                                 BasicMenuItemUI.MAX_ICON_OFFSET, null);
          ((JPopupMenu)target).putClientProperty(
                                 BASICMENUITEMUI_MAX_TEXT_OFFSET, null);
        }
        return super.preferredLayoutSize(target);
    }
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar