Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1011 / libraries / libCq_CMS_praster / src / org / cresques / ui / DefaultTabPanel.java @ 12904

History | View | Annotate | Download (3.31 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.ui;
25

    
26
import java.awt.GridBagConstraints;
27
import java.awt.event.ComponentEvent;
28
import java.awt.event.ComponentListener;
29
import java.awt.event.MouseEvent;
30
import java.awt.event.MouseListener;
31

    
32
import javax.swing.JPanel;
33
import javax.swing.JTabbedPane;
34
import javax.swing.event.ChangeEvent;
35
import javax.swing.event.ChangeListener;
36

    
37

    
38
/**
39
 * Panel del que heredaran los paneles que contengan tabs
40
 * @author Nacho Brodin (brodin_ign@gva.es)
41
 */
42
public class DefaultTabPanel extends DefaultDialogPanel implements ComponentListener, ChangeListener{
43
    final private static long serialVersionUID = -3370601314380922368L;
44
    protected JTabbedPane tabbedPane = null;
45

    
46
    /**
47
     * Contructor
48
     */
49
    public DefaultTabPanel() {
50
        super();
51
        this.setBounds(0, 0, 355, 230);
52
        this.getContentPanel();
53
        this.getTabPane();
54
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
55
        gridBagConstraints6.gridy = 0;
56
        gridBagConstraints6.gridx = 0;
57
        contentPane.add(tabbedPane, gridBagConstraints6);
58
        tabbedPane.addChangeListener(this);
59
    }
60

    
61

    
62
        /**
63
     * Obtiene el Componente JTabbedPane
64
     * @return Componente JTabbedPane
65
     */
66
    private JTabbedPane getTabPane() {
67
        if (tabbedPane == null) {
68
            tabbedPane = new JTabbedPane();
69
            tabbedPane.setLocation(0,0);
70
        }
71

    
72
        return tabbedPane;
73
    }
74

    
75
    /**
76
     * A?ade un tab al JTabbedPane
77
     * @param title        T?tulo del tab
78
     * @param panel        Panel del nuevo tab
79
     */
80
    public void addTab(String title, JPanel panel) {
81
        tabbedPane.add(title, panel);
82
    }
83

    
84
    /**
85
     * Obtiene el JTabbedPane
86
     * @return JTabbedPane
87
     */
88
    public JTabbedPane getTab() {
89
        return tabbedPane;
90
    }
91

    
92
        public void componentResized(ComponentEvent e) {
93
                if(e.getSource() ==  this){
94
                        super.componentResized(e);
95
                        this.tabbedPane.setSize(this.tabbedPane.getSize().width + difWidth, this.tabbedPane.getSize().height + difHeight);
96
                        this.setLocation(0,0);
97
                        
98
                }
99
                
100
        }
101

    
102
        public void stateChanged(ChangeEvent ev) {
103
                
104
                /*if (ev.getSource().getClass().toString().endsWith("JTabbedPane")) {
105
                        if (((JTabbedPane)ev.getSource()).getSelectedIndex() == 1){
106
                                super.resizeWindow();
107
                                this.tabbedPane.setSize(this.tabbedPane.getSize().width + difWidth, this.tabbedPane.getSize().height + difHeight);
108
                                this.setLocation(0,0);
109
                        }
110
                }*/
111
        }
112
}  //  @jve:decl-index=0:visual-constraint="13,18"