/* * PrincipalFrame.java * * Created on 25 de enero de 2008, 07:59 PM */ package gafetes; import java.awt.event.*; import java.awt.event.KeyEvent; import javax.swing.event.*; import java.awt.*; import javax.swing.*; import javax.swing.table.*; /** * * @author jalafita */ public class PrincipalFrame extends javax.swing.JFrame { /** Creates new form PrincipalFrame */ public PrincipalFrame() { initComponents(); initComp(); } public void initComp(){ // table.setModel(gafetes.business.SqlHelper.getListadoEmpleados( // (String) ordenComboBox.getSelectedItem() , //(String) ascdescComboBox.getSelectedItem()) ); gafetes.util.Misc.windowsItemActionPerformed(this); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); ordenComboBox = new javax.swing.JComboBox(); ascdescComboBox = new javax.swing.JComboBox(); jButton3 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Listao de Empleados ADO Region Caribe"); jPanel1.setBackground(new java.awt.Color(205, 199, 182)); ordenComboBox.setBackground(new java.awt.Color(228, 230, 224)); ordenComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Clave", "Nombre", "Apellidos", "Area" })); ordenComboBox.setBorder(javax.swing.BorderFactory.createEtchedBorder()); ordenComboBox.setPreferredSize(new java.awt.Dimension(150, 22)); ordenComboBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { ordenComboBoxItemStateChanged(evt); } }); ascdescComboBox.setBackground(new java.awt.Color(228, 230, 224)); ascdescComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Asc", "Desc" })); ascdescComboBox.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jButton3.setBackground(new java.awt.Color(205, 199, 182)); jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gafetes/images/busqueda_apretado.gif"))); jButton3.setBorder(null); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton2.setBackground(new java.awt.Color(205, 199, 182)); jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gafetes/images/salir.gif"))); jButton2.setBorder(null); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton4.setBackground(new java.awt.Color(205, 199, 182)); jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gafetes/images/nuevo.gif"))); jButton4.setBorder(null); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(172, 172, 172) .add(ordenComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(5, 5, 5) .add(ascdescComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 84, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(40, 40, 40) .add(jButton4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(227, 227, 227)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(13, 13, 13) .add(ordenComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel1Layout.createSequentialGroup() .add(5, 5, 5) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jButton4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .add(jPanel1Layout.createSequentialGroup() .add(13, 13, 13) .add(ascdescComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH); jPanel2.setBackground(new java.awt.Color(236, 227, 211)); getContentPane().add(jPanel2, java.awt.BorderLayout.EAST); jPanel3.setBackground(new java.awt.Color(236, 227, 211)); getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH); jPanel4.setBackground(new java.awt.Color(236, 227, 211)); getContentPane().add(jPanel4, java.awt.BorderLayout.WEST); jPanel5.setBackground(new java.awt.Color(236, 227, 211)); jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jPanel5.setPreferredSize(new java.awt.Dimension(900, 600)); jScrollPane1.setBackground(new java.awt.Color(244, 244, 240)); table.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); table.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tableMouseClicked(evt); } }); jScrollPane1.setViewportView(table); org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup() .addContainerGap() .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 756, Short.MAX_VALUE) .addContainerGap()) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup() .add(56, 56, 56) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE) .addContainerGap()) ); getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: dispose(); }//GEN-LAST:event_jButton2ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: newAction(); }//GEN-LAST:event_jButton4ActionPerformed private void ordenComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ordenComboBoxItemStateChanged // TODO add your handling code here: initComp(); }//GEN-LAST:event_ordenComboBoxItemStateChanged private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: gafetes.beans.Empleado empleado = new gafetes.beans.Empleado(); SearchDialog d = new SearchDialog(Application.getparentFrame(), false, empleado); gafetes.util.Misc.centerFrame(d); d.setVisible(true); }//GEN-LAST:event_jButton3ActionPerformed private void tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseClicked // TODO add your handling code here: if(evt.getClickCount() > 1){ editAction(); } }//GEN-LAST:event_tableMouseClicked public void newAction(){ gafetes.EmpleadoDialog ef = new EmpleadoDialog(this,false); ef.newMode(); gafetes.beans.Empleado e = new gafetes.beans.Empleado(); gafetes.util.Misc.centerFrame(ef); ef.setTitle("Alta de Empleados"); ef.setVisible(true); table.setModel(gafetes.business.SqlHelper.getListadoEmpleados( (String) ordenComboBox.getSelectedItem() ,(String) ascdescComboBox.getSelectedItem() ) ); jScrollPane1.requestFocus(); table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION); table.requestFocus(); } private void editAction(){ gafetes.EmpleadoDialog ef = new EmpleadoDialog(this,false); gafetes.beans.Empleado e = new gafetes.beans.Empleado(); int row = table.getSelectedRow(); if(row<0){ javax.swing.JOptionPane.showMessageDialog(new JFrame(),"Selecccione un registro"); table.requestFocus(); } e = (gafetes.beans.Empleado) table.getModel().getValueAt(row,1) ; ef.setEditMode(e); //ef.setModal(true); gafetes.util.Misc.centerFrame(ef); ef.setVisible(true); table.setModel(gafetes.business.SqlHelper.getListadoEmpleados( (String) ordenComboBox.getSelectedItem() ,(String) ascdescComboBox.getSelectedItem() ) ); jScrollPane1.requestFocus(); table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION); table.requestFocus(); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PrincipalFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox ascdescComboBox; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JComboBox ordenComboBox; private javax.swing.JTable table; // End of variables declaration//GEN-END:variables }