StaticPanel.java~24~
资源名称:Java.rar [点击查看]
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:5k
源码类别:
Java编程
开发平台:
Java
- package manpowersystem;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- import java.io.*;
- import java.util.*;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.event.*;
- import javax.swing.border.*;
- import javax.swing.table.*;
- import com.borland.jbcl.layout.*;
- public class StaticPanel extends JFrame {
- XYLayout xYLayout1 = new XYLayout();
- JButton jDelRecordButton = new JButton();
- JButton jExitButton = new JButton();
- JScrollPane jStaticScrollPane = new JScrollPane();
- JTable jStaticTable = new JTable();
- boolean bCanDel = true;
- int intDelLines; //显示所选的行数
- String[] arrField = {"工 号", "姓 名", "上班时间", "下班时间","请假时间","备 注"};
- Object[][] arrData = {}; //设定表格的字段
- public StaticPanel() {
- try {
- jbInit();
- }
- catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- public static void main( String[] args ) {
- StaticPanel tablePanel1 = new StaticPanel();
- tablePanel1.validate();
- tablePanel1.setVisible( true );
- }
- private void jbInit() throws Exception {
- DefaultTableModel tableModel = new DefaultTableModel( arrData, arrField );
- jStaticTable = new JTable(tableModel);
- jExitButton.addActionListener(new ActionListener(this));
- jStaticScrollPane.getViewport().add( jStaticTable, null );
- this.setTitle("信息统计页面");
- this.getContentPane().setBackground( new Color( 210, 138, 177 ) );
- this.getContentPane().setLayout( xYLayout1 );
- jDelRecordButton.setBackground( new Color( 212, 158, 217 ) );
- jDelRecordButton.setFont( new java.awt.Font( "DialogInput", 1, 16 ) );
- jDelRecordButton.setText( "删除记录" );
- jDelRecordButton.addActionListener( new java.awt.event.ActionListener() {
- public void actionPerformed( ActionEvent e ) {
- jDelRecordButton_actionPerformed( e );
- }
- } );
- jExitButton.setBackground( new Color( 212, 158, 217 ) );
- jExitButton.setFont( new java.awt.Font( "DialogInput", 1, 16 ) );
- jExitButton.setText( "退出" );
- jExitButton.addActionListener( new java.awt.event.ActionListener() {
- public void actionPerformed( ActionEvent e ) {
- jExitButton_actionPerformed( e );
- }
- } );
- addWindowListener( new WindowAdapter() {
- public void windowClosing( WindowEvent e ) {
- dispose();
- }
- } );
- jStaticScrollPane.getViewport().setBackground(new Color(210, 138, 177));
- this.getContentPane().add(jStaticScrollPane, new XYConstraints(4, 4, 462, 420));
- this.getContentPane().add(jExitButton, new XYConstraints(266, 462, 102, 52));
- this.getContentPane().add(jDelRecordButton, new XYConstraints(85, 462, 102, 52));
- jStaticScrollPane.getViewport().add(jStaticTable, null);
- this.getContentPane().add(jStaticScrollPane, new XYConstraints(4, 2, 463, 420));
- this.setSize( 470, 550 );
- this.setLocation( 230, 100 );
- this.setResizable( false );
- }
- void jExitButton_actionPerformed( ActionEvent e ) {
- this.dispose();
- }
- void jDelRecordButton_actionPerformed( ActionEvent e ) {
- DelRecord();
- }
- public void DelRecord() {
- }
- public void UpdateRecord() {
- Object[][] arrTmp = {}; //设定表格的字段
- tableModel = new DefaultTableModel( arrTmp, arrField );
- jRecordTable = new JTable( tableModel );
- jTableScrollPane.getViewport().add( jRecordTable, null );
- try {
- RecordItem[] result = new RecordItem[ 100 ];
- for ( int j = 0; j < 100; j++ )
- result[ j ] = new RecordItem();
- result = database.AccessData();
- for ( int i = 0; i < result.length; i++ ) {
- Object newdata[] = {result[ i ].GetEmployeeID(),
- result[ i ].GetEmployeeName(),
- result[ i ].GetOnWorkTime(),
- result[ i ].GetDescribe()};
- String strTmp = result[ i ].GetOnWorkTime();
- if ( strTmp.trim().length() == 0 )
- continue;
- tableModel.addRow( newdata );
- }
- }
- catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- }
- class ActionListener implements java.awt.event.ActionListener {
- StaticPanel adaptee;
- ActionListener(StaticPanel adaptee) {
- this.adaptee = adaptee;
- }
- public void actionPerformed(ActionEvent e) {
- adaptee.jExitButton_actionPerformed(e);
- }
- }