⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findfacility.java~76~

📁 是我写的一些关于设备基础管理的一些代码程序
💻 JAVA~76~
字号:
package 设备管理系统2;

import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.*;
import javax.swing.JTabbedPane;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.border.TitledBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import com.borland.dx.sql.dataset.Database;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
import java.sql.ResultSet;

public class FindFacility extends JFrame implements ActionListener {

    JPanel contentJpane;
    JPanel jPanel1 = new JPanel();
    JLabel jLabel1 = new JLabel();
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JComboBox jComboBox1 = new JComboBox();
    JComboBox jComboBox2 = new JComboBox();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    JTextField jTextField4 = new JTextField();
    JComboBox jComboBox3 = new JComboBox();
    //JScrollPane jScrollPane1 = new JScrollPane();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    TitledBorder titledBorder1 = new TitledBorder("");

    JTextField jTextField5 = new JTextField();
    JLabel jLabel11 = new JLabel();
    XYLayout xYLayout2 = new XYLayout();

    Vector vector;
    JTable table;
    AbstractTableModel tm;
    String[] arrField = {"档案编号", "设备名称", "设备编码", "投产年月", "设备类别",
                        "设备型号", "制造年月", "年折旧率", "使用部门", "制造厂家",
                        "复杂系数DF", "复杂系数JF", "设备原值", "折旧年限", "电机台数",
                        "总功率KW", "备注"};
    Object[][] arrtmp = {};
    ResultSet re = null;


    JRadioButton jRadioButton1 = new JRadioButton();
    JRadioButton jRadioButton2 = new JRadioButton();
    ButtonModel model = jRadioButton1.getModel();
    ButtonModel model1 = jRadioButton2.getModel();
    // group.setSelected(model, true);

    ButtonGroup buttonGroup1 = new ButtonGroup();


