setVisible メソッドを宣言する JFrame クラスがどのクラスを継承するかについて、Java API を調査するという宿題に取り組んでいます。次に、そのクラスをインポートし、main メソッドのコードを変更して、frame 変数が JFrame 型ではなくその型として宣言されるようにします。
setVisible メソッド JWindow を宣言しているクラスを見つけましたが、コードを変更しようとすると実行されないので、助けていただければ幸いです。
import javax.swing.JFrame;
import javax.swing.JWindow;
//JFrame is inherited from java.awt.Frame class
//setVisible is declared by the java.awt.Window class
public class ProductFrame extends JWindow
{
public ProductFrame()
{
// all of these methods are available because
// they are inherited from the JFrame class
// and its superclasses
this.setTitle("Product");
this.setSize(200, 200);
this.setLocation(10, 10);
this.setResizable(false);
// this method uses a field that's available
// because it's inherited
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
// this creates an instance of the ProductFrame
JWindow frame = new ProductFrame();
// this displays the frame
frame.setVisible(true);
}
}