简体   繁体   中英

Java setShape() method giving error on command prompt but works fine on eclipse

I am trying to change the shape of my main frame using

    frame.setShape(new RoundRectangle2D.Double(1,1,863,590,80,80));

this method is working perfectly on eclipse but when I compile the program using command prompt with javac command it gives me error.

Code Snippet

C:\Users\AbdulMoiz\Desktop\JAVA PROJECT FINAL>javac Main.java
Main.java:40: cannot find symbol
symbol  : method setShape(java.awt.geom.RoundRectangle2D.Double)
location: class javax.swing.JFrame
frame.setShape(new RoundRectangle2D.Double(1,1,863,590,80,80));

Imports

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.event.*;
import javax.imageio.*;
import java.awt.image.*;
import java.lang.Math;
import java.awt.geom.*;
import java.util.*;

Could be your eclipse isn't using the same compiler version as javac from cmd. you can compare the javac -version result (in cmd) to the version used in the eclipse project properties.

Apparently JFrame.setShape has been introduced with JDK7 but was not available in JDK6 . So it looks like you are using eclipse with JDK >= 7, however your command line javac stems from a JDK <= 6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM