[英]How to close a constructor frame?
public class RainfallStudy extends JFrame{
/**
* Declare global variables
*/
int x = 20, y = 567; //starting location for the title
int xSpeed = 20, ySpeed = 20; // the speed for x and y directions
int delay = 20; // to slow down my title
ImageIcon BackGnd, pic; // variables for the pictures
/**
* Constructor to build the frame
*/
public RainfallStudy() {
// this builds a window with a title
super("Weather Report");
setSize(1000,567);
//loading the picture files
BackGnd = new ImageIcon ("weatherBack.png");
pic = new ImageIcon ("weatherIcon.png");
setResizable(false);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
這就是我制作框架的方式,然后我在public void paint(Graphics g)
中制作了動畫。
現在,在我使用new RainfallStudy();
, window 在 animation 完成后保持打開狀態,如何手動關閉它?
在 RainfallStudy 實例上調用dispose或setVisible是否有效? 例如:
RainfallStudy rs = new RainfallStudy();
rs.setVisible(false);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.