package logica;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import datos.connDb;
import javax.swing.border.TitledBorder;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class frmRegistro extends JFrame {
private JPanel contentPane;
connDb objDb;
private JTextField txtId;
private JTextField txtNombres;
private JTextField txtDni;
private JTextField txtDireccion;
private JTextField txtCargo;
private JTextField txtTelefono;
private JButton btnNuevo;
private JButton btnInsertar;
private JButton btnBuscar;
private JButton btnActualizar;
private JTable table;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frmRegistro frame = new frmRegistro();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public frmRegistro() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 732, 411);
setFont(new Font("Droid Sans", Font.BOLD, 11));
setTitle("Registro de Usuarios");
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(new LineBorder(new Color(99, 130, 191)), "Registro de datos", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(128, 0, 0)));
panel.setLayout(null);
panel.setBounds(12, 12, 706, 141);
txtId = new JTextField();
txtId.setBounds(126, 39, 114, 19);
txtId.setFont(new Font("Droid Sans", Font.PLAIN, 11));
panel.add(txtId);
txtId.setColumns(10);
table = new JTable();
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(7)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 706, GroupLayout.PREFERRED_SIZE)
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(table, GroupLayout.PREFERRED_SIZE, 701, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(table, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
txtNombres = new JTextField();
txtNombres.setFont(new Font("Droid Sans", Font.PLAIN, 11));
txtNombres.setBounds(453, 39, 240, 19);
panel.add(txtNombres);
txtNombres.setColumns(10);
txtDni = new JTextField();
txtDni.setFont(new Font("Droid Sans", Font.PLAIN, 11));
txtDni.setBounds(126, 59, 114, 19);
panel.add(txtDni);
txtDni.setColumns(10);
txtDireccion = new JTextField();
txtDireccion.setFont(new Font("Droid Sans", Font.PLAIN, 11));
txtDireccion.setBounds(126, 79, 230, 19);
panel.add(txtDireccion);
txtDireccion.setColumns(10);
txtCargo = new JTextField();
txtCargo.setFont(new Font("Droid Sans", Font.PLAIN, 11));
txtCargo.setBounds(453, 59, 114, 19);
panel.add(txtCargo);
txtCargo.setColumns(10);
txtTelefono = new JTextField();
txtTelefono.setFont(new Font("Droid Sans", Font.PLAIN, 11));
txtTelefono.setBounds(453, 79, 114, 19);
panel.add(txtTelefono);
txtTelefono.setColumns(10);
JButton btnNuevo = new JButton("Nuevo");
btnNuevo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onVariables();
}
});
btnNuevo.setBounds(100, 110, 117, 25);
panel.add(btnNuevo);
contentPane.setLayout(gl_contentPane);
JButton btnInsertar = new JButton("Insertar");
btnInsertar.setBounds(239, 110, 117, 25);
panel.add(btnInsertar);
JButton btnBuscar = new JButton("Buscar");
btnBuscar.setBounds(378, 110, 117, 25);
panel.add(btnBuscar);
JButton btnActualizar = new JButton("Actualizar");
btnActualizar.setBounds(517, 110, 117, 25);
panel.add(btnActualizar);
JLabel lblNewLabel = new JLabel("Id Usuario :");
lblNewLabel.setBounds(48, 39, 74, 19);
lblNewLabel.setFont(new Font("Droid Sans", Font.BOLD, 11));
panel.add(lblNewLabel);
contentPane.setLayout(gl_contentPane);
JLabel lblNewLabel_1 = new JLabel("Nombres y Apellidos :");
lblNewLabel_1.setFont(new Font("Droid Sans", Font.BOLD, 11));
lblNewLabel_1.setBounds(321, 39, 127, 19);
panel.add(lblNewLabel_1);
contentPane.setLayout(gl_contentPane);
JLabel lblNewLabel_2 = new JLabel("Doc. Identidad :");
lblNewLabel_2.setFont(new Font("Droid Sans", Font.BOLD, 11));
lblNewLabel_2.setBounds(24, 59, 97, 19);
panel.add(lblNewLabel_2);
contentPane.setLayout(gl_contentPane);
JLabel lblNewLabel_3 = new JLabel("Dirección :");
lblNewLabel_3.setFont(new Font("Droid Sans", Font.BOLD, 11));
lblNewLabel_3.setBounds(52, 79, 70, 19);
panel.add(lblNewLabel_3);
contentPane.setLayout(gl_contentPane);
JLabel lblNewLabel_4 = new JLabel("Cargo :");
lblNewLabel_4.setFont(new Font("Droid Sans", Font.BOLD, 11));
lblNewLabel_4.setBounds(399, 59, 48, 19);
panel.add(lblNewLabel_4);
contentPane.setLayout(gl_contentPane);
JLabel lblNewLabel_5 = new JLabel("Telefono :");
lblNewLabel_5.setFont(new Font("Droid Sans", Font.BOLD, 11));
lblNewLabel_5.setBounds(383, 79, 63, 19);
panel.add(lblNewLabel_5);
contentPane.setLayout(gl_contentPane);
offVariables();
btnInsertar.setEnabled(false);
btnBuscar.setEnabled(false);
btnActualizar.setEnabled(false);
}
private void onVariables()
{
txtId.setEnabled(true);
txtNombres.setEnabled(true);
txtDni.setEnabled(true);
txtCargo.setEnabled(true);
txtDireccion.setEnabled(true);
txtTelefono.setEnabled(true);
btnNuevo.setEnabled(true);
btnActualizar.setEnabled(true);
btnBuscar.setEnabled(true);
}
private void offVariables()
{
txtId.setEnabled(false);
txtNombres.setEnabled(false);
txtDni.setEnabled(false);
txtCargo.setEnabled(false);
txtDireccion.setEnabled(false);
txtTelefono.setEnabled(false);
//btnInsertar.setEnabled(false);
//btnBuscar.setEnabled(false);
//btnActualizar.setEnabled(false);
}
}