2013-04-22 52 views
0

我必須創建一個基本的Login FormSwingJButtonActionListner。所以我寫了下面的代碼:無法在java中創建登錄表單Swing

private void Balance() throws IOException { 
getContentPane().removeAll(); 
JPanel test = new JPanel(); 
JLabel singin = new JLabel(); 
javax.swing.ImageIcon icon = createImageIcon(
    "https://dl.dropboxusercontent.com/u/20476478/Capture.PNG", 
    "a pretty but meaningless splat"); 
singin.setIcon(icon); 
test.add(singin); 
getContentPane().add(test); 
repaint(); 
printAll(getGraphics()); 
} 

它創建類似下面的UI:

sample

But i am looking for this: 

I want like this

我嘗試了很多,但不能以適合的尺寸像上面那樣。我剛開始學習Swing

+1

您可以使用'CardLayout'完成此任務。使用電子郵件地址/密碼和登錄按鈕登錄後,佈局中的第一張卡片將爲空白。 – 2013-04-22 12:29:06

回答

1

您可以使用FormLayoutHere就是一個例子。

+0

我可以在JPanel中添加FormLayout嗎? – 2013-04-22 12:40:01

+0

當然,爲什麼不呢? – Apurv 2013-04-22 12:45:29

+0

是'import com.jgoodies.forms.builder.DefaultFormBuilder;'jgoodies是jar嗎? – 2013-04-22 12:46:18