    public FindFacility() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        Facility.initialize();
        contentJpane = (JPanel) getContentPane();
        contentJpane.setLayout(xYLayout2);
        jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel1.setText("设备种类");
        jPanel1.setLayout(xYLayout1);
        jLabel2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 20));
        jLabel2.setText("请输入你的查询的 条件:");
        jLabel3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel3.setText("设备名称");
        jLabel4.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel4.setText("使用部门");
        jLabel5.setText("jLabel5");
        jLabel6.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel6.setToolTipText("");
        jLabel6.setText("设备档案编号");
        jTextField1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 16));
        jTextField1.setText("2001/01/01");
        jLabel7.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel7.setText("设备编码");
        jLabel8.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel8.setText("设备制造厂家");
        jTextField2.setText("jTextField2");
        jTextField3.setText("jTextField3");
        jLabel9.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel9.setToolTipText("");
        jLabel9.setText("投产日期区间查询(如:2000/01/01---2005/01/01期间投产设备的查询)");
        jLabel10.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel10.setText("-----------------------");
        jTextField4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
        jTextField4.setText("2006/01/01");
        jButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 18));
        jButton1.setText("查询");
        jButton1.addActionListener(this);
        jButton2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 18));
        jButton2.setText("取消查询");
        jRadioButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 16));
        jRadioButton1.setText("精确查询");
        jRadioButton2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 16));
        jRadioButton2.setText("模糊查询");
        jTextField5.setText("jTextField2");
        jLabel11.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 20));
        jLabel11.setText("查询结果显示");
        jPanel1.add(jLabel5, new XYConstraints(308, 141, 5, 3));
        jPanel1.add(jRadioButton1, new XYConstraints(38, 46, -1, -1));
        jPanel1.add(jRadioButton2, new XYConstraints(38, 79, -1, -1));
        jPanel1.add(jLabel6, new XYConstraints(154, 45, 101, 32));
        jPanel1.add(jLabel1, new XYConstraints(154, 80, 78, 27));
        jPanel1.add(jLabel4, new XYConstraints(154, 112, 79, 23));
        jPanel1.add(jLabel9, new XYConstraints(155, 145, 539, -1));
        jPanel1.add(jLabel2, new XYConstraints(10, 3, -1, 34));
        jPanel1.add(jLabel7, new XYConstraints(501, 50, 65, 27));
        jPanel1.add(jLabel8, new XYConstraints(500, 81, 93, 25));
        jPanel1.add(jLabel3, new XYConstraints(500, 112, 62, 24));
        jPanel1.add(jTextField2, new XYConstraints(275, 49, 148, 26));
        jPanel1.add(jComboBox1, new XYConstraints(248, 83, 177, 24));
        jPanel1.add(jComboBox2, new XYConstraints(248, 116, 177, 21));
        jPanel1.add(jLabel10, new XYConstraints(423, 174, -1, -1));
        jPanel1.add(jTextField1, new XYConstraints(245, 169, 181, 26));
        jPanel1.add(jTextField5, new XYConstraints(640, 54, 144, 25));
        jPanel1.add(jComboBox3, new XYConstraints(606, 86, 178, 24));
        jPanel1.add(jTextField3, new XYConstraints(605, 117, 179, -1));
        jPanel1.add(jTextField4, new XYConstraints(605, 168, 179, 24));
        jPanel1.add(jButton2, new XYConstraints(177, 197, 111, 28));
        jPanel1.add(jLabel11, new XYConstraints(9, 230, -1, -1));
        jPanel1.add(jButton1, new XYConstraints(43, 197, 107, -1));
        contentJpane.add(jPanel1, new XYConstraints(0, 0, 0, 0));
        // jPanel1.add(jScrollPane1, new XYConstraints(53, 259, 733, 287));
        jTextField3.setEditable(false);
        jTextField1.setEditable(false);
        jTextField4.setEditable(false);
        //   jComboBox1.disable();
        // jComboBox2.disable();

        //  jComboBox3.disable();

        createTable();
        //jScrollPane1.setBorder(titledBorder1);
        buttonGroup1.add(jRadioButton1);
        jRadioButton1.addActionListener(this);
        jRadioButton2.addActionListener(this);
        buttonGroup1.add(jRadioButton2);
        jRadioButton1.addActionListener(this);
        buttonGroup1.setSelected(model, true);

        //jRadioButton2.se
        // buttonGroup1.isSelected();
        setSize(842, 600);
        setResizable(false);
        setLocation(20, 110);
        setVisible(true);

    }

    void createTable() {
        vector = new Vector();

        AbstractTableModel tm = new AbstractTableModel() {
            public int getColumnCount() {
                return arrField.length;
            }

            public int getRowCount() {
                return vector.size();
            }

            public Object getValueAt(int row, int column) {
                if (!vector.isEmpty()) {
                    return ((Vector) vector.elementAt(row)).elementAt(column);
                } else {
                    return null;
                }
            }

            public void setValueAt(Object value, int row, int column) {}

            public String getColumnName(int column) {
                return arrField[column];
            }

            public Class getColumnClass(int c) {
                return getValueAt(0, c).getClass();
            }

            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        table = new JTable(tm);
        JScrollPane tabelJScrollPane;

        table.setAutoResizeMode(table.AUTO_RESIZE_OFF);
        table.setCellSelectionEnabled(false);
        table.setShowHorizontalLines(true);
        table.setShowVerticalLines(true);
        tabelJScrollPane = new JScrollPane(table);
        //JScrollPane.setBorder(BorderFactory.createEtchedBorder());
        //tabelJScrollPane.setColumnHeader();
        //   tabelJScrollPane.setBounds();//(6,20,540,250);
        contentJpane.add(tabelJScrollPane, new XYConstraints(53, 259, 733, 287));
    }


    public void actionPerformed(ActionEvent event) {
        Object source = event.getSource();
        if (source == jRadioButton1) {
            buttonGroup1.setSelected(model, true);
            jTextField2.setEditable(true);
            jTextField5.setEditable(true);
            jTextField3.setEditable(false);
            jTextField1.setEditable(false);
            jTextField4.setEditable(false);
            //  jComboBox1.disable();
            //    jComboBox2.disable();

            //  jComboBox3.disable();

            // jComboBox3.enableInputMethods(false);
        }
        if (source == jRadioButton2) {
            buttonGroup1.setSelected(model1, true);
            jTextField2.setEditable(false);
            jTextField5.setEditable(false);
            jTextField3.setEditable(true);
            jTextField1.setEditable(true);
            jTextField4.setEditable(true);
            //   jComboBox1.enable();
            // jComboBox2.enable();
            //  jComboBox3.enable();

        }

        if (source == jButton1) {
            String sql = "select * from TABLE1 where";
            if (jTextField2.getText().equals("") == false) {
                sql = sql + " fileNo=" + "'" + jTextField2.getText() + "'";
            }
            System.out.println("--------");
            System.out.println(sql);
            System.out.println("--------");
            vector = Facility.findAll(sql)  ;
            this.table.repaint();
            this.table.updateUI();
        }



    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -