PopButtonGroup.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00017 package com.generalrobotix.ui.view.tdview;
00018 
00019 import java.awt.event.ActionListener;
00020 import java.awt.event.ActionEvent;
00021 import javax.swing.*;
00022 
00026 @SuppressWarnings("serial")
00027 public class PopButtonGroup extends ButtonGroup implements ActionListener {
00028     //--------------------------------------------------------------------
00029     // Instance variables
00030     private AbstractButton prevButton_;
00031     private JToggleButton hidden_;
00032 
00033     //--------------------------------------------------------------------
00034     // Constructor
00035     public PopButtonGroup() {
00036         hidden_ = new JToggleButton();
00037         hidden_.setVisible(false);
00038         super.add(hidden_);
00039     }
00040 
00041     //--------------------------------------------------------------------
00042     // Public methods
00043     public void addActionListener(ActionListener listener) {
00044         hidden_.addActionListener(listener);
00045     }
00046 
00047     public void removeActionListener(ActionListener listener) {
00048         hidden_.removeActionListener(listener);
00049     }
00050 
00051     public void selectNone() {
00052         hidden_.setSelected(true);
00053     }
00054 
00055     //--------------------------------------------------------------------
00056     // Override
00057     public void add(AbstractButton button) {
00058         button.addActionListener(this);
00059         super.add(button);
00060     }
00061 
00062     public void remove(AbstractButton button) {
00063         button.removeActionListener(this);
00064         super.remove(button);
00065     }
00066 
00067     //--------------------------------------------------------------------
00068     // Implementation of ActionListener
00069     public void actionPerformed(ActionEvent evt) {
00070         if (evt.getSource() == prevButton_) {
00071             //hidden_.setSelected(true);
00072             SwingUtilities.invokeLater(
00073                 new Runnable() {
00074                      public void run() {
00075                          hidden_.doClick();
00076                          prevButton_ = hidden_;
00077                      }
00078                 }
00079             );
00080         } else {
00081             prevButton_ = (AbstractButton)evt.getSource();
00082         }
00083     }
00084 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:56