import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SchoolNet extends JFrame implements ActionListener
{
private JPanel jp=new JPanel();
private JTextField jtf=new JTextField();
private JPasswordField jpf=new JPasswordField();
private JButton[] jbArray={new JButton("连接"),new JButton("退出"),
new JButton("系统"),new JButton("设置")};
private JLabel[] jlArray={new JLabel("用户名"),new JLabel("密码"),
new JLabel("语言"),new JLabel("网卡"),new JLabel("邵阳学院"),
new JLabel("HU NAN SHAO YANG UNIVERSITY"),
new JLabel("Supplicant 3.35-0618")};
private String str1[]={"中文","English"};
private JComboBox jcb1=new JComboBox(str1);
private String str2[]={"VIA Rhine Fast Ethernet Adapt"};
private JComboBox jcb2=new JComboBox(str2);
public SchoolNet()
{
jp.setLayout(null);
for(int i=0;i<4;i++)
{
jlArray[i].setBounds(20,50+i*40,80,25);
jp.add(jlArray[i]);
jbArray[i].setBounds(10+i*80,230,70,20);
jp.add(jbArray[i]);
}
jtf.setBounds(80,48,200,25);
jp.add(jtf);
jpf.setBounds(80,88,200,25);
jp.add(jpf);
jcb1.setBounds(80,128,200,25);
jp.add(jcb1);
jcb2.setBounds(80,170,200,25);
jp.add(jcb2);
jlArray[4].setBounds(130,0,55,25);
jlArray[4].setOpaque(true);
jlArray[4].setBackground(Color.red);
jp.add(jlArray[4]);
jlArray[5].setBounds(80,25,185,10);
jlArray[5].setOpaque(true);
jlArray[5].setBackground(Color.red);
jp.add(jlArray[5]);
jlArray[6].setBounds(200,210,130,10);
jp.add(jlArray[6]);
jbArray[0].addActionListener(this);
jbArray[1].addActionListener(this);
jbArray[2].addActionListener(this);
jbArray[3].addActionListener(this);
this.add(jp);
this.setTitle("邵阳学院网络认证计费系统");
this.setBounds(300,200,340,300);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jlArray[0])
{
JOptionPane.showMessageDialog(null,"还没与数据库连接","消息!",1);
}
if(e.getSource()==jlArray[1])
{
System.exit(0);
}
if(e.getSource()==jlArray[0])
{
JOptionPane.showMessageDialog(null,"邵阳学院校园网","消息!",1);
}
if(e.getSource()==jlArray[0])
{
JOptionPane.showMessageDialog(null,"没与网络连接","消息!",1);
}
}
public static void main(String[] args)
{
SchoolNet sn=new SchoolNet();
}
}
import java.awt.event.*;
import javax.swing.*;
public class SchoolNet extends JFrame implements ActionListener
{
private JPanel jp=new JPanel();
private JTextField jtf=new JTextField();
private JPasswordField jpf=new JPasswordField();
private JButton[] jbArray={new JButton("连接"),new JButton("退出"),
new JButton("系统"),new JButton("设置")};
private JLabel[] jlArray={new JLabel("用户名"),new JLabel("密码"),
new JLabel("语言"),new JLabel("网卡"),new JLabel("邵阳学院"),
new JLabel("HU NAN SHAO YANG UNIVERSITY"),
new JLabel("Supplicant 3.35-0618")};
private String str1[]={"中文","English"};
private JComboBox jcb1=new JComboBox(str1);
private String str2[]={"VIA Rhine Fast Ethernet Adapt"};
private JComboBox jcb2=new JComboBox(str2);
public SchoolNet()
{
jp.setLayout(null);
for(int i=0;i<4;i++)
{
jlArray[i].setBounds(20,50+i*40,80,25);
jp.add(jlArray[i]);
jbArray[i].setBounds(10+i*80,230,70,20);
jp.add(jbArray[i]);
}
jtf.setBounds(80,48,200,25);
jp.add(jtf);
jpf.setBounds(80,88,200,25);
jp.add(jpf);
jcb1.setBounds(80,128,200,25);
jp.add(jcb1);
jcb2.setBounds(80,170,200,25);
jp.add(jcb2);
jlArray[4].setBounds(130,0,55,25);
jlArray[4].setOpaque(true);
jlArray[4].setBackground(Color.red);
jp.add(jlArray[4]);
jlArray[5].setBounds(80,25,185,10);
jlArray[5].setOpaque(true);
jlArray[5].setBackground(Color.red);
jp.add(jlArray[5]);
jlArray[6].setBounds(200,210,130,10);
jp.add(jlArray[6]);
jbArray[0].addActionListener(this);
jbArray[1].addActionListener(this);
jbArray[2].addActionListener(this);
jbArray[3].addActionListener(this);
this.add(jp);
this.setTitle("邵阳学院网络认证计费系统");
this.setBounds(300,200,340,300);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jlArray[0])
{
JOptionPane.showMessageDialog(null,"还没与数据库连接","消息!",1);
}
if(e.getSource()==jlArray[1])
{
System.exit(0);
}
if(e.getSource()==jlArray[0])
{
JOptionPane.showMessageDialog(null,"邵阳学院校园网","消息!",1);
}
if(e.getSource()==jlArray[0])
{
JOptionPane.showMessageDialog(null,"没与网络连接","消息!",1);
}
}
public static void main(String[] args)
{
SchoolNet sn=new SchoolNet();
}
}
jlArray是标签 jbArray才是按钮
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jbArray[0]) {
JOptionPane.showMessageDialog(null, "还没与数据库连接", "消息!", 1);
}
if (e.getSource() == jbArray[1]) {
System.exit(0);
}
if (e.getSource() == jbArray[0]) {
JOptionPane.showMessageDialog(null, "邵阳学院校园网", "消息!", 1);
}
if (e.getSource() == jbArray[0]) {
JOptionPane.showMessageDialog(null, "没与网络连接", "消息!", 1);
}
}