StyledTextのサイズ変更とそれが存在するExpandItemの高さをトリガーするサッシュがあります。「ジャンピー」になります。つまり、StyledTextは目的のサイズに拡張され、サイズが変更されると元のサイズに戻る傾向があります。結局、すべてが正しい場所に着陸しますが、それは醜い移行です。
「ジャンプ」を取り除くために、次のコードで何を変更できますか?
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);
//Create the expand bar
ExpandBar expandBar1=new ExpandBar(shell,SWT.None);
//Create the first expand item.
final ExpandItem expandItem1=new ExpandItem(expandBar1,SWT.None);
final Composite composite=new Composite(expandBar1,SWT.NONE);
final RowLayout layout=new RowLayout(SWT.VERTICAL);
composite.setLayout(layout);
expandItem1.setControl(composite);
expandItem1.setHeight(100);
//Add text
final StyledText one=new StyledText(composite,SWT.BORDER|SWT.MULTI|SWT.WRAP|SWT.V_SCROLL);
one.setText("aaaa\nbbbbbb\nccccc\ndddd");
//Add a sash
final Sash sash1=new Sash(composite,SWT.HORIZONTAL);
sash1.setSize(sash1.getSize().x, 10);
sash1.addListener(SWT.Selection,new Listener(){
@Override
public void handleEvent(Event event) {
one.setSize(one.getSize().x,event.y);
sash1.setLocation(0, event.y+5);
expandItem1.setHeight(event.y+10);
composite.redraw();
}
});
//Create the second expand item.
ExpandItem expandItem2=new ExpandItem(expandBar1,SWT.None);
Composite composite2=new Composite(expandBar1,SWT.None);
composite2.setLayout(new FillLayout());
StyledText two=new StyledText(composite2,SWT.V_SCROLL);
two.setText("two\nabadfae\nasdfaef\nadfef\nesfj;lef\nefsfe\nasefae\n...");
expandItem2.setControl(composite2);
expandItem2.setHeight(100);
//Final junk
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
注:このコードを改善するためのその他のヒントを自由に提供してください。私はSWTを初めて使用します。