스윙 구성 요소를 사용하여 Java에서 프레임 & 패널을 만들려고하지만 "잘못된 선언, 반환 유형 필요"라는 myframe()에서 오류가 발생합니다. 선생님이 교실에서 그것을 실행하면 성공적으로 실행되었지만 이제는 오류가 발생합니다.JFrame을 생성하는 중 오류가 발생했습니다.
import javax.swing.*;
class myFrame extends JFrame {
private mypanel p1;
myframe() /*here I'm getting error that "invalid decleration, return type required */ {
this.setSize(400, 500);
this.setTitle("My First GUI");
setDeafultCloseOpeartion(JFrame.EXIT_ON_CLOSE);
this.add(p1);
setVisible(true);
}
}
class mypanel extends Jpanel {
private JButton b1;
mypanel() {
b1 = new JButton("Click me");
this.add(b1);
}
}
class mygui {
public static void main(String args[]) {
myframe f = new myframe();
myframe f1 = new myframe();
}
}
MyFrame이란은 MyFrame을 –
같은 잘못되지이었다 ... 그리고 클래스 이름은 대문자 문자로 시작해야합니다. 즉, 'MyFrame'이어야합니다. – camickr
Jpanel은 JPanel – Ingram