请教高手。
dylsz 2003-10-17 10:05:19 import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ControlPane extends JInternalFrame {
Component right, left, bottom;
JSplitPane top, total;
public ControlPane(String title, boolean b1, boolean b2, boolean b3, boolean b4){
super(title, b1, b2, b3, b4);
setBounds(0, 0, 550, 350);
Dimension minsize = new Dimension(250, 250);
bottom = new MyPanel2();
right = new MyPanel1(bottom);
left = new MyPanel3();
top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, right, left);
top.setDividerSize(6);
top.setMinimumSize(minsize);
bottom.setVisible(false);
total = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top , bottom);
total.setDividerSize(6);
getContentPane().add(total, BorderLayout.CENTER);
}
}
class MyPanel1 extends JPanel{
Component c;
public MyPanel1(Component c){
this.c = c;
Action show = new AbstractAction("sure"){
public void actionPerformed(ActionEvent e)
{
c.setVisible(true);
}
};
JButton sure = new JButton(show);
add(sure);
}
public Dimension getMinimumSize(){
return new Dimension(50, 300);
}
}
class MyPanel2 extends JPanel{
public Dimension getPreferredSize()
{
return new Dimension(200, 20);
}
}
class MyPanel3 extends JPanel{
}
我想把窗口分成3部分,下面部分开始时隐藏。第一部分有个按钮,按此按钮下面部分显示。
运行时出现如下提示:
E:\java\soft\ControlPane.java:37: local variable c is accessed from within inner class; needs to be declared final
c.setVisible(true);
这是为什么啊。