2014-03-27 3 views
-1

blueJ에서 사람 모양을 만드는 동안 계속 "식별자 예상 오류"가 표시됩니다. 여기<identifier> 예상 Java 오류

import java.awrt.*; 
import java.awt.event.*; 
import java.awt.geom.*; 
/** 
* Write a description of class Main here 
* 
* @author Ibrahim Hmood 
* @version 03.27.2014 
*/ 
public class main 
{ 
     public static void main (String[] args); 
     Frame frame = newCricleDraw(); 
     frame.addWindowListener(new WindowAdapter() 
     {public void windowClosing (WindowEvent we) 
      { 
       system.exit(0); 
      } 
      } 
     };//end of listener 
     frame.setSize(600,600) 
     frame.setVisible(true); 
    } 
} 

및 CircleDraw 클래스의 코드는 다음과 같습니다 : 지금까지, 여기에 메인 클래스의 코드는

import java.awt.*; 
import java.awt.event.*; 
import java.awt.geom.*; 

public class CircleDraw extends Frame 
{ 
    Shape squarehead = new; 
    Ellipse2D.Float(200.0F, 40.0f, 100.0f, 100.0f); 

    Shape squareLeftArm = new; 
    Rectangle2D.Double(165, 230,30, 50); 

    Shape circleCenter = new; 
    Circle2D.Double(165, 230, 30, 50); 

    Shape squareNeck = new 
    Square2D.Double(165, 230, 30,50); 
    { 
     //draw head 
     Graphics2D ga = (Graphics2D)g; 
     ga.draw(squareHead); 
     ga.setPaint(color.Blue); 
     ga.fill(squareHead); 

     //draw arms 
     ga.setPaint(Color.black); 
     ga.draw(squareLeftArm); 
     ga.fill(squareLeftArm); 

     //draw center 
     ga.setPaint(color.NavyBlue); 
     ga.Draw(circleCenter); 
     ga.fill(circleCenter); 

     //draw neck 

    } 
} 

이 오류는 내가 테스트를 위해 컴파일 때마다 발생하고 있습니다. 지금까지 나는 그것을 끝내지 않았다.

+0

@SotiriosDelimanolis. 이것은 분명히 새로운 자바 프로그래머입니다. – mttdbrd

+1

@mttdbrd 저를 포기하지 마십시오. 핀 중 하나가 오류를 지적했습니다. 다른 많은 인쇄상의 오류가 있습니다. OP는 프로그램하는 법을 배우기 전에 타이핑하는 법을 배워야합니다. 이 질문은 다른 누구에게 도움이되지 않습니다. –

+0

@SotiriosDelimanolis 사람들은 프로그래밍에 대한 도움을 받기 위해 여기에옵니다. 귀하의 의견은 건설적이거나 도움이되지 않습니다. – mttdbrd

답변

2

main을 포함한 메소드는 중괄호로 묶인 인코딩을 가져야합니다. 그래서 :

public static void main (String[] args); 

는 또한

public static void main (String[] args) { 

해야한다, 중괄호 { } 및 괄호 () 중 하나를 다른 균형해야합니다. 청취자로 사용되는 "익명 클래스"를 작성할 때 이것은 까다로울 수 있습니다. 이 시점에서

Frame frame = newCricleDraw(); 
    frame.addWindowListener(new WindowAdapter() 
    {public void windowClosing (WindowEvent we) 
     { 
      system.exit(0); 
     } // This closes the { two lines above 
     } // This closes the { just before "public" 

, 당신은 단지 단어 new 전에 열린 (, 그래서 당신은 } 그것을 닫을 수 없습니다. (오른쪽 괄호 사용)에

};//end of listener 

변경 :

frame.setSize(600,600); 
1

은 이클립스와 같은 IDE를 사용하고 :

); // end of listener  

을 그리고,이 후 세미콜론이 필요하십니까? 컴파일러/IDE

public class CircleDraw extends Frame 
{ 
    Shape squareHead = new 
    Ellipse2D.Float(200.0F, 40.0f, 100.0f, 100.0f); 

    Shape squareLeftArm = new 
    Rectangle2D.Double(165, 230,30, 50); 

    Shape circleCenter = new 
      Ellipse2D.Double(165, 230, 30, 50); 

    Shape squareNeck = new 
    Rectangle2D.Double(165, 230, 30,50); 

    public void paint(Graphics g) 
    { 

     //draw head 
     Graphics2D ga = (Graphics2D)g; 
     ga.draw(squareHead); 
     ga.setPaint(Color.BLUE); 
     ga.fill(squareHead); 

     //draw arms 
     ga.setPaint(Color.black); 
     ga.draw(squareLeftArm); 
     ga.fill(squareLeftArm); 

     //draw center 
     ga.setPaint(Color.CYAN); 
     ga.draw(circleCenter); 
     ga.fill(circleCenter); 

     //draw neck 

    } 
} 

그리고

public static void main(String[] args) 
{ 

    Frame frame = new CircleDraw(); 
     frame.addWindowListener(new WindowAdapter() 
    { 
     public void windowClosing (WindowEvent we) 
     { 
      System.exit(0); 
     } 
    });//end of listener 
    frame.setSize(600,600); 
    frame.setVisible(true); 
} 

지금은 실행되는 메인 클래스에 의해 체포해야 오류의 무리, 당신은 점점에 할 몇 가지 작업을 거기에 도착 것 같다 모양과 위치 바로 ... 도움이되지이다

enter image description here

+0

그 다음, 메인 윈도우에서, "파싱하는 동안 파일의 끝에 도달했다"는 오류가 발생하고 마지막 괄호가 강조 표시됩니다. –

+0

나는 전체 수업이 아니라 주된 수업 방식을 가르쳐주었습니다. 당신은 클래스가'public class main {'로 정의되어있다. 왜냐하면 클래스 *는 대문자로 시작해야하고 더 설명하기 쉬워야하기 때문에이 사실을 바꿔야한다. 어쩌면 공공 수업 HumanTest. – Dan