2016-11-17 1 views
1

저는 ComponentGroup이 자동으로 공간을 채우도록하고 싶습니다 (예 : Form의 너비). 다양한 방법으로 시도했습니다. BoxLayout.y에 그것을 감싸고 있지만 작동하는 방법을 찾지 못했습니다. 이것을 달성하는 방법을 아는 사람은 누구입니까? 내가 뭘하려사용 가능한 공간을 채우기 위해 늘어나는 ComponentGroup을 만드는 방법은 무엇입니까?

은 이것이다 :

Form hiCG = new Form("ComponentGroup"); 

hiCG.add(BoxLayout.encloseY(ComponentGroup.encloseHorizontal(new Label("Text1"), new Label("Text22222")))); 

//A hack to show what I'm after 
Label label1 = new Label("Text3"); 
Label label2 = new Label("Text4444444"); 
label2.setPreferredW(hiCG.getWidth()/2); //using deprecated setPreferredW 
ComponentGroup.setSameWidth(label1, label2); 
hiCG.add(ComponentGroup.encloseHorizontal(label1, label2)); 
hiCG.show(); 
수평 구성 요소 그룹은 너무 큰 결과로는 성장하지 않는 화면에서 실패에서 UI를 방지하기 위해 스크롤 할 수

enter image description here

답변

0

크기에 맞게.

그리드 레이아웃에서 작동하는 어댑테이션을 추가 할 수는 있지만 지금은 약간 "하드 코드 된"것입니다. 해결 방법은 다음과 같이 할 수 있습니다.

Container c = GridLayout.encloseIn(2, label1, label2); 
label1.setUIID("ToggleButtonFirst"); 
label2.setUIID("ToggleButtonLast"); 
관련 문제