2015-06-02 37 views
0

如何設置按鈕以轉到下一個小程序?代碼如下:如何設置登錄按鈕轉到下一個小程序?

if (strp.matches(strp) && stru.matches(stru)) { 
    register rg=new register(); 
    rg.setVisible(true); 
    this.setVisible(false); 
} 
else { 
    JOptionPane.showMessageDialog(null,"User name or password are not correct."); 
    return; 
} 

確認密碼和用戶名後,只顯示空白。如何設置小程序,以便點擊按鈕後它將轉到下一個小程序?

+0

總之, '小程序' 應該是面板。使用'CardLayout'在視圖之間翻轉。 –

回答

0

請嘗試以下...

if (strp.matches(strp) && stru.matches(stru)) 
{ 
    Class applet2 = Class.forName("register"); // give complete name of register class including package name 
    Applet appletToLoad = (Applet)applet2.newInstance(); 
    appletToLoad.setStub(this); 
    setLayout(new GridLayout(1,0)); 
    add(appletToLoad); 
    appletToLoad.init(); 
    appletToLoad.start(); 
} 
else 
{ 
    JOptionPane.showMessageDialog(null,"User name or password are not correct."); 
    return; 
} 
相關問題