读书人

JDK 年到底想要我如何样!

发布时间: 2011-12-12 22:59:56 作者: rapoo

JDK 年到底想要我怎么样!!!!!!!!!!!!!
我好像并没有错呀 但它好提示我找不到符号DecoratedFrame

Java code
 
import java.awt.*;
import javax.swing.*;

public class Aaa extends JFrame
{
public void DecoratedFrame()
{
this.getContentPane().add(new JLabel("Just a test."));
this.setUndecorated(true);
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
this.setSize(300,150);
}
public static void main(String[] args)
{
JFrame frame = new DecoratedFrame();
frame.setVisible(true);
}
}

开始说
Java code
  public DecoratedFrame()

需要返回值 我就改成了
Java code
  public void DecoratedFrame()

又说找不到DecoratedFrame()了
我承认我菜 可你也不能这样对我呀!找不到你想办法找呀 我都找到了你还找不到 都快被气死了

[解决办法]
你的初衷应该是写一个构造方法
所以要让Aaa和DecoratedFrame名称一致
也就是说
可以写成如下情况:
Java code
import   java.awt.*;    import   javax.swing.*;   public class DecoratedFrame extends JFrame{   public DecoratedFrame()  {     this.getContentPane().add(new JLabel("Just a test."));     this.setUndecorated(true);    this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);     this.setSize(300,150);   }   public static void main(String[] args)  {    JFrame frame = new DecoratedFrame();    frame.setVisible(true);   } }
[解决办法]
JFrame frame = new DecoratedFrame();
错误太明显了,你怎么new了一个方法啊 !
呵呵
把你的类名改成DecoratedFrame就好了

[解决办法]
引用楼主 sunnet2008 的帖子:
我好像并没有错呀 但它好提示我找不到符号DecoratedFrame

Java code
import java.awt.*;
import javax.swing.*;

public class Aaa extends JFrame
{
public void DecoratedFrame()
{
this.getContentPane().add(new JLabel("Just a test."));
this.setUndecorated(true);
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
this.setSize(300,150);
}

读书人网 >J2SE开发

热点推荐