001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.swing;
019:
020: import javax.accessibility.AccessibleContext;
021: import javax.accessibility.AccessibleRole;
022:
023: /**
024: * <p>
025: * <i>JCheckBox</i>
026: * </p>
027: * <h3>Implementation Notes:</h3>
028: * <ul>
029: * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
030: * optimization, not as a guarantee of serialization compatibility.</li>
031: * </ul>
032: */
033: public class JCheckBox extends JToggleButton {
034: private static final long serialVersionUID = 2823978782065130270L;
035:
036: protected class AccessibleJCheckBox extends AccessibleJToggleButton {
037: private static final long serialVersionUID = -7895379006459422318L;
038:
039: @Override
040: public AccessibleRole getAccessibleRole() {
041: return AccessibleRole.CHECK_BOX;
042: }
043: }
044:
045: public static final String BORDER_PAINTED_FLAT_CHANGED_PROPERTY = "borderPaintedFlat";
046:
047: private static final String UI_CLASS_ID = "CheckBoxUI";
048:
049: private boolean borderPaintedFlat;
050:
051: public JCheckBox() {
052: super (null, null, false);
053: }
054:
055: public JCheckBox(Action action) {
056: super (action);
057: }
058:
059: public JCheckBox(Icon icon) {
060: super (null, icon, false);
061: }
062:
063: public JCheckBox(Icon icon, boolean selected) {
064: super (null, icon, selected);
065: }
066:
067: public JCheckBox(String text) {
068: super (text, null, false);
069: }
070:
071: public JCheckBox(String text, boolean selected) {
072: super (text, null, selected);
073: }
074:
075: public JCheckBox(String text, Icon icon) {
076: super (text, icon, false);
077: }
078:
079: public JCheckBox(String text, Icon icon, boolean selected) {
080: super (text, icon, selected);
081: }
082:
083: @Override
084: void configurePropertyFromAction(Action action, Object propertyName) {
085: if (propertyName == null
086: || propertyName.equals(Action.SMALL_ICON)) {
087: return;
088: }
089: super .configurePropertyFromAction(action, propertyName);
090: }
091:
092: @Override
093: protected void init(String text, Icon icon) {
094: setHorizontalAlignment(LEADING);
095: super .init(text, icon);
096: }
097:
098: @Override
099: public AccessibleContext getAccessibleContext() {
100: return (accessibleContext == null) ? (accessibleContext = new AccessibleJCheckBox())
101: : accessibleContext;
102: }
103:
104: @Override
105: public String getUIClassID() {
106: return UI_CLASS_ID;
107: }
108:
109: public boolean isBorderPaintedFlat() {
110: return borderPaintedFlat;
111: }
112:
113: public void setBorderPaintedFlat(boolean paintedFlat) {
114: boolean oldValue = borderPaintedFlat;
115: borderPaintedFlat = paintedFlat;
116: firePropertyChange(BORDER_PAINTED_FLAT_CHANGED_PROPERTY,
117: oldValue, borderPaintedFlat);
118: }
119:
120: @Override
121: Object getActionPropertiesFilter() {
122: return JRadioButton.NO_ICON_ACTION_PROPERTIES;
123: }
124: }
|