2016-04-15 4 views
1

Ich möchte Komponenten in Flowlayout ausrichten. Ist es möglich? Hier ist mein Code:Container Alingments in Jframe

JPanel ppanel = new JPanel(new FlowLayout()); 
    ppanel.add(text); 
    ppanel.add(btnLogin); 
    ppanel.add(btnRegister); 

    text.setAlignmentX(LEFT_ALIGNMENT); 
    btnLogin.setAlignmentX(RIGHT_ALIGNMENT); 
    btnRegister.setAlignmentX(RIGHT_ALIGNMENT); 

picture

ich möchte Irgendwelche Vorschläge weit nach links und 2 Tasten für ganz rechts Etikett „Willkommen“ bewegen?

+1

Nein, ist es nicht möglich, mit Flowlayout. Verwenden Sie eine [horizontale Box] (http://docs.oracle.com/javase/8/docs/api/javax/swing/Box.html#createHorizontalBox--) mit [leim] (http://docs.oracle. com/javase/8/docs/api/javax/swing/Box.html # createHorizontalGlue--) oder verwenden Sie ein GridBagLayout. – VGR

Antwort

1
  yourpanel.setLayout(new BorderLayout()); 
     yorpanelpanel.add(yourbutton,BorderLayout.WEST); 
     yorpanelpanel.add(yourbutton,BorderLayout.EAST); 

Sie wollen könnte diesen Code versuchen,

+0

y das hat wirklich geholfen, danke – joki00