メソッドからではなくクラスから自分の仕事を成し遂げようと思ったとき、私はちょうどJavaをいじくり回していました。私がしたことをチェックしてください。
import javax.swing.*;
class foolingAround{
public static void main(String ARG[]) {
createMyInterface();
}
private static void createMyInterface(){
JFrame f = new JFrame("Frame from Swing but not from other class");
f.setSize(100,100);
f.setVisible(true);
new createAnotherInterface();
}
}
class createAnotherInterface{
public static void main(String arg[]){
giveMe();
}
static JFrame giveMe(){
JFrame p = new JFrame("Frame from Swing and from another class");
p.setSize(100,100);
p.setVisible(true);
return p;
}
}
エラーなしでコンパイルされましたが、からのフレームclass createAnotherInterface
は表示されませんでした。なんで?メソッドではなく、異なるクラスを作成するのはいつですか?