Java - Fuera del sitio ...

 
Vista:
sin imagen de perfil

Fuera del sitio ...

Publicado por Cesar Santos (4 intervenciones) el 28/03/2015 10:04:35
AYUDA !!!! ...

Por que se descoloca el interface cuando pulso en alguna de las pestañas del JTabbedPane .... ???????

package ERP;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
 
/**
 *
 * @author Cesar Santos
 */
public class ERPGui extends JFrame implements ActionListener{
    int nivel;
    private String tiponivel;
 
    JFrame Contenedor;
    JPanel MenuSuperior , MenuLateral , Contenido;
    JMenu jmArchivo, jmEdicion , jmInforme, jmConfiguracion, jmAyuda;
    JMenuItem jmiNuevo , jmiGuardar , jmiSalir , jmiImprimir ;
    JMenuItem jmiCopiar , jmiPegar , jmiDeshacer ;
    JMenuItem jmiCrearPDF;
    JMenuItem jmiInforme;
    JMenuItem jmiConfigurarBBDD;
    JMenuItem jmiAyuda;
    JMenuBar mjbMenuSuperior;
 
    JButton jbClientes , jbProveedores , jbAlmacen ;
    JButton jbMantenimientos , jbObras , jbPartes;
    JButton jbUsuarios , jbConfiguracion;
 
    ImageIcon iiClientes , iiProveedores , iiAlmacen ;
    ImageIcon iiMantenimientos, iiObras , iiPartes;
    ImageIcon iiUsuarios, iiConfiguracion;
 
 
//Asigna el nivel a una variable privada.    
 
    public ERPGui(int nivel){
 
        this.nivel=nivel;
        if (nivel == 1 ){
            tiponivel = "Administrador";
        }
        if (nivel == 2 ){
            tiponivel = "Gestor";
        }
 
        CrearGUI();
 
    }
 
// Metodo para crear la estructura fija del GUI
 
