StaticPanel.java~30~
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:5k
源码类别:

Java编程

开发平台:

Java

  1. package manpowersystem;
  2. /**
  3.  * <p>Title: </p>
  4.  * <p>Description: </p>
  5.  * <p>Copyright: Copyright (c) 2003</p>
  6.  * <p>Company: </p>
  7.  * @author not attributable
  8.  * @version 1.0
  9.  */
  10. import java.io.*;
  11. import java.util.*;
  12. import java.awt.*;
  13. import java.awt.event.*;
  14. import javax.swing.*;
  15. import javax.swing.event.*;
  16. import javax.swing.border.*;
  17. import javax.swing.table.*;
  18. import com.borland.jbcl.layout.*;
  19. public class StaticPanel extends JFrame {
  20.     XYLayout xYLayout1 = new XYLayout();
  21.     JButton jDelRecordButton = new JButton();
  22.     JButton jExitButton = new JButton();
  23.     JScrollPane jStaticScrollPane = new JScrollPane();
  24.     JTable jStaticTable = new JTable();
  25.     boolean bCanDel = true;
  26.     int intDelLines;         //显示所选的行数
  27.     String[] arrField = {"工 号", "姓 名", "上班时间", "下班时间","请假时间","备 注"};
  28.     Object[][] arrData = {};        //设定表格的字段
  29.     Database database = new Database(); //数据库存取对象
  30.     RecordItem item = new RecordItem(); //每一条数据记录
  31.     DefaultTableModel tableModel; //表格模型
  32.     int intRow;              //显示所选的行数
  33.     int intCol;              //显示所选的行数
  34.     int intEmploreeID;       //员工工号
  35.     String strName;          //员工姓名
  36.     Date dateTime;           //确切记录
  37.     String strDescribe;      //备注
  38.     public StaticPanel() {
  39.         try {
  40.             jbInit();
  41.         }
  42.         catch ( Exception e ) {
  43.             e.printStackTrace();
  44.         }
  45.     }
  46.     public static void main( String[] args ) {
  47.         StaticPanel tablePanel1 = new StaticPanel();
  48.         tablePanel1.validate();
  49.         tablePanel1.setVisible( true );
  50.     }
  51.     private void jbInit() throws Exception {
  52.         DefaultTableModel tableModel = new DefaultTableModel( arrData, arrField );
  53.         jStaticTable = new JTable(tableModel);
  54.         jExitButton.addActionListener(new ActionListener(this));
  55.         jStaticScrollPane.getViewport().add( jStaticTable, null );
  56.         this.setTitle("信息统计页面");
  57.         this.getContentPane().setBackground( new Color( 210, 138, 177 ) );
  58.         this.getContentPane().setLayout( xYLayout1 );
  59.         jDelRecordButton.setBackground( new Color( 212, 158, 217 ) );
  60.         jDelRecordButton.setFont( new java.awt.Font( "DialogInput", 1, 16 ) );
  61.         jDelRecordButton.setText( "删除记录" );
  62.         jDelRecordButton.addActionListener( new java.awt.event.ActionListener() {
  63.             public void actionPerformed( ActionEvent e ) {
  64.                 jDelRecordButton_actionPerformed( e );
  65.             }
  66.         } );
  67.         jExitButton.setBackground( new Color( 212, 158, 217 ) );
  68.         jExitButton.setFont( new java.awt.Font( "DialogInput", 1, 16 ) );
  69.         jExitButton.setText( "退出" );
  70.         jExitButton.addActionListener( new java.awt.event.ActionListener() {
  71.             public void actionPerformed( ActionEvent e ) {
  72.                 jExitButton_actionPerformed( e );
  73.             }
  74.         } );
  75.         addWindowListener( new WindowAdapter() {
  76.             public void windowClosing( WindowEvent e ) {
  77.                 dispose();
  78.             }
  79.         } );
  80.         jStaticScrollPane.getViewport().setBackground(new Color(210, 138, 177));
  81.         this.getContentPane().add(jStaticScrollPane, new XYConstraints(4, 4, 462, 420));
  82.         this.getContentPane().add(jExitButton, new XYConstraints(266, 462, 102, 52));
  83.         this.getContentPane().add(jDelRecordButton,  new XYConstraints(85, 462, 102, 52));
  84.         jStaticScrollPane.getViewport().add(jStaticTable, null);
  85.         this.getContentPane().add(jStaticScrollPane,     new XYConstraints(4, 2, 463, 420));
  86.         this.setSize( 470, 550 );
  87.         this.setLocation( 230, 100 );
  88.         this.setResizable( false );
  89.         UpdateRecord();
  90.     }
  91.     void jExitButton_actionPerformed( ActionEvent e ) {
  92.         this.dispose();
  93.     }
  94.     void jDelRecordButton_actionPerformed( ActionEvent e ) {
  95.         DelRecord();
  96.     }
  97.     public void DelRecord() {
  98.     }
  99.     public void UpdateRecord() {
  100.         Object[][] arrTmp = {}; //设定表格的字段
  101.         tableModel = new DefaultTableModel( arrTmp, arrField );
  102.         jStaticTable = new JTable( tableModel );
  103.         jStaticScrollPane.getViewport().add( jStaticTable, null );
  104.         try {
  105.             RecordItem[] result = new RecordItem[ 100 ];
  106.             for ( int j = 0; j < 100; j++ )
  107.                 result[ j ] = new RecordItem();
  108.             result = database.AccessData();
  109.             for ( int i = 0; i < result.length; i++ ) {
  110.                 Object newdata[] = {result[ i ].GetEmployeeID(),
  111.                     result[ i ].GetEmployeeName(),
  112.                     result[ i ].GetOnWorkTime(),
  113.                     result[ i ].GetOffWorkTime(),
  114.                     result[ i ].GetLeaveWorkTime(),
  115.                     result[ i ].GetDescribe()};
  116.                 String strTmp = result[ i ].GetOnWorkTime();
  117.                 if ( strTmp.trim().length() == 0 )
  118.                     continue;
  119.                 tableModel.addRow( newdata );
  120.             }
  121.         }
  122.         catch ( Exception e ) {
  123.             e.printStackTrace();
  124.         }
  125.     }
  126. }
  127. class ActionListener implements java.awt.event.ActionListener {
  128.     StaticPanel adaptee;
  129.     ActionListener(StaticPanel adaptee) {
  130.         this.adaptee = adaptee;
  131.     }
  132.     public void actionPerformed(ActionEvent e) {
  133.         adaptee.jExitButton_actionPerformed(e);
  134.     }
  135. }