当前位置: 代码迷 >> J2SE >> JDK 年到底想要我如何样!
  详细解决方案

JDK 年到底想要我如何样!

热度:132   发布时间:2016-04-24 12:46:58.0
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);
}

  相关解决方案