Path: blob/master/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java
41154 views
/*1* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.apple.laf;2627import javax.swing.JComponent;28import javax.swing.ImageIcon;29import javax.swing.JRadioButton;30import javax.swing.Icon;31import javax.swing.AbstractButton;32import javax.swing.AbstractAction;33import javax.swing.KeyStroke;34import javax.swing.DefaultButtonModel;35import javax.swing.ButtonGroup;36import javax.swing.ButtonModel;37import javax.swing.plaf.ComponentUI;3839import java.awt.Component;40import java.awt.AWTKeyStroke;41import java.awt.KeyboardFocusManager;4243import java.awt.event.ActionEvent;44import java.awt.event.KeyListener;45import java.awt.event.KeyEvent;4647import apple.laf.JRSUIConstants.Widget;48import com.apple.laf.AquaUtilControlSize.SizeVariant;49import com.apple.laf.AquaUtilControlSize.SizeDescriptor;50import com.apple.laf.AquaUtils.RecyclableSingleton;51import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;5253import java.util.HashSet;54import java.util.Set;55import java.util.Enumeration;5657public class AquaButtonRadioUI extends AquaButtonLabeledUI {5859private static final RecyclableSingleton<AquaButtonRadioUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaButtonRadioUI>(AquaButtonRadioUI.class);60private static final RecyclableSingleton<ImageIcon> sizingIcon = new RecyclableSingleton<ImageIcon>() {61protected ImageIcon getInstance() {62return new ImageIcon(AquaNativeResources.getRadioButtonSizerImage());63}64};6566public static ComponentUI createUI(final JComponent b) {67return instance.get();68}6970public static Icon getSizingRadioButtonIcon() {71return sizingIcon.get();72}7374protected String getPropertyPrefix() {75return "RadioButton" + ".";76}7778protected AquaButtonBorder getPainter() {79return new RadioButtonBorder();80}8182public static class RadioButtonBorder extends LabeledButtonBorder {83public RadioButtonBorder() {84super(new SizeDescriptor(new SizeVariant().replaceMargins("RadioButton.margin")));85painter.state.set(Widget.BUTTON_RADIO);86}8788public RadioButtonBorder(final RadioButtonBorder other) {89super(other);90}91}92}939495