📄 浏览用户.java~7~
字号:
package untitled3;import java.awt.*;import javax.swing.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;import java.awt.event.*;import java.util.Vector;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2001</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class 浏览用户 extends JDialog { Vector item=new Vector(); JPanel jPanel1 = new JPanel(); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); FlowLayout flowLayout1 = new FlowLayout(); JTextField jTextField1 = new JTextField(); JTextField jTextField3 = new JTextField(); JPanel jPanel2 = new JPanel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JButton jButton3 = new JButton(); Database database1 = new Database(); QueryDataSet queryDataSet1 = new QueryDataSet(); JPanel jPanel3 = new JPanel(); TableScrollPane tableScrollPane1 = new TableScrollPane(); JdbTable jdbTable1 = new JdbTable(); FlowLayout flowLayout2 = new FlowLayout(); JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar(); private int counter=0; JComboBox jComboBox1 = new JComboBox(item); public 浏览用户(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public 浏览用户() { this(null, "", false); } private void jbInit() throws Exception { this.getContentPane().setLayout(null); jPanel1.setFont(new java.awt.Font("Dialog", 0, 15)); jPanel1.setBounds(new Rectangle(23, 7, 261, 158)); jPanel1.setLayout(flowLayout1); jLabel1.setFont(new java.awt.Font("Dialog", 0, 15)); jLabel1.setPreferredSize(new Dimension(80, 30)); jLabel1.setText("用 户:"); jLabel2.setFont(new java.awt.Font("Dialog", 0, 15)); jLabel2.setPreferredSize(new Dimension(80, 30)); jLabel2.setText("权 限:"); jLabel3.setFont(new java.awt.Font("Dialog", 0, 15)); jLabel3.setPreferredSize(new Dimension(80, 30)); jLabel3.setText("模块号:"); jTextField1.setFont(new java.awt.Font("Dialog", 0, 15)); jTextField1.setPreferredSize(new Dimension(120, 30)); jTextField1.setText(""); jTextField3.setFont(new java.awt.Font("Dialog", 0, 15)); jTextField3.setPreferredSize(new Dimension(120, 30)); jTextField3.setText(""); jButton1.setFont(new java.awt.Font("Dialog", 0, 15)); jButton1.setPreferredSize(new Dimension(120, 30)); jButton1.setText("查找"); jButton1.addActionListener(new 浏览用户_jButton1_actionAdapter(this)); jButton2.setFont(new java.awt.Font("Dialog", 0, 15)); jButton2.setPreferredSize(new Dimension(120, 30)); jButton2.setText("增加"); jButton2.addActionListener(new 浏览用户_jButton2_actionAdapter(this)); jButton3.setFont(new java.awt.Font("Dialog", 0, 15)); jButton3.setPreferredSize(new Dimension(120, 30)); jButton3.setText("返回"); jButton3.addActionListener(new 浏览用户_jButton3_actionAdapter(this)); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:学生信息管理", "sample", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); jPanel3.setLayout(flowLayout2); jdbTable1.setFont(new java.awt.Font("Dialog", 0, 15)); tableScrollPane1.setFont(new java.awt.Font("Dialog", 0, 15)); tableScrollPane1.setPreferredSize(new Dimension(450, 200)); jPanel3.setBounds(new Rectangle(39, 191, 460, 205)); jPanel2.setBounds(new Rectangle(303, 7, 197, 100)); jdbNavToolBar1.setBounds(new Rectangle(71, 164, 452, 28)); this.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); this.setEnabled(true); this.setModal(false); this.setResizable(true); this.setTitle(""); jComboBox1.setFont(new java.awt.Font("Dialog", 0, 15)); jComboBox1.setPreferredSize(new Dimension(120, 30)); item.add("学生"); item.add("老师"); jComboBox1.setEnabled(true); jPanel1.add(jLabel1, null); jPanel1.add(jTextField1, null); jPanel1.add(jLabel2, null); jPanel1.add(jComboBox1, null); jPanel1.add(jLabel3, null); jPanel1.add(jTextField3, null); jPanel1.add(jButton1, null); this.getContentPane().add(jPanel2, null); this.getContentPane().add(jPanel3, null); jPanel3.add(tableScrollPane1, null); this.getContentPane().add(jPanel1, null); this.getContentPane().add(jdbNavToolBar1, null); jPanel2.add(jButton2, null); jPanel2.add(jButton3, null); } void jButton1_actionPerformed(ActionEvent e) { String sql = ""; sql= "select 用户,权限,模块号 from 用户";String str1=jTextField1.getText(),str3=jTextField3.getText(); String str2; if(String.valueOf(jComboBox1.getSelectedItem())=="老师")str2="1"; else str2="0"; //判断查询条件 sql+=" where "; if(str1.length()!=0||str2.length()!=0||str3.length()!=0) {} if(str1.length()!=0) {sql+="用户="+"'"+str1+"'"; sql+=" AND "; } sql+="权限=" +str2; if(str3.length()!=0)sql+=" AND "; if(str3.length()!=0){sql+="模块号="+str3;}if(counter==0){ queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, sql, null, true, Load.ALL)); counter++;} else {queryDataSet1.close(); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, sql, null, true, Load.ALL)); } jdbTable1.setDataSet(queryDataSet1); tableScrollPane1.getViewport().add(jdbTable1, null); } void jButton2_actionPerformed(ActionEvent e) { 增加用户 增加用户1=new 增加用户 (); 增加用户1.setBounds(50,50,400,350); 增加用户1.setTitle("增加用户 "); 增加用户1.show(); } void cancel() { dispose(); } void jButton3_actionPerformed(ActionEvent e) { if (e.getSource() == jButton3) { cancel(); } }}class 浏览用户_jButton1_actionAdapter implements java.awt.event.ActionListener { 浏览用户 adaptee; 浏览用户_jButton1_actionAdapter(浏览用户 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}class 浏览用户_jButton2_actionAdapter implements java.awt.event.ActionListener { 浏览用户 adaptee; 浏览用户_jButton2_actionAdapter(浏览用户 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton2_actionPerformed(e); }}class 浏览用户_jButton3_actionAdapter implements java.awt.event.ActionListener { 浏览用户 adaptee; 浏览用户_jButton3_actionAdapter(浏览用户 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton3_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -