KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > motif > MotifOptionPaneUI


1 /*
2  * @(#)MotifOptionPaneUI.java 1.17 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 com.sun.java.swing.plaf.motif;
9
10 import javax.swing.*;
11 import javax.swing.plaf.basic.BasicOptionPaneUI JavaDoc;
12 import javax.swing.plaf.ComponentUI JavaDoc;
13 import java.awt.Color JavaDoc;
14 import java.awt.Component JavaDoc;
15 import java.awt.Container JavaDoc;
16 import java.awt.Dimension JavaDoc;
17 import java.awt.Graphics JavaDoc;
18 import java.awt.Insets JavaDoc;
19 import java.awt.Rectangle JavaDoc;
20
21 /**
22  * Provides the CDE/Motif look and feel for a JOptionPane.
23  * <p>
24  * <strong>Warning:</strong>
25  * Serialized objects of this class will not be compatible with
26  * future Swing releases. The current serialization support is appropriate
27  * for short term storage or RMI between applications running the same
28  * version of Swing. A future release of Swing will provide support for
29  * long term persistence.
30  *
31  * @version 1.17 12/19/03
32  * @author Scott Violet
33  */

34 public class MotifOptionPaneUI extends BasicOptionPaneUI JavaDoc
35 {
36     /**
37       * Creates a new MotifOptionPaneUI instance.
38       */

39     public static ComponentUI JavaDoc createUI(JComponent x) {
40     return new MotifOptionPaneUI();
41     }
42
43     /**
44      * Creates and returns a Container containin the buttons. The buttons
45      * are created by calling <code>getButtons</code>.
46      */

47     protected Container JavaDoc createButtonArea() {
48     Container JavaDoc b = super.createButtonArea();
49
50     if(b != null && b.getLayout() instanceof ButtonAreaLayout) {
51         ((ButtonAreaLayout)b.getLayout()).setCentersChildren(false);
52     }
53     return b;
54     }
55
56     /**
57      * Returns null, CDE/Motif does not impose a minimum size.
58      */

59     public Dimension JavaDoc getMinimumOptionPaneSize() {
60     return null;
61     }
62
63     protected Container JavaDoc createSeparator() {
64         return new JPanel() {
65
66             public Dimension JavaDoc getPreferredSize() {
67                 return new Dimension JavaDoc(10, 2);
68             }
69
70             public void paint(Graphics JavaDoc g) {
71                 int width = getWidth();
72             g.setColor(Color.darkGray);
73             g.drawLine(0, 0, width, 0);
74             g.setColor(Color.white);
75             g.drawLine(0, 1, width, 1);
76             }
77     };
78     }
79
80     /**
81      * Creates and adds a JLabel representing the icon returned from
82      * <code>getIcon</code> to <code>top</code>. This is messaged from
83      * <code>createMessageArea</code>
84      */

85     protected void addIcon(Container JavaDoc top) {
86     /* Create the icon. */
87     Icon sideIcon = getIcon();
88
89     if (sideIcon != null) {
90         JLabel iconLabel = new JLabel(sideIcon);
91
92         iconLabel.setVerticalAlignment(SwingConstants.CENTER);
93         top.add(iconLabel, "West");
94     }
95     }
96
97 }
98
Popular Tags