EL FORMULARIO NO ES WEB ES EN VENTANAS !! PERDON POR LA EQUIVOCACION
Tengo unas serias dudas.
Estoy empezando con java, tengo una base de datos y quiero realizar los formularios en java. Uno de los formularios es el siguiente y quiero alinearlo a la izquierda y que no me salga centrado para que despues se ajuste a las pantallas:
Código:
GRACIAS public class FrameClientes { public FrameClientes() { } public void datosCliente(){ /*Creamos el frame*/ final JFrame frame = new JFrame("GESTION DE CLIENTES"); /*Creamos paneles*/ JPanel panel0 = new JPanel(); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JPanel panel4 = new JPanel(); JPanel panel5 = new JPanel(); JPanel panel6 = new JPanel(); JPanel panel7 = new JPanel(); JPanel panel8 = new JPanel(); JPanel panel9 = new JPanel(); JPanel panel10 = new JPanel(); JPanel panelT1 = new JPanel(); JPanel panelT2 = new JPanel(); JPanel panelT3 = new JPanel(); JPanel panelT4 = new JPanel(); JPanel panelT5 = new JPanel(); /*Creamos los componentes*/ JLabel titulo = new JLabel("GESTION DE CLIENTES"); JLabel texto1 = new JLabel("Código:"); JLabel texto2 = new JLabel("D.N.I.:"); JLabel texto3 = new JLabel("Nombre:"); JLabel texto4 = new JLabel("1º Apellido:"); JLabel texto5 = new JLabel("2º Apellido:"); JLabel texto6 = new JLabel("Dirección:"); JLabel texto7 = new JLabel("Teléfonos:"); JLabel texto8 = new JLabel("E-mail:"); JLabel texto9 = new JLabel("Fecha de Nacimiento:"); JLabel texto10 = new JLabel("Cliente desde:"); JTextField codigo = new JTextField(8); JTextField dni = new JTextField(9); JTextField nombre = new JTextField(15); JTextField apellido1 = new JTextField(15); JTextField apellido2 = new JTextField(15); JTextField direccion = new JTextField(30); JTextField telf1 = new JTextField(12); JTextField telf2 = new JTextField(12); JTextField email = new JTextField(30); JTextField fechaNac = new JTextField(10); JTextField fechaDesde = new JTextField(10); JButton anadir = new JButton("AÑADIR"); JButton eliminar = new JButton("ELIMINAR"); JButton consultar = new JButton("CONSULTAR"); titulo.setFont(new Font("",3,20)); panel0.add(titulo); panel1.add(texto1); panel1.add(codigo); panel2.add(texto2); panel2.add(dni); panel3.add(texto3); panel3.add(nombre); panel4.add(texto4); panel4.add(apellido1); panel5.add(texto5); panel5.add(apellido2); panel6.add(texto6); panel6.add(direccion); panel7.add(texto7); panel7.add(telf1); panel7.add(telf2); panel8.add(texto8); panel8.add(email); panel9.add(texto9); panel9.add(fechaNac); panel10.add(texto10); panel10.add(fechaDesde); GridBagLayout gridbag1 = new GridBagLayout(); GridBagConstraints gbc1 = new GridBagConstraints(); GridBagLayout gridbag2 = new GridBagLayout(); GridBagConstraints gbc2 = new GridBagConstraints(); GridBagLayout gridbag3 = new GridBagLayout(); GridBagConstraints gbc3 = new GridBagConstraints(); GridBagLayout gridbag4 = new GridBagLayout(); GridBagConstraints gbc4 = new GridBagConstraints(); GridBagLayout gridbag5 = new GridBagLayout(); GridBagConstraints gbc5 = new GridBagConstraints(); GridBagLayout gridbagT = new GridBagLayout(); GridBagConstraints gbcT = new GridBagConstraints(); panelT1.setLayout( gridbag1 ); gbc1.gridwidth = GridBagConstraints.REMAINDER; gbc1.weightx = 1.0; gridbag1.setConstraints(panel0,gbc1); panelT1.add(panel0); gbc1.gridwidth = GridBagConstraints.RELATIVE; gridbag1.setConstraints(panel1,gbc1 ); panelT1.add(panel1); gbc1.gridwidth = GridBagConstraints.REMAINDER; gridbag1.setConstraints(panel2,gbc1 ); panelT1.add(panel2); panelT2.setLayout( gridbag2 ); gbc2.weightx = 1.0; gridbag2.setConstraints(panel3,gbc2); panelT2.add(panel3); gridbag2.setConstraints(panel4,gbc2 ); panelT2.add(panel4); gbc2.gridwidth = GridBagConstraints.REMAINDER; gridbag2.setConstraints(panel5,gbc2 ); panelT2.add(panel5); panelT3.setLayout( gridbag3 ); gbc3.weightx = 1.0; gridbag3.setConstraints(panel6,gbc3); panelT3.add(panel6); gbc3.gridwidth = GridBagConstraints.REMAINDER; gridbag3.setConstraints(panel7,gbc3 ); panelT3.add(panel7); panelT4.setLayout( gridbag4 ); gbc4.gridwidth = GridBagConstraints.REMAINDER; gbc4.weightx = 1.0; gridbag4.setConstraints(panel8,gbc4); panelT4.add(panel8); gbc4.gridwidth = GridBagConstraints.RELATIVE; gridbag4.setConstraints(panel9,gbc4 ); panelT4.add(panel9); gbc4.gridwidth = GridBagConstraints.REMAINDER; gridbag4.setConstraints(panel10,gbc4 ); panelT4.add(panel10); panelT5.setLayout(gridbag5); gbc5.weightx = 1.0; gridbag5.setConstraints(anadir, gbc5); panelT5.add(anadir); gbc5.gridwidth = GridBagConstraints.RELATIVE; gridbag5.setConstraints(eliminar,gbc5 ); panelT5.add(eliminar); gbc5.gridwidth = GridBagConstraints.REMAINDER; gridbag5.setConstraints(consultar,gbc5 ); panelT5.add(consultar); frame.setLayout(gridbagT); gbcT.gridwidth = GridBagConstraints.REMAINDER; gbcT.weightx = 1.0; gridbagT.setConstraints(panelT1, gbcT); frame.add(panelT1); gridbagT.setConstraints(panelT2, gbcT); frame.add(panelT2); gridbagT.setConstraints(panelT3, gbcT); frame.add(panelT3); gridbagT.setConstraints(panelT4, gbcT); frame.add(panelT4); gridbagT.setConstraints(panelT5, gbcT); frame.add(panelT5); frame.pack(); frame.setVisible(true); } }