import java.awt.*; import java.util.*; import java.text.*; import javax.swing.*; import javax.swing.text.*; public class personalPane2 extends JPanel { public JTextField fieldNombre; public JTextField fieldRut; public JTextField fieldVerificador; public JTextField fieldNacimientoD; public JTextField fieldNacimientoM; public JTextField fieldNacimientoA; public JRadioButton masculino; public JRadioButton femenino; public JTextField fieldDomicilio; public JTextField fieldCiudad; public JTextField fieldFono1; public JTextField fieldFono2; public JTextField fieldPrevision; public personalPane2() { SpringLayout layout = new SpringLayout(); setLayout(layout); setOpaque(true); //Create and add the components. int centro = 350; int linea = 25; Calendar cal = Calendar.getInstance(); Date date = cal.getTime(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL); String fechax = dateFormatter.format(date); JComponent fecha = new JLabel("Fecha:"); JComponent fieldFecha = new JLabel(" "+fechax); add(fecha); add(fieldFecha); layout.putConstraint(SpringLayout.NORTH, fecha, linea*1, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fecha, centro+20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldFecha, linea*1, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldFecha, centro+80, SpringLayout.WEST, this); JComponent nombre = new JLabel("Nombre:"); fieldNombre = new JTextField(19); add(nombre); add(fieldNombre); layout.putConstraint(SpringLayout.NORTH, nombre, linea*2, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, nombre, 20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldNombre, linea*2, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldNombre, 90, SpringLayout.WEST, this); JComponent rut = new JLabel("RUT:"); fieldRut = new JTextField(8); JComponent guion = new JLabel("-"); fieldVerificador = new JTextField(1); add(rut); add(fieldRut); add(guion); add(fieldVerificador); layout.putConstraint(SpringLayout.NORTH, rut, linea*2, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, rut, centro+20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldRut, linea*2, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldRut, centro+90, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, guion, linea*2, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, guion, 2, SpringLayout.EAST, fieldRut); layout.putConstraint(SpringLayout.NORTH, fieldVerificador, linea*2, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldVerificador, 2, SpringLayout.EAST, guion); JComponent nacimiento = new JLabel("Fecha de Nacimiento:"); JComponent de1 = new JLabel("de"); JComponent de2 = new JLabel("de"); fieldNacimientoD = new JTextField(2); fieldNacimientoM = new JTextField(2); fieldNacimientoA = new JTextField(3); add(nacimiento); add(fieldNacimientoD); add(de1); add(fieldNacimientoM); add(de2); add(fieldNacimientoA); layout.putConstraint(SpringLayout.NORTH, nacimiento, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, nacimiento, 20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldNacimientoD, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldNacimientoD, 38, SpringLayout.EAST, nacimiento); layout.putConstraint(SpringLayout.NORTH, de1, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, de1, 1, SpringLayout.EAST, fieldNacimientoD); layout.putConstraint(SpringLayout.NORTH, fieldNacimientoM, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldNacimientoM, 2, SpringLayout.EAST, de1); layout.putConstraint(SpringLayout.NORTH, de2, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, de2, 1, SpringLayout.EAST, fieldNacimientoM); layout.putConstraint(SpringLayout.NORTH, fieldNacimientoA, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldNacimientoA, 2, SpringLayout.EAST, de2); JLabel sexo = new JLabel("Sexo: "); masculino = new JRadioButton("M"); femenino = new JRadioButton("F"); masculino.setSelected(true); ButtonGroup sexgroup = new ButtonGroup(); sexgroup.add(masculino); sexgroup.add(femenino); add(sexo); add(masculino); add(femenino); layout.putConstraint(SpringLayout.NORTH, sexo, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, sexo, centro+20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, masculino, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, masculino, centro+90, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, femenino, linea*3, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, femenino, centro+140, SpringLayout.WEST, this); JComponent domicilio = new JLabel("Domicilio:"); fieldDomicilio = new JTextField(19); add(domicilio); add(fieldDomicilio); layout.putConstraint(SpringLayout.NORTH, domicilio, linea*4, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, domicilio, 20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldDomicilio, linea*4, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldDomicilio, 90, SpringLayout.WEST, this); JComponent ciudad = new JLabel("Ciudad:"); fieldCiudad = new JTextField(15); add(ciudad); add(fieldCiudad); layout.putConstraint(SpringLayout.NORTH, ciudad, linea*4, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, ciudad, centro+20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldCiudad, linea*4, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldCiudad, centro+90, SpringLayout.WEST, this); JComponent fono1 = new JLabel("Teléfono1:"); JComponent fono2 = new JLabel("Teléfono2:"); fieldFono1 = new JTextField(6); fieldFono2 = new JTextField(6); add(fono1); add(fono2); add(fieldFono1); add(fieldFono2); layout.putConstraint(SpringLayout.NORTH, fono1, linea*5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fono1, 20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldFono1, linea*5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldFono1, 90, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fono2, linea*5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fono2, 7, SpringLayout.EAST, fieldFono1); layout.putConstraint(SpringLayout.NORTH, fieldFono2, linea*5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldFono2, 7, SpringLayout.EAST, fono2); JComponent prevision = new JLabel("Previsión: "); fieldPrevision = new JTextField(15); add(prevision); add(fieldPrevision); layout.putConstraint(SpringLayout.NORTH, prevision, linea*5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, prevision, centro+20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, fieldPrevision, linea*5, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, fieldPrevision, centro+90, SpringLayout.WEST, this); } }