PopButtonGroup.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
17 package com.generalrobotix.ui.view.tdview;
18 
19 import java.awt.event.ActionListener;
20 import java.awt.event.ActionEvent;
21 import javax.swing.*;
22 
26 @SuppressWarnings("serial")
27 public class PopButtonGroup extends ButtonGroup implements ActionListener {
28  //--------------------------------------------------------------------
29  // Instance variables
30  private AbstractButton prevButton_;
31  private JToggleButton hidden_;
32 
33  //--------------------------------------------------------------------
34  // Constructor
35  public PopButtonGroup() {
36  hidden_ = new JToggleButton();
37  hidden_.setVisible(false);
38  super.add(hidden_);
39  }
40 
41  //--------------------------------------------------------------------
42  // Public methods
43  public void addActionListener(ActionListener listener) {
44  hidden_.addActionListener(listener);
45  }
46 
47  public void removeActionListener(ActionListener listener) {
48  hidden_.removeActionListener(listener);
49  }
50 
51  public void selectNone() {
52  hidden_.setSelected(true);
53  }
54 
55  //--------------------------------------------------------------------
56  // Override
57  public void add(AbstractButton button) {
58  button.addActionListener(this);
59  super.add(button);
60  }
61 
62  public void remove(AbstractButton button) {
63  button.removeActionListener(this);
64  super.remove(button);
65  }
66 
67  //--------------------------------------------------------------------
68  // Implementation of ActionListener
69  public void actionPerformed(ActionEvent evt) {
70  if (evt.getSource() == prevButton_) {
71  //hidden_.setSelected(true);
72  SwingUtilities.invokeLater(
73  new Runnable() {
74  public void run() {
75  hidden_.doClick();
76  prevButton_ = hidden_;
77  }
78  }
79  );
80  } else {
81  prevButton_ = (AbstractButton)evt.getSource();
82  }
83  }
84 }
def run(tree, args)
void addActionListener(ActionListener listener)
void removeActionListener(ActionListener listener)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:25