B/S写久了尝试写写C/S报如下错误。请求解答:
代码:
jf.getContentPane().add(jp3);
jf.getContentPane().add(jp1);
jf.getContentPane().add(jp2);
jf.getContentPane().add(jp4);
jf.getContentPane().add(jp5);
jf.getContentPane().add(jp6);
jf.getContentPane().add(jp2);
jp4.setLayout(fl);删除线部分为错误点。jf 为一个JFrame实例,jp为JPanel实例 fl为FlowLayout实例
错误内容如下:
The method getContentPane() from the type JFrame refers to the missing type Container
期待解答
代码:
jf.getContentPane().add(jp3);
jf.
jf.
jf.
jf.
jf.
jf.
jp4.
错误内容如下:
The method getContentPane() from the type JFrame refers to the missing type Container
期待解答
很简单的代码如下:
import javax.swing.JButton;
import javax.swing.JFrame;/**
*
*//**
* @author Administrator
*
*/
public class testframe extends JFrame {
public void test()
{
JButton jb = new JButton("你好");
this.getContentPane().add(jb);
this.setSize(200,200);
this.setVisible(true);
} public static void main(String args[])
{
testframe te = new testframe();
te.test();
}
}