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>JCheckBoxMenuItem</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 JCheckBoxMenuItem extends JMenuItem {
034: private static final long serialVersionUID = 7596676985032928624L;
035:
036: protected class AccessibleJCheckBoxMenuItem extends
037: AccessibleJMenuItem {
038: private static final long serialVersionUID = -5343091705345502936L;
039:
040: @Override
041: public AccessibleRole getAccessibleRole() {
042: return AccessibleRole.CHECK_BOX;
043: }
044: }
045:
046: private final static String UI_CLASS_ID = "CheckBoxMenuItemUI";
047:
048: public JCheckBoxMenuItem() {
049: this (null, null, false);
050: }
051:
052: public JCheckBoxMenuItem(Icon icon) {
053: this (null, icon, false);
054: }
055:
056: public JCheckBoxMenuItem(String text) {
057: this (text, null, false);
058: }
059:
060: public JCheckBoxMenuItem(String text, Icon icon) {
061: this (text, icon, false);
062: }
063:
064: public JCheckBoxMenuItem(String text, boolean selected) {
065: this (text, null, selected);
066: }
067:
068: public JCheckBoxMenuItem(String text, Icon icon, boolean selected) {
069: setDefaultModelAndFocus();
070: setSelected(selected);
071: init(text, icon);
072: }
073:
074: public JCheckBoxMenuItem(Action action) {
075: super (action);
076: }
077:
078: @Override
079: public String getUIClassID() {
080: return UI_CLASS_ID;
081: }
082:
083: public void setState(boolean b) {
084: setSelected(b);
085: }
086:
087: public boolean getState() {
088: return isSelected();
089: }
090:
091: @Override
092: public AccessibleContext getAccessibleContext() {
093: return (accessibleContext == null) ? (accessibleContext = new AccessibleJCheckBoxMenuItem())
094: : accessibleContext;
095: }
096:
097: @Override
098: ButtonModel createDefaultModel() {
099: return new JToggleButton.ToggleButtonModel();
100: }
101: }
|