close
class Init 是用來自動設定好Size、Location、visable等等的類別,可以減少主要類別裡的程式複雜度
import java.awt.*; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; public class Init { /*polymorphism*/ public static void InitWin(Frame v){ v.setSize(1000,800); v.setLocation(500,100); v.setLayout(null); v.setVisible(true); } public static void addWinListen(Frame v){ /*Interface*/ v.addWindowListener( new WindowListener(){ /*WindowListener Method*/ public void windowOpened(WindowEvent e) {} public void windowClosing(WindowEvent e) {v.dispose();} public void windowClosed(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} } ); } public static void setButton(Button b, int weigh, int height, int x, int y){ b.setSize(weigh,height); b.setLocation(x,y); } }
文章標籤
全站熱搜
留言列表