java下面代码中 为什么要建立一个ss=null的语句,startBtn.setEnabled(false);是什么意思,求老鸟告知
privateJButtonstartBtn,offBtn;privateThreadt;privateServerSocketss;privatevoidinit(){...
private JButton startBtn, offBtn;
private Thread t;
private ServerSocket ss;
private void init()
{
startBtn = new JButton("开启服务器");
startBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
t = new Thread(new Runnable() {
public void run() {
if (ss == null) {
try {
ss = new ServerSocket(9999);
new StartServer(ss);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
t.start();
startBtn.setEnabled(false);
offBtn.setEnabled(true);
}
}); 展开
private Thread t;
private ServerSocket ss;
private void init()
{
startBtn = new JButton("开启服务器");
startBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
t = new Thread(new Runnable() {
public void run() {
if (ss == null) {
try {
ss = new ServerSocket(9999);
new StartServer(ss);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
t.start();
startBtn.setEnabled(false);
offBtn.setEnabled(true);
}
}); 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询