大虾们帮我看看下面这段代码,
package uni8080;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.table.*;
public class socket8080 extends JFrame
{
/**
* 主模块,初始化所有子模块,并设置主框架的相关属性
*/
public socket8080()
{
RightPanel rightPanel = new RightPanel();
CenterPanel centerPanel = new CenterPanel();
// 设置主框架的布局
Container c = this.getContentPane();
c.add(rightPanel,BorderLayout.EAST);
c.add(centerPanel,BorderLayout.CENTER);
// c.add(bottomPanel,BorderLayout.SOUTH);
// 利用无名内隐类,增加窗口事件
this.addWindowListener(new WindowAdapter()
{
public void WindowClosing(WindowEvent e)
{
// 释放资源,退出程序
dispose();
System.exit(0);
}
});
setSize(500,350);
setTitle("socket通讯");
setLocation(200,150);
show();
}
/**
* 最右边模块,继承JPanel,初始化各种按钮
*/
class RightPanel extends JPanel
{
public RightPanel()
{
this.setLayout(new GridLayout(9,1));
// 初始化各种按钮
//JCheckBox checkBox = new JCheckBox("复选按钮");
JLabel lab0 = new JLabel("");
JLabel lab1 = new JLabel("");
JLabel lab2 = new JLabel("");
JLabel lab3 = new JLabel("");
JLabel lab4 = new JLabel("");
JButton sendbtn = new JButton(" 发 送 ");
sendbtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
//dispose();
//System.exit(0);
}
});
JButton startbtn = new JButton(" 启动服务 ");
startbtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
Server ufs=new Server();
ufs.getIni();
//setButton("start");
//startbtn=new startbtn
startbtn.setEnabled(false);
}
});
JButton stopbtn = new JButton(" 停止服务 ");
stopbtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
stopbtn.setEnabled(false);
//dispose();
//System.exit(0);
}
});
JButton closebtn = new JButton(" 关 闭 ");
closebtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
dispose();
System.exit(0);
}
});
add(lab0);
add(sendbtn);
add(lab1);
add(startbtn);
add(lab2);
add(stopbtn);
add(lab3);
add(closebtn);
add(lab4);
this.setBorder(new EtchedBorder(EtchedBorder.LOWERED,Color.LIGHT_GRAY,Color.DARK_GRAY));
}
}
////////////////////////////////////////////////////////////////////////////
/**
* 中间层模块,继承JPanel,初始化页签,并在页签中设置文本区,
* 文本区上下用分隔条分隔
*/
class CenterPanel extends JPanel
{
public CenterPanel()
{
JTabbedPane tab = new JTabbedPane(JTabbedPane.TOP);
JTextPane SendTextPane = new JTextPane();
JTextPane RecTextPane = new JTextPane();
RecTextPane.setEnabled(false);
JTextPane SysTextPane = new JTextPane();
SysTextPane.setEnabled(false) ;
RecTextPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
RecTextPane.setText("");
tab.addTab("发送信息",SendTextPane);
tab.addTab("受到的信息",RecTextPane);
tab.addTab("系统信息",SysTextPane);
tab.setPreferredSize(new Dimension(380,300));
this.add(tab);
//this.add(SysTextPane);
this.setEnabled(true);
this.setBorder(new EtchedBorder(EtchedBorder.LOWERED,Color.LIGHT_GRAY,Color.DARK_GRAY));
}
}
public static void main(String args[])
{
new socket8080();
}
}
=======================================
这段代码中的这一段
JButton startbtn = new JButton(" 启动服务 ");
startbtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
Server ufs=new Server();
ufs.getIni();
//setButton("start");
//startbtn=new startbtn
startbtn.setEnabled(false);
}
});
----------------------------------------
startbtn.setEnabled(false); 这个编译时老是说
"socket8080.java": local variable startbtn is accessed from within inner class; needs to be declared final at line 83, column 33
这是什么原因啊?谢谢了!!
---------------------------------------
=======================================