2 Copyright (C) 2002, 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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)
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.
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
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
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. */
40 import javax.accessibility.Accessible;
41 import javax.accessibility.AccessibleContext;
42 import javax.accessibility.AccessibleRole;
43 import javax.swing.plaf.SeparatorUI;
47 * The JSeparator. It is mostly used to divide/space out
50 public class JSeparator extends JComponent implements SwingConstants,
54 * AccessibleJSeparator
56 protected class AccessibleJSeparator extends AccessibleJComponent
59 * Constructor AccessibleJSeparator
61 * @param component TODO
63 protected AccessibleJSeparator(JSeparator component)
71 * @return AccessibleRole
73 public AccessibleRole getAccessibleRole()
75 return AccessibleRole.SEPARATOR;
79 /** The orientation of the JSeparator. */
80 private transient int orientation = HORIZONTAL;
83 * Creates a new horizontal JSeparator object.
91 * Creates a new JSeparator object with the given orientation.
93 * @param orientation The orientation of the JSeparator.
95 public JSeparator(int orientation)
97 if (orientation != HORIZONTAL && orientation != VERTICAL)
98 throw new IllegalArgumentException(orientation
99 + " is not a valid orientation.");
100 this.orientation = orientation;
105 * This method returns the UI delegate being
106 * used with the JSeparator.
108 * @return SeparatorUI The JSeparator's UI delegate.
110 public SeparatorUI getUI()
112 return (SeparatorUI) ui;
116 * This method sets the UI delegate to use
117 * with the JSeparator.
119 * @param ui The UI delegate to use.
121 public void setUI(SeparatorUI ui)
127 * This method resets the UI delegate to the
128 * default for the current look and feel.
130 public void updateUI()
132 setUI((SeparatorUI) UIManager.getUI(this));
137 * This method returns the identifier string
138 * that is used to determine the UI delegate
139 * from the current look and feel.
141 * @return String The identifier string for the UI.
143 public String getUIClassID()
145 return "SeparatorUI";
149 * This method returns the JSeparator's orientation.
151 * @return int The JSeparator's orientation.
153 public int getOrientation()
159 * This method changes the JSeparator's orientation.
161 * @param orientation The JSeparator's orientation.
163 public void setOrientation(int orientation)
165 if (orientation != HORIZONTAL && orientation != VERTICAL)
166 throw new IllegalArgumentException(orientation
167 + " is not a valid orientation.");
168 this.orientation = orientation;
172 * This method returns a string desribing the JSeparator.
173 * Normally only used in debugging.
175 * @return String A string describing the JSeparator.
177 protected String paramString()
183 * This method overrides the isFocusTraversable method from
184 * Component to false. JSeparator cannot be focused on.
186 * @return boolean False.
188 public boolean isFocusTraversable()
194 * getAccessibleContext
196 * @return AccessibleContext
198 public AccessibleContext getAccessibleContext()
200 if (accessibleContext == null)
201 accessibleContext = new AccessibleJSeparator(this);
202 return accessibleContext;