2017-05-21 2 views
0

Jlabelfillmeup이라고 말하고 싶습니다. 버튼을 추가하려고하면 버튼 오른쪽에 레이블이 표시되지 않습니다. 애플릿을 사용하고 JButtons을 사용하고 있습니다. 모든 조언을 많이 주시면 감사하겠습니다. 여기 버튼 배치

는 GUI 사진 여기 Java Layout Options

워드 프로세서를 참조 그리고 당신의 요구에 맞는 하나 buttonPane2의 레이아웃 매니저를 설정하는 것이 좋습니다 것 enter image description here

The blackJack game I am trying to make

setBackground(new Color(130,50,40)); 
    setLayout(new BorderLayout(3,3)); 

    BlackjackCanvas board = new BlackjackCanvas(); 
    add(board, BorderLayout.CENTER);  

    Panel buttonPanel = new Panel(); 
    buttonPanel.setBackground(new Color(220,200,180)); 
    add(buttonPanel, BorderLayout.SOUTH); 

    Panel buttonPane2 = new Panel(); 
    buttonPane2.setBackground(new Color(220,200,180)); 
    add(buttonPane2, BorderLayout.EAST); 

    Panel buttonPane3 = new Panel(); 
    buttonPane3.setBackground(new Color(220,200,180)); 
    add(buttonPane3, BorderLayout.WEST); 

    Button hit = new Button("Hit!"); 
    hit.addActionListener(board); 
    hit.setBackground(Color.lightGray); 
    buttonPanel.add(hit); 

    Button stand = new Button("Stand!"); 
    stand.addActionListener(board); 
    stand.setBackground(Color.lightGray); 
    buttonPanel.add(stand); 

    Button newGame = new Button("New Game"); 
    newGame.addActionListener(board); 
    newGame.setBackground(Color.lightGray); 
    buttonPanel.add(newGame); 

    JLabel money = new JLabel("Fill me up!"); 
    money.setBackground(Color.lightGray); 
    buttonPane2.add(money); 

    Button money1 = new Button("A rare commodity"); 
    newGame.addActionListener(board); 
    newGame.setBackground(Color.lightGray); 
    buttonPane2.add(money1); 
+0

다른 웹 사이트의 이미지에 ** 연결 **하지 ** 마십시오. 대신 편집기에서 이미지 도구를 사용하십시오. 외부 소스에 연결하고 어떤 이유로 든 죽을 경우 리소스에 더 이상 액세스 할 수 없으므로 질문을 이해하기 어렵게 만듭니다. – BackSlash

+0

@BackSlash 사진을 추가 할 수 없습니다. – toningbasher

답변

1

에게 있습니다.

이 작업은 setLayout (new xxxLayout());

+0

Steven Kirby, 저는 박스 레이아웃을 사용했고 작동합니다. 감사 – toningbasher

관련 문제