Statistics
| Revision:

root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / defaultbuttonspanel / DefaultButtonsPanel.java @ 10948

History | View | Annotate | Download (3.95 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.defaultbuttonspanel;
20

    
21
import java.awt.Component;
22
import java.awt.LayoutManager;
23

    
24
import javax.swing.JPanel;
25

    
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27
/**
28
 * <code>DialogPanel</code> es un Panel que hereda de <code>JPanel</code> con
29
 * el a?adido de poder definir una botonera por defecto.
30
 *
31
 * @version 15/03/2007
32
 * @author Borja Sanchez Zamorano (borja.sanchez@iver.es)
33
 */
34
public class DefaultButtonsPanel extends JPanel {
35
        private static final long serialVersionUID = 1519536113682350563L;
36
        ButtonsPanel bp = null;
37
        JPanel content = null;
38

    
39
        /**
40
         * Crea el <code>DialogPanel</code> con los botones por defecto.
41
         */
42
        public DefaultButtonsPanel() {
43
    super.setLayout(new java.awt.BorderLayout(5, 5));
44
                getButtonsPanel().addAccept();
45
                getButtonsPanel().addCancel();
46
                getButtonsPanel().addApply();
47
                super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
48
                super.add(getContent(), java.awt.BorderLayout.CENTER);
49
        }
50
        
51
        /**
52
         * Crea el <code>DialogPanel</code> con los botones que definamos de la clase
53
         * <code>ButtonsPanel</code>
54
         * 
55
         * @param buttons Constante para definir que botones se crear?n
56
         */
57
        public DefaultButtonsPanel(int buttons) {
58
    super.setLayout(new java.awt.BorderLayout(5, 5));                
59
                bp = new ButtonsPanel(buttons);
60
                super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
61
                super.add(getContent(), java.awt.BorderLayout.CENTER);
62
        }
63
        
64
        /**
65
         * Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>.
66
         * En caso de no estar creado, lo crear?.
67
         * 
68
         * @return El componente bp
69
         */
70
        public ButtonsPanel getButtonsPanel() {
71
                if (bp == null)
72
                        bp = new ButtonsPanel();
73
                return bp;
74
        }
75

    
76
        /**
77
         * Obtener el contenido del <code>DialogPanel</code>. En caso de no estar creado,
78
         * lo crear?.
79
         * 
80
         * @return El componente content
81
         */
82
        public JPanel getContent() {
83
                if (content == null)
84
                        content = new JPanel();
85
                return content;
86
        }
87

    
88
        /*
89
         * (non-Javadoc)
90
         * @see java.awt.Container#getLayout()
91
         */
92
        public LayoutManager getLayout() {
93
                return getContent().getLayout();
94
        }
95
        
96
        /*
97
         * (non-Javadoc)
98
         * @see java.awt.Container#setLayout(java.awt.LayoutManager)
99
         */
100
        public void setLayout(LayoutManager mgr) {
101
                getContent().setLayout(mgr);
102
        }
103

    
104
        /*
105
         * (non-Javadoc)
106
         * @see java.awt.Container#add(java.awt.Component)
107
         */
108
        public Component add(Component comp) {
109
                return getContent().add(comp);
110
        }
111

    
112
        /*
113
         * (non-Javadoc)
114
         * @see java.awt.Container#add(java.awt.Component, int)
115
         */
116
        public Component add(Component comp, int index) {
117
                return getContent().add(comp, index);
118
        }
119
  
120
        /*
121
         * (non-Javadoc)
122
         * @see java.awt.Container#add(java.awt.Component, java.lang.Object)
123
         */
124
        public void add(Component comp, Object constraints) {
125
                getContent().add(comp, constraints);
126
        }
127
  
128
        /*
129
         * (non-Javadoc)
130
         * @see java.awt.Container#add(java.awt.Component, java.lang.Object, int)
131
         */
132
        public void add(Component comp, Object constraints, int index) {
133
                getContent().add(comp, constraints, index);
134
        }
135
  
136
        /*
137
         * (non-Javadoc)
138
         * @see java.awt.Container#add(java.lang.String, java.awt.Component)
139
         */
140
        public Component add(String name, Component comp) {
141
                return getContent().add(name, comp);
142
        }
143
}