I've created a simple Frame with a button on Eclipse but i can't close it.
package esercizi1;
import java.awt.*;
public class FinestraConBottone {
public static void main(String[] args) {
Frame finestra = new Frame ("Titolo");
Button bottone = new Button ("Cliccami");
finestra.add (bottone);
finestra.setSize (200,200);
finestra.setVisible (true);
}
}
You forgot to add the close operation:
finestra.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
finestra.dispose();
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.