📄 userpower.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package testgui;import DBOperation.*;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.io.*;/** * * @author DancingMoon */public class UserPower extends JDialog implements ActionListener{ JLabel 用户名,权限; JTextField 用户名1; JComboBox 权限1; JButton 确定,取消; public UserPower(UserTest power) { super(); // super(power,"用户权限",false); 用户名=new JLabel("用 户 名"); 权限=new JLabel("指定权限"); 用户名1=new JTextField(""); 确定=new JButton("确定"); 取消=new JButton("取消"); String item[]={"Administrator","User"}; 权限1=new JComboBox(item); 权限1.setEditable(false); 权限1.addActionListener(this); 确定.addActionListener(this); 取消.addActionListener(this); this.add(用户名); this.add(权限); this.add(用户名1); this.add(权限1); this.add(确定); this.add(取消); this.setLayout(null); 用户名.setBounds(10, 10, 50, 20); 用户名1.setBounds(70, 10, 140, 20); 权限.setBounds(10, 30, 80, 20); 权限1.setBounds(70, 30, 140, 20); 确定.setBounds(30, 60, 80, 20); 取消.setBounds(120, 60, 80, 20); this.setBounds(600, 300, 240, 120); this.setVisible(false); } public void actionPerformed(ActionEvent e) { if(e.getSource()==取消) { 用户名1.setText(""); this.setVisible(false); } if(e.getSource()==确定) { int n; DBUser user = new DBUser(); String s=(String)权限1.getSelectedItem(); if(s.equals("Administrator")) n=1; else n=2; user.UserSetPower(用户名1.getText(),n); this.setVisible(false); } throw new UnsupportedOperationException("Not supported yet."); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -