OSDN Git Service

* javax/naming/CompoundName.java (CompoundName): Don't check for
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / JSeparator.java
1 /* JSeparator.java --
2    Copyright (C) 2002, 2004 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38 package javax.swing;
39
40 import javax.accessibility.Accessible;
41 import javax.accessibility.AccessibleContext;
42 import javax.accessibility.AccessibleRole;
43 import javax.swing.plaf.SeparatorUI;
44
45
46 /**
47  * The JSeparator. It is mostly used to divide/space out
48  * components.
49  */
50 public class JSeparator extends JComponent implements SwingConstants,
51                                                       Accessible
52 {
53   /**
54    * AccessibleJSeparator
55    */
56   protected class AccessibleJSeparator extends AccessibleJComponent
57   {
58     private static final long serialVersionUID = 916332890553201095L;
59   
60     /**
61      * Constructor AccessibleJSeparator
62      *
63      * @param component TODO
64      */
65     protected AccessibleJSeparator()
66     {
67     }
68
69     /**
70      * getAccessibleRole
71      *
72      * @return AccessibleRole
73      */
74     public AccessibleRole getAccessibleRole()
75     {
76       return AccessibleRole.SEPARATOR;
77     }
78   }
79
80   private static final long serialVersionUID = 125301223445282357L;
81   
82   /** The orientation of the JSeparator. */
83   private transient int orientation = HORIZONTAL;
84
85   /**
86    * Creates a new horizontal JSeparator object.
87    */
88   public JSeparator()
89   {
90     this(HORIZONTAL);
91   }
92
93   /**
94    * Creates a new JSeparator object with the given orientation.
95    *
96    * @param orientation The orientation of the JSeparator.
97    */
98   public JSeparator(int orientation)
99   {
100     if (orientation != HORIZONTAL && orientation != VERTICAL)
101       throw new IllegalArgumentException(orientation
102                                          + " is not a valid orientation.");
103     this.orientation = orientation;
104     updateUI();
105   }
106
107   /**
108    * This method returns the UI delegate being
109    * used with the JSeparator.
110    *
111    * @return SeparatorUI The JSeparator's UI delegate.
112    */
113   public SeparatorUI getUI()
114   {
115     return (SeparatorUI) ui;
116   }
117
118   /**
119    * This method sets the UI delegate to use
120    * with the JSeparator.
121    *
122    * @param ui The UI delegate to use.
123    */
124   public void setUI(SeparatorUI ui)
125   {
126     super.setUI(ui);
127   }
128
129   /**
130    * This method resets the UI delegate to the 
131    * default for the current look and feel.
132    */
133   public void updateUI()
134   {
135     setUI((SeparatorUI) UIManager.getUI(this));
136     invalidate();
137   }
138
139   /**
140    * This method returns the identifier string
141    * that is used to determine the UI delegate
142    * from the current look and feel.
143    *
144    * @return String The identifier string for the UI.
145    */
146   public String getUIClassID()
147   {
148     return "SeparatorUI";
149   }
150
151   /**
152    * This method returns the JSeparator's orientation.
153    *
154    * @return int The JSeparator's orientation.
155    */
156   public int getOrientation()
157   {
158     return orientation;
159   }
160
161   /**
162    * This method changes the JSeparator's orientation.
163    *
164    * @param orientation The JSeparator's orientation.
165    */
166   public void setOrientation(int orientation)
167   {
168     if (orientation != HORIZONTAL && orientation != VERTICAL)
169       throw new IllegalArgumentException(orientation
170                                          + " is not a valid orientation.");
171     this.orientation = orientation;
172   }
173
174   /**
175    * This method returns a string desribing the JSeparator.
176    * Normally only used in debugging.
177    *
178    * @return String A string describing the JSeparator.
179    */
180   protected String paramString()
181   {
182     return "JSeparator";
183   }
184
185   /**
186    * This method overrides the isFocusTraversable method from
187    * Component to false. JSeparator cannot be focused on.
188    *
189    * @return boolean False.
190    */
191   public boolean isFocusTraversable()
192   {
193     return false;
194   }
195
196   /**
197    * getAccessibleContext
198    *
199    * @return AccessibleContext
200    */
201   public AccessibleContext getAccessibleContext()
202   {
203     if (accessibleContext == null)
204       accessibleContext = new AccessibleJSeparator();
205     
206     return accessibleContext;
207   }
208 }