Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / combobutton / TestComboButton.java @ 40561

History | View | Annotate | Download (2.52 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.combobutton;
25

    
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28

    
29
import javax.swing.ImageIcon;
30
import javax.swing.JButton;
31

    
32
import org.gvsig.gui.beans.TestUI;
33
import org.gvsig.gui.beans.controls.combobutton.ComboButton;
34

    
35
public class TestComboButton implements ActionListener {
36
        
37
        public TestComboButton() {
38
                TestUI frame = new TestUI("TestComboButton");
39
                ComboButton cb = new ComboButton();
40
                ImageIcon icon1 = new ImageIcon(getClass().getResource("images/backward.png"));
41
                ImageIcon icon2 = new ImageIcon(getClass().getResource("images/forward.png"));
42
                JButton b1 = new JButton("Action 1", icon1);
43
                b1.addActionListener(new ActionListener() {
44
                        public void actionPerformed(ActionEvent arg0) {
45
                                System.out.println("Pulsando el bot?n 1");
46
                                System.out.println("Action command: " + arg0.getActionCommand());
47
                        }
48
                });
49
                b1.setActionCommand("action1");
50
                JButton b2 = new JButton("Action 2", icon2);
51
                b2.addActionListener(new ActionListener() {
52
                        public void actionPerformed(ActionEvent arg0) {
53
                                System.out.println("Pulsando el bot?n 2");
54
                                System.out.println("Action command: " + arg0.getActionCommand());
55
                        }
56
                });
57
                b2.setActionCommand("action2");
58
                cb.setName("Prueba");
59
                cb.addButton(b1);
60
                cb.addSeparator();
61
                cb.addButton(b2);
62
                cb.addActionListener(this);
63
                frame.getContentPane().add(cb);
64
                frame.setSize(80, 80);
65
                frame.setVisible(true);
66
        }
67
        
68

    
69
        public static void main(String[] args) {
70
                new TestComboButton();
71
        }
72

    
73

    
74
        public void actionPerformed(ActionEvent e) {
75
                System.out.println("actionPerformed() : " + e.getActionCommand());
76
        }
77
}