    public void CrearGUI(){
 
// Creamos los contenedores ----------------------------------------------------
 
        Contenedor = new JFrame();
        Contenedor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Contenedor.setSize(1024,720);
        Contenedor.setTitle("ERP");
        Contenedor.setVisible(true);
        Contenedor.setResizable(false);
        Contenedor.setLocationRelativeTo(null);
 
        MenuSuperior = new JPanel(new FlowLayout(FlowLayout.LEFT));
        MenuSuperior.setBounds(0, 0, 1024, 35);
        MenuSuperior.setBackground(Color.ORANGE);
 
        MenuLateral = new JPanel();
        MenuLateral.setLayout(new GridLayout(10,1));
        MenuLateral.setBounds(0,34,180,685);
        MenuLateral.setBackground(Color.ORANGE);
 
        Contenido = new JPanel();
        Contenido.setBounds(180,35,843,685);
        //Contenido.setBackground(Color.BLUE);
 
 
        Contenedor.add(MenuSuperior);
        Contenedor.add(MenuLateral);
        Contenedor.add(Contenido);
 
// Inicializamos los items del menu superior -----------------------------------        
 
        JMenuBar jmbMenuSuperior = new JMenuBar();
 
            jmArchivo = new JMenu();
            jmArchivo.setText("Archivo");
 
 
                jmiGuardar = new JMenuItem("Guardar");
                jmiGuardar.addActionListener(this);
                jmiSalir = new JMenuItem("Salir");
                jmiSalir.addActionListener(this);
 
 
            jmEdicion = new JMenu();
            jmEdicion.setText("Edicion");
 
 
                jmiCopiar = new JMenuItem("Copiar");
                jmiCopiar.addActionListener(this);
                jmiPegar = new JMenuItem("Pegar");
                jmiPegar.addActionListener(this);
                jmiDeshacer = new JMenuItem("Dehacer");
                jmiDeshacer.addActionListener(this);
 
            jmInforme = new JMenu();
            jmInforme.setText("Informes");
 
 
                jmiInforme = new JMenuItem("CrearPDF");
                jmiInforme.addActionListener(this);
 
            jmConfiguracion = new JMenu();
            jmConfiguracion.setText("Configuración");
 
                jmiConfigurarBBDD = new JMenuItem("Configurar BBDD");
                jmiConfigurarBBDD.addActionListener(this);
 
            jmAyuda = new JMenu();
            jmAyuda.setText("Ayuda");
 
                jmiAyuda = new JMenuItem("Ayuda");
                jmiAyuda.addActionListener(this);
 
 
// Inicializamos los botones del menu lateral ----------------------------------
 
        jbClientes = new JButton();
        iiClientes = new ImageIcon("src/IconosBotones/clientes.jpg");
        jbClientes.setIcon(iiClientes);
        jbClientes.addActionListener(this);
 
        jbProveedores = new JButton();
        iiProveedores = new ImageIcon("src/IconosBotones/proveedores.jpg");
        jbProveedores.setIcon(iiProveedores);
        jbProveedores.addActionListener(this);
 
        jbAlmacen = new JButton();
        iiAlmacen = new ImageIcon("src/IconosBotones/almacen.jpg");
        jbAlmacen.setIcon(iiAlmacen);
        jbAlmacen.addActionListener(this);
 
        jbObras = new JButton();
        iiObras = new ImageIcon("src/IconosBotones/obras.jpg");
        jbObras.setIcon(iiObras);
        jbObras.addActionListener(this);
 
        jbMantenimientos = new JButton();
        iiMantenimientos = new ImageIcon("src/IconosBotones/mantenimiento.jpg");
        jbMantenimientos.setIcon(iiMantenimientos);
        jbMantenimientos.addActionListener(this);
 
        jbPartes = new JButton();
        iiPartes = new ImageIcon("src/IconosBotones/partes.jpg");
        jbPartes.setIcon(iiPartes);
        jbPartes.addActionListener(this);
 
        jbUsuarios = new JButton();
        iiUsuarios = new ImageIcon("src/IconosBotones/usuarios.jpg");
        jbUsuarios.setIcon(iiUsuarios);
        jbUsuarios.addActionListener(this);
 
        jbConfiguracion = new JButton();
        iiConfiguracion = new ImageIcon("src/IconosBotones/configuracion.jpg");
        jbConfiguracion.setIcon(iiConfiguracion);
        jbConfiguracion.addActionListener(this);
 
 
// Generamos los menus ---------------------------------------------------------
 
        MenuSuperior.add(jmbMenuSuperior);
 
        jmbMenuSuperior.add(jmArchivo);
        jmArchivo.add(jmiGuardar);
        jmArchivo.add(jmiSalir);
 
        jmbMenuSuperior.add(jmEdicion);
        jmEdicion.add(jmiCopiar);
        jmEdicion.add(jmiPegar);
        jmEdicion.add(jmiDeshacer);
 
        jmbMenuSuperior.add(jmInforme);
        jmInforme.add(jmiInforme);
 
        jmbMenuSuperior.add(jmConfiguracion);
        jmConfiguracion.add(jmiConfigurarBBDD);
 
        jmbMenuSuperior.add(jmAyuda);
        jmAyuda.add(jmiAyuda);
 
        MenuLateral.add(jbClientes);
        MenuLateral.add(jbProveedores);
        MenuLateral.add(jbAlmacen);
        MenuLateral.add(jbObras);
        MenuLateral.add(jbMantenimientos);
        MenuLateral.add(jbPartes);
        MenuLateral.add(jbUsuarios);
        MenuLateral.add(jbConfiguracion);
 
 
        if (tiponivel.equals("Administrador")){
 
        }
 
        if (tiponivel.equals("Gestor")){
            jbUsuarios.setEnabled(false);
            jbConfiguracion.setEnabled(false);
        }
    }
 
// Metodo para crear la pantallas de clientes    
 
    public void Clientes(){
 
    //Iniciamos los elementos del formulario 
 
        JPanel jpContactos, jpDatosBancarios, jpObras, jpMantenimientos;
 
        JButton jbBuscar , jbAnadir;
        ImageIcon iiBuscar , iiAnadir;
 
        JComboBox jcbPais;
        String[] paises = {"España" , "G. Ecuatorial"};
 
        JLabel jlId, jlPais, jlNombre, jlCif;
        JLabel jlNombreComercial , jlTelefono ;
        JLabel jlDireccion, jlNumero , jlEscalera;
        JLabel jlCod , jlPoblacion , jlProvincia;
        JLabel jlEmail , jlWeb;
 
        JTextField jtfId, jtfNombre, jtfCif;
        JTextField jtfNombreComercial , jtfTelefono;
        JTextField jtfDireccion, jtfNumero, jtfEscalera;
        JTextField jtfCod , jtfPoblacion, jtfProvincia;
        JTextField jtfEmail , jtfWeb;
 
        Contenido.setBounds(180,35,843,714);
        Contenido.setLayout(null);
 
        jbBuscar = new JButton();
        iiBuscar = new ImageIcon("src/IconosBotones/iconobuscar.jpg");
        jbBuscar.setIcon(iiBuscar);
        jbBuscar.setBounds(703 , 15 , 40 , 40);
 
        jbAnadir = new JButton();
        iiAnadir = new ImageIcon("src/IconosBotones/iconoanadir.jpg");
        jbAnadir.setIcon(iiAnadir);
        jbAnadir.setBounds(753 , 15 , 40 , 40);
 
        jlId = new JLabel();
        jlId.setText("ID");
        jtfId = new JTextField(50);
        jlId.setBounds(40 , 60 , 50 , 20);
        jtfId.setBounds(120 , 60 , 100 , 20);
 
        jlPais = new JLabel("Pais");
        jcbPais = new JComboBox(paises);
        jlPais.setBounds(360 , 60 , 50 , 20);
        jcbPais.setBounds(399 , 60 , 120 , 20);
 
        jlNombre = new JLabel();
        jlNombre.setText("Nombre");
        jtfNombre = new JTextField(25);
        jlNombre.setBounds( 40 , 90 , 50 , 20);
        jtfNombre.setBounds (120 , 90 , 400 , 20);
 
        jlCif = new JLabel();
        jlCif.setText("CIF/NIF");
        jtfCif = new JTextField(25);
        jlCif.setBounds ( 550 , 90 , 50 , 20);
        jtfCif.setBounds( 610 , 90 , 100 , 20);
 
        jlNombreComercial = new JLabel();
        jlNombreComercial.setText("N. Comercial");
        jtfNombreComercial = new JTextField();
        jlNombreComercial.setBounds ( 40 , 120 , 80 , 20 );
        jtfNombreComercial.setBounds (120 , 120 , 400 , 20);
 
        jlTelefono = new JLabel();
        jlTelefono.setText("Telefono");
        jtfTelefono = new JTextField();
        jlTelefono.setBounds(550 , 120 , 50 , 20);
        jtfTelefono.setBounds(610 , 120 , 120 , 20);
 
        jlDireccion = new JLabel();
        jlDireccion.setText("Direccion");
        jtfDireccion = new JTextField();
        jlDireccion.setBounds(40 , 150 , 80 , 20);
        jtfDireccion.setBounds(120 , 150 , 400 , 20);
 
        jlNumero = new JLabel();
        jlNumero.setText("Num");
        jtfNumero = new JTextField();
        jlNumero.setBounds(550 , 150 , 30 , 20);
        jtfNumero.setBounds(610 , 150 , 30 , 20);
 
        jlEscalera = new JLabel();
        jlEscalera.setText("Esc");
        jtfEscalera = new JTextField();
        jlEscalera.setBounds(660 , 150 , 30 , 20);
        jtfEscalera.setBounds(700 , 150 , 30 , 20);
 
        jlPoblacion = new JLabel();
        jlPoblacion.setText("Poblacion");
        jtfPoblacion = new JTextField();
        jlPoblacion.setBounds(40 , 180 , 80 , 20);
        jtfPoblacion.setBounds(120 , 180 , 200 , 20);
 
        jlCod = new JLabel();
        jlCod.setText("Cod. Postal");
        jtfCod = new JTextField();
        jlCod.setBounds(350 , 180 , 80 , 20);
        jtfCod.setBounds(440 , 180 , 80 , 20);
 
        jlProvincia = new JLabel();
        jlProvincia.setText("Provincia");
        jtfProvincia = new JTextField();
        jlProvincia.setBounds(550 , 180 , 60 , 20);
        jtfProvincia.setBounds(610 , 180 , 120 , 20);
 
        jlEmail = new JLabel();
        jlEmail.setText("Email");
        jtfEmail = new JTextField();
        jlEmail.setBounds(40 , 210 , 80 , 20);
        jtfEmail.setBounds(120 , 210 , 280 , 20);
 
        jlWeb = new JLabel();
        jlWeb.setText("Web");
        jtfWeb = new JTextField();
        jlWeb.setBounds(420 , 210 , 80 , 20);
        jtfWeb.setBounds(470 , 210 , 260 , 20);
 
        JTabbedPane jtpDatos = new JTabbedPane();
        jtpDatos.setBounds(40 , 250 , 720 , 320);
            jpContactos = new JPanel();
 
            jpDatosBancarios = new JPanel();
 
            jpObras = new JPanel();
 
            jpMantenimientos = new JPanel();
 
            jtpDatos.add("Contactos" , jpContactos);
            jtpDatos.add("Datos Bancarios" , jpDatosBancarios );
            jtpDatos.add("Obras" , jpObras);
            jtpDatos.add("Mantenimientos" , jpMantenimientos);
 
 
        Contenido.add(jbBuscar);
        Contenido.add(jbAnadir);
        Contenido.add(jlId);
        Contenido.add(jtfId);
        Contenido.add(jlPais);
        Contenido.add(jcbPais);
        Contenido.add(jlNombre);
        Contenido.add(jtfNombre);
        Contenido.add(jlCif);
        Contenido.add(jtfCif);
        Contenido.add(jlNombreComercial);
        Contenido.add(jtfNombreComercial);
        Contenido.add(jlTelefono);
        Contenido.add(jtfTelefono);
        Contenido.add(jlDireccion);
        Contenido.add(jtfDireccion);
        Contenido.add(jlNumero);
        Contenido.add(jtfNumero);
        Contenido.add(jlEscalera);
        Contenido.add(jtfEscalera);
        Contenido.add(jlPoblacion);
        Contenido.add(jtfPoblacion);
        Contenido.add(jlCod);
        Contenido.add(jtfCod);
        Contenido.add(jlProvincia);
        Contenido.add(jtfProvincia);
        Contenido.add(jlEmail);
        Contenido.add(jtfEmail);
        Contenido.add(jlWeb);
        Contenido.add(jtfWeb);
 
        Contenido.add(jtpDatos);
 
        Contenido.validate();
 
    }
    public void Proveedores(){
        Contenido.setBounds(180,35,843,714);
        Contenido.setLayout(null);
        Contenido.validate();
 
    }
 
    @Override
    public void actionPerformed(ActionEvent e){
        if(e.getSource()== jmiSalir){
            System.exit(0);
        }
        if(e.getSource()== jmiAyuda){
            JOptionPane.showMessageDialog(this , "Sofware ERP - Verision 1.0");
        }
        if(e.getSource()== jbClientes){
            Clientes();
        }
        if(e.getSource()== jbProveedores){
            Proveedores();
        }
    }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder