01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexander T. Simbirtsev
19: * @version $Revision$
20: */package javax.swing;
21:
22: import javax.accessibility.Accessible;
23: import javax.accessibility.AccessibleContext;
24: import javax.accessibility.AccessibleRole;
25: import javax.swing.plaf.SeparatorUI;
26:
27: import org.apache.harmony.x.swing.internal.nls.Messages;
28:
29: public class JSeparator extends JComponent implements SwingConstants,
30: Accessible {
31:
32: protected class AccessibleJSeparator extends AccessibleJComponent {
33: public AccessibleRole getAccessibleRole() {
34: return AccessibleRole.SEPARATOR;
35: }
36: }
37:
38: private final static String UI_CLASS_ID = "SeparatorUI";
39:
40: private int orientation;
41:
42: public JSeparator() {
43: this (SwingConstants.HORIZONTAL);
44: }
45:
46: public JSeparator(final int orientation) {
47: checkOrientation(orientation);
48: this .orientation = orientation;
49: setFocusable(false);
50: updateUI();
51: }
52:
53: public SeparatorUI getUI() {
54: return (SeparatorUI) ui;
55: }
56:
57: public void setUI(final SeparatorUI ui) {
58: super .setUI(ui);
59: }
60:
61: public void updateUI() {
62: setUI(UIManager.getUI(this ));
63: }
64:
65: public String getUIClassID() {
66: return UI_CLASS_ID;
67: }
68:
69: public int getOrientation() {
70: return orientation;
71: }
72:
73: public void setOrientation(final int orientation) {
74: checkOrientation(orientation);
75: this .orientation = orientation;
76: }
77:
78: public AccessibleContext getAccessibleContext() {
79: return (accessibleContext == null) ? (accessibleContext = new AccessibleJSeparator())
80: : accessibleContext;
81: }
82:
83: private void checkOrientation(final int orientation) {
84: if (orientation == SwingConstants.HORIZONTAL
85: || orientation == SwingConstants.VERTICAL) {
86: return;
87: }
88:
89: throw new IllegalArgumentException(Messages
90: .getString("swing.47")); //$NON-NLS-1$
91: }
92:
93: }
|