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: * @author Alexander T. Simbirtsev
019: * @version $Revision$
020: */package javax.swing;
021:
022: import javax.accessibility.AccessibleContext;
023: import javax.accessibility.AccessibleRole;
024:
025: public class JRadioButton extends JToggleButton {
026: protected class AccessibleJRadioButton extends
027: AccessibleJToggleButton {
028: public AccessibleRole getAccessibleRole() {
029: return AccessibleRole.RADIO_BUTTON;
030: }
031: };
032:
033: private static final String UI_CLASS_ID = "RadioButtonUI";
034:
035: // this constant is also used by JCheckBox
036: static final Object NO_ICON_ACTION_PROPERTIES = new Object() { //$NON-LOCK-1$
037: public boolean equals(final Object o) {
038: return !Action.SMALL_ICON.equals(o);
039: }
040: };
041:
042: public JRadioButton() {
043: super (null, null, false);
044: }
045:
046: public JRadioButton(final Action action) {
047: super (action);
048: }
049:
050: public JRadioButton(final Icon icon) {
051: super (null, icon, false);
052: }
053:
054: public JRadioButton(final Icon icon, final boolean selected) {
055: super (null, icon, selected);
056: }
057:
058: public JRadioButton(final String text) {
059: super (text, null, false);
060: }
061:
062: public JRadioButton(final String text, final boolean selected) {
063: super (text, null, selected);
064: }
065:
066: public JRadioButton(final String text, final Icon icon) {
067: super (text, icon, false);
068: }
069:
070: public JRadioButton(final String text, final Icon icon,
071: final boolean selected) {
072: super (text, icon, selected);
073: }
074:
075: void configurePropertyFromAction(final Action action,
076: final Object propertyName) {
077: if (propertyName == null
078: || propertyName.equals(Action.SMALL_ICON)) {
079: return;
080: }
081: super .configurePropertyFromAction(action, propertyName);
082: }
083:
084: protected void init(final String text, final Icon icon) {
085: setHorizontalAlignment(LEADING);
086: super .init(text, icon);
087: }
088:
089: public AccessibleContext getAccessibleContext() {
090: return (accessibleContext == null) ? (accessibleContext = new AccessibleJRadioButton())
091: : accessibleContext;
092: }
093:
094: public String getUIClassID() {
095: return UI_CLASS_ID;
096: }
097:
098: Object getActionPropertiesFilter() {
099: return NO_ICON_ACTION_PROPERTIES;
100: }
101: }
|