用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

小鱼宝宝    -  云代码空间

——

aaaaaa

2017-05-18|982阅||

摘要:asdasda

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("服务器状态:关闭");



}
}

顶 0踩 0收藏
文章评论
    发表评论

    个人资料

    • 昵称: 小鱼宝宝
    • 等级: 初级程序员
    • 积分: 18
    • 代码: 2 个
    • 文章: 15 篇
    • 随想: 0 条
    • 访问: 8 次
    • 关注

    人气文章

    人气代码

    最新提问

      站长推荐