선택 리스너 내부에서 초기화하는 ScrolledComposite 위젯이 있습니다 (차례대로 다른 컴포지트에 연결됨). 이 ScrolledComposite는 Button과 Label을 차례로 포함하는 Composite를 차례로 포함합니다. 내부 컴포지트가 나타나지 만 해당 하위 위젯에는 아무 것도 없습니다. 전에 ScrolledComposite를 여러 번 사용했는데 모든 것이 눈에.니다. 아무도 틀린 것을 볼 수 있습니까? ScrolledComposite는 클래스 변수입니다. 또한이 문제는 내가 else와 else의 내용을 처분 할 때 관계없이 발생한다는 것에주의하십시오.ScrolledComposite 어린이가 콘텐트를 채우지 못함
final Button showConsole = new Button(topLeft, SWT.CHECK);
showConsole.setText("Show Debug Console");
showConsole.setFont(new Font(domains.getDisplay(), "Segoe UI", 9, SWT.ITALIC));
showConsole.setSelection(false);
showConsole.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
//The total widget group is only supposed to appear when the button is selected
if (showConsole.getSelection()) {
scrolledConsoleComp = new ScrolledComposite(leftComposite,
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
Composite consoleComposite = new ScrolledComposite(scrolledConsoleComp, SWT.NONE | SWT.BORDER);
consoleComposite.setLayout(new GridLayout());
consoleComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
consoleComposite.setVisible(true);
scrolledConsoleComp.setContent(consoleComposite);
scrolledConsoleComp.setExpandHorizontal(true);
scrolledConsoleComp.setExpandVertical(true);
scrolledConsoleComp.setLayout(new GridLayout());
scrolledConsoleComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Button clear = new Button(consoleComposite, SWT.PUSH);
clear.setText("Clear Console");
final Label consoleText = new Label(consoleComposite, SWT.WRAP);
consoleText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
consoleText.setText("Messages: \n" + consoleData);
clear.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
consoleData = "";
consoleText.setText("Messages: \n" + consoleData);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
scrolledConsoleComp.setMinSize(leftComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
leftComposite.layout(true);
} else {
scrolledConsoleComp.setVisible(false);
scrolledConsoleComp.dispose();
leftComposite.layout(true);
}
}
감사합니다. 이 질문에있는 것이 명확하지 않은 경우 알려주십시오. 고맙습니다!
아, 그래서 모든 위젯에서 setContent()를 호출해야합니까? 나는 그것이 Composite에서 일어날 필요가있을 것이라고 생각하고 있었다. 내가 아는 것을 보여줍니다. 고맙습니다! – Sarah
안녕하세요, Sarah, 사실 당신은 오해했습니다. ScrollledComposite에는 setContent() 메소드 만 있습니다. – LppEdd
'setContent'는'ScrolledComposite'에서 모두 호출되어야합니다.'consoleComposite'는 실제로 당신이 원하는 것이 아닌'ScrolledComposite'입니다. –