📄 selectlogin.java~70~
字号:
package bank;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.Toolkit;
import java.awt.Dimension;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.DisplayMode;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
//选择进入界面类
public class SelectLogin extends JFrame
{
public SelectLogin() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
private void jbInit() throws Exception {
jRadioButton1.setBackground(Color.pink);
jRadioButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
jRadioButton1.setText("管理员");
jButton1.updateUI();
this.getContentPane().setLayout(gtl);
jButton1.addActionListener(new SelectLogin_jButton1_actionAdapter(this));
this.getContentPane().setBackground(new Color(192, 192, 230));
this.setForeground(Color.pink);
grounp.add(jRadioButton1);
grounp.add(jRadioButton2);
this.getContentPane().add(jRadioButton2,
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(25, 0, 10, 0), 15, 0));
this.getContentPane().add(jButton1,
new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
, GridBagConstraints.SOUTH, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), -13, -40));
this.getContentPane().add(jButton2,
new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
new Insets(0, 30, 0, 44), 24, 16));
this.getContentPane().add(jRadioButton1,
new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.EAST, GridBagConstraints.NONE,
new Insets(29, 70, 3, 0), 0, 0));
this.getContentPane().add(jLabel1,
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(8, 23, 17, 51), 0, 0));
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 18));
jLabel1.setForeground(Color.red);
jLabel1.setText("请选择进入模式:");
jRadioButton2.setBackground(Color.pink);
jButton2.setBackground(Color.orange);
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton2.setText("退出");
jButton2.addActionListener(new SelectLogin_jButton2_actionAdapter(this));
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jRadioButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
jRadioButton2.setText("用户");
}
ButtonGroup grounp=new ButtonGroup();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton(new ImageIcon("bank4.gif"));
JButton jButton2 = new JButton();
GridBagLayout gtl = new GridBagLayout();
public void jButton1_actionPerformed(ActionEvent e) {
if((e.getSource()==jButton1)&&(jRadioButton2.isSelected()==true))//用户界面
{
UserLogFrame userframe=new UserLogFrame();
this.dispose();//关闭之前的窗口
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = userframe.getSize();
// WindowFrameP win=new WindowFrameP();
// DisplayMode dis=new DisplayMode(1024,768,32,86);
// win.setFullScreen(dis,userframe);
userframe.setState(userframe.NORMAL);
userframe.setLocation( (screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2);
userframe.show();//显示在屏幕
}
else if((e.getSource()==jButton1)&&(jRadioButton1.isSelected()==true))//管理员界面
{
AdminFrame admin=new AdminFrame();
this.dispose();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = admin.getSize();
admin.setState(admin.NORMAL);
admin.setLocation( (screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2);
admin.show();
}
else //弹出一个对话框叫你选择
{
JOptionPane.showMessageDialog( null,"请选择其中一项,要么退出银行系统!!");
}
}
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class SelectLogin_jButton2_actionAdapter
implements ActionListener {
private SelectLogin adaptee;
SelectLogin_jButton2_actionAdapter(SelectLogin adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class SelectLogin_jButton1_actionAdapter
implements ActionListener {
private SelectLogin adaptee;
SelectLogin_jButton1_actionAdapter(SelectLogin adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -