0
私は自分のシェルをビルドして開いた後、ランタイム中に開いた後にグラフィック要素をシェルに追加する必要があります そして、追加された新しいグラフィック要素を見ることはできません。 新しいグラフィック要素は、シェルのサイズを変更した場合に表示されます。ScrolledCompositeでオートマチックリフレッシュを行う方法SWT
この問題を修正し、自動的にリフレッシュを表示する方法はありますか これは簡単な例です。 1-タブフォルダにAの10個のボタンを追加してシェルを開きます。 2-それから
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class TabFolder
{
public static void main(String[] args)
{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(500, 500);
shell.setLayout(new GridLayout());
final CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
folder.setSize(500, 500);
CTabItem item = new CTabItem(folder, SWT.CLOSE);
final ScrolledComposite scrollComp = new ScrolledComposite(folder, SWT.V_SCROLL | SWT.H_SCROLL);
item.setControl(scrollComp);
final Composite tab1Comp = new Composite(scrollComp, SWT.NONE);
tab1Comp.setLayout(new GridLayout(1, true));
tab1Comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
scrollComp.setContent(tab1Comp);
scrollComp.setExpandVertical(true);
scrollComp.setExpandHorizontal(true);
scrollComp.addControlListener(new ControlAdapter()
{
public void controlResized(ControlEvent e)
{
Rectangle r = scrollComp.getClientArea();
scrollComp.setMinSize(folder.computeSize(r.width, SWT.DEFAULT));
}
});
for (int x = 0; x < 10; x++)
{
Button text = new Button(tab1Comp, SWT.NONE);
text.setText("A");
}
shell.open();
for (int x = 10; x < 20; x++)
{
Button text = new Button(tab1Comp, SWT.NONE);
text.setText("B");
}
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
おかげシェルのサイズを変更する場合、私はちょうどボタンBを見ることができるシェル 3- Bの10個のボタンを追加しました。
お返事ありがとうございました あなたの助けに感謝 – user1205079