package Interface;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import server.MyServer;
public class Server extends JFrame implements ActionListener {
static String sss="关闭";
JLabel zhuangtai;
public Server() {
this.setTitle("服务器"); // 设置窗体的标题
this.setSize(400, 200); // 设置窗体的大小
this.setLocationRelativeTo(null); // 设置窗体出现位置居中
this.setDefaultCloseOperation(3); // 设置窗体的关闭操作
this.setResizable(false); // 设置禁止调整窗体的大小
this.setIconImage((new ImageIcon("src/Mypicture/qq.png").getImage())); // 设置标题栏图标
this.setLayout(new FlowLayout());
JButton j1 = new JButton("启动服务器");
JButton j2 = new JButton("关闭服务器");
zhuangtai=new JLabel("服务器状态:关闭");
this.add(j1);
this.add(j2);
this.add(zhuangtai);
j1.addActionListener(this);
j2.addActionListener(this);
this.setVisible(true);
}
public static void main(String[] args) {
new Server();
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("启动服务器"))
{
zhuangtai.setText("服务器状态:开启");
JOptionPane.showMessageDialog(null, "服务器已启动");
new MyServer();
}
if (e.getActionCommand().equals("关闭服务器"))
zhuangtai=new JLabel("服务器状态:关闭");
}
}