?? reportmanageframe.java
字號:
package baseinforinterface;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import data.*;import maininterface.*;import user.*;public class ReportManageFrame extends JFrame implements ActionListener { JPanel contentPane; //創(chuàng)建標簽控件 JLabel jLabel1 = new JLabel(); //創(chuàng)建下拉列表框控件 JComboBox jComboBox1 = new JComboBox(); //創(chuàng)建按鈕 JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); //創(chuàng)建滾動框和表格 JScrollPane tableScrollPane1 = new JScrollPane(); JTable jdbTable1 = new JTable(); //創(chuàng)建表格模式類 StockManagementTableModel smTableModel = new StockManagementTableModel(); //創(chuàng)建標題數(shù)組 String[] colNames = {"會計科目", "借貸標識", "余額"}; //創(chuàng)建字體類 Font dialog13 = new java.awt.Font("Dialog", 0, 13); //聲明數(shù)據(jù)類 StockManagementData stockManagementData = null; //聲明用戶類 User user = null; //聲明主窗口類 StockManagementMainFrame stockManagementMainFrame = null; //創(chuàng)建會計科目余額數(shù)組 String[][] accountBalance = new String[0][3]; //創(chuàng)建帳套日期字符串 String ledgerDate = ""; public ReportManageFrame(StockManagementMainFrame stockManagementMainFrame) { this.stockManagementMainFrame = stockManagementMainFrame; //取得主窗口的數(shù)據(jù)類 stockManagementData = stockManagementMainFrame.getStockManagementData(); //取得主窗口的用戶類 user = stockManagementMainFrame.getUser(); //取得主窗口的賬套日期 ledgerDate = stockManagementMainFrame.getLedgerDate(); //取得基礎信息模塊的用戶權限 int baseInforFunction = user.getBaseInforFunction(); //檢查用戶權限 if((baseInforFunction & 1024) != 1024){ JOptionPane.showMessageDialog(null, user.getUserName() + "用戶不具有該權限."); System.exit(0); } //檢查賬套日期 if(ledgerDate.length() == 0){ JOptionPane.showMessageDialog(null, "請選擇賬套."); return; } try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(null); this.setSize(new Dimension(619, 505)); this.setTitle("報表管理窗口"); //設置標簽控件屬性 jLabel1.setText("完成狀態(tài)"); jLabel1.setBounds(new Rectangle(23, 33, 70, 16)); //設置下拉列表框?qū)傩?/span> jComboBox1.setBounds(new Rectangle(94, 33, 156, 22)); jComboBox1.addItem("等待審核"); jComboBox1.addItem("已經(jīng)撤消"); jComboBox1.addItem("完成審核"); //設置滾動框的屬性 tableScrollPane1.setBounds(new Rectangle(23, 77, 570, 363)); tableScrollPane1.getViewport().add(jdbTable1); //設置按鈕的屬性 jButton1.setText("查詢"); jButton1.setActionCommand("search"); jButton1.setBounds(new Rectangle(270, 33, 79, 22)); jButton2.setText("退出"); jButton2.setActionCommand("exit"); jButton2.setBounds(new Rectangle(370, 33, 79, 22)); //為面板加入控件 contentPane.add(jLabel1, null); contentPane.add(jButton1, null); contentPane.add(jButton2, null); contentPane.add(tableScrollPane1); contentPane.add(jComboBox1, null); //設置窗口類的字體和為按鈕加入動作接收器 setupFontAndListener(); } //設置窗口類的字體和為按鈕加入動作接收器的方法 public void setupFontAndListener(){ Component[] components = contentPane.getComponents(); //創(chuàng)建臨時按鈕控件 JButton tmpBtn = new JButton(); for(int i = 0; i < components.length; i++){ components[i].setFont(dialog13); if(components[i].getClass().getName().equals("javax.swing.JButton")){ tmpBtn = (JButton)components[i]; tmpBtn.addActionListener(this); } } } //退出方法 public void exit(){ //隱藏窗口 this.setVisible(false); //清空數(shù)組的內(nèi)容 accountBalance = new String[0][3]; //清空表格的內(nèi)容 this.showTableData(accountBalance); //取得面板上的所有控件 Component[] components = contentPane.getComponents(); //創(chuàng)建臨時編輯框控件 JTextField tmpTextField = new JTextField(); for(int i = 0; i < components.length; i++){ if(components[i].getClass().getName().equals("javax.swing.JTextField")){ tmpTextField = (JTextField)components[i]; //清空編輯框的內(nèi)容 tmpTextField.setText(""); } } } //設置賬套的方法 public void setLedgerDate(String ledgerDate) { this.ledgerDate = ledgerDate; } //設置用戶的方法 public void setUser(User user) { this.user = user; } protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { exit(); } } //顯示表格內(nèi)容的方法 public void showTableData(String[][] detail){ //設置表格的標題 smTableModel.setColumnNames(colNames); //設置表格的數(shù)據(jù) smTableModel.setData(detail); jdbTable1 = new JTable(smTableModel); //設置表格的字體 jdbTable1.setFont(dialog13); //將數(shù)據(jù)表格加入數(shù)據(jù)滾動框 tableScrollPane1.getViewport().add(jdbTable1, null); } //單擊事件方法 public void actionPerformed(ActionEvent e) { //取得按鈕的動作字符串 String actionCommand = e.getActionCommand().trim(); //單擊按鈕的處理代碼 if (actionCommand.equals("search")) { //取得查詢選項 int selectedIndex = jComboBox1.getSelectedIndex(); //0表示等待審核的會計科目余額,1表示撤消的會計科目余額,2表示完成審核的會計科目余額 accountBalance = stockManagementData.getAccountBalance(ledgerDate, selectedIndex); this.showTableData(accountBalance); }else if (actionCommand.equals("exit")){ exit(); } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -