0

the "shape = getShape();" is identified as an error, cannot find symbol

JDK 1.6 netbeans 7.0.1

the code is given below;(was trying to do this http://www.youtube.com/watch?v=IFIlr6cpX64 )

import com.sun.awt.AWTUtilities;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;


public class Wickget extends JFrame{

    public Wickget(){
        setUndecorated(true);
        setSize(500,500);
        add(new JLabel(new ImageIcon("index.jpg")));
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setVisible(true);

        Shape shape= new Ellipse2D.Float(0,0,500,500);
        shape = getShape();
        AWTUtilities.setWindowShape(this, shape);
    }

    public static void main(String[] args){
        new Wickget();
    }
}

the "shape = getShape();" is identified as an error, cannot find symbol

JDK 1.6 netbeans 7.0.1

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • 4
    It's right, `JFrame` doesn't have a `getShape()` method in Java6. You have to update to Java7 if you want to use this method, but note that your application won't work in PCs which have Java6 or lower installed – BackSlash Jul 15 '13 at 22:45
  • Also, you've simply set the frame of the shape back to itself (you've not actually changed it) – MadProgrammer Jul 15 '13 at 22:48

1 Answers1

2

As you can read in the documentation, Window.getShape() was added in JDK 1.7 so it is not available on JDK 1.6. You can either update your JDK, thus increase the JRE version required to run your application. Or you can invoke the method using reflection and only if it exists, which will make the shape available on a Java 7 JRE while still allowing your application to run on Java 6, albeit without window shape support. Choose depending on how essential this shape support is for the proper workings of your application.

MvG
  • 57,380
  • 22
  • 148
  • 276