import java.awt.*; import java.awt.event.*; class WindowAdapterFrame extends Frame{ public WindowAdapterFrame(){ this.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } public void windowOpened(WindowEvent e){ this.setTitle("nonono");//★ウィンドウが開いたときにメッセージを表示したい。 } } ); } }
public class WindowAdapterFrameMain{ public static void main(String[] args){ Frame f = new WindowAdapterFrame(); f.setSize(250,100); //f.setTitle("WindowAdapter"); f.setVisible(true); } }
2件の回答
評価
0
import java.awt.*; import java.awt.event.*;
class WindowAdapterFrame extends Frame { public WindowAdapterFrame() { this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } public void windowOpened(WindowEvent e) { //ここ注意してください
class WindowAdapterFrameMain { public static void main(String[] args) { Frame f = new WindowAdapterFrame(); f.setSize(250,100); //f.setTitle("WindowAdapter"); f.setVisible(true); } }