KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > basic > DefaultMenuLayout


1 /*
2  * @(#)DefaultMenuLayout.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.basic;
9
10 import javax.swing.*;
11 import javax.swing.plaf.UIResource JavaDoc;
12
13 import java.awt.Container JavaDoc;
14 import java.awt.Dimension JavaDoc;
15
16 /**
17  * The default layout manager for Popup menus and menubars. This
18  * class is an extension of BoxLayout which adds the UIResource tag
19  * so that plauggable L&Fs can distinguish it from user-installed
20  * layout managers on menus.
21  *
22  * @version 1.8 12/19/03
23  * @author Georges Saab
24  */

25
26 public class DefaultMenuLayout extends BoxLayout implements UIResource JavaDoc {
27     public DefaultMenuLayout(Container JavaDoc target, int axis) {
28     super(target, axis);
29     }
30
31     public Dimension JavaDoc preferredLayoutSize(Container JavaDoc target) {
32         if (target instanceof JPopupMenu) {
33           ((JPopupMenu)target).putClientProperty(
34                                  BasicMenuItemUI.MAX_TEXT_WIDTH, null);
35           ((JPopupMenu)target).putClientProperty(
36                                  BasicMenuItemUI.MAX_ACC_WIDTH, null);
37         }
38         return super.preferredLayoutSize(target);
39     }
40 }
41
Popular Tags