簡體   English   中英

如何將組組件向左對齊

[英]How to align group components to the left

我想使用組框來改善我的GUI。 但是,將組件添加到Group它們將移動到框的中心,並且不再保持對齊狀態。 如何使每個按鈕和文本移到左邊距。 具有居中元素的分組框

GridLayout layout = new GridLayout(1, true);
layout.marginWidth = 300;
Group group = new Group(this, SWT.SHADOW_OUT);
group.setText("Open file locations");
group.setLayout(layout);

Button optionOne = new Button(group, SWT.CHECK | SWT.LEFT);
optionOne.setText(AppMessages.msg("Open file A") );

Button optionTwo = new Button(group, SWT.LEFT | SWT.CHECK);
optionTwo.setText(AppMessages.msg("Open file B") );

兩組之間需要空間

按鈕保持左對齊,但是在對齊之前,您已指定300像素的邊距到按鈕的左側。

您為“ Group或“ Composite的布局指定的邊距值將設置控件中的邊距。

您是否可以嘗試從布局中刪除marginWidth

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM