RowLayout in SWT that vertically aligns with the baseline of the font

SWT RowLayout is great for this purpose, however I would like to see the vertical alignment of the original font for all widgets containing text.

Could there be a ready made custom layout that does this?

Snippet204.java probably has what it takes to implement it, but I just want to ask if this has been done before. Could not find it, but this seems like a typical requirement.

At the top screenshot is the layout of the line, below is the fixed layout, which I manually arranged to the baseline (for this, WindowBuilder has a binding).

demo screenshot

+4
source share
1 answer

RowLayout center. true, .

center , . false.

public static void main(String[] args)
{
    Display display = new Display();
    Shell shell = new Shell(display);

    RowLayout layout = new RowLayout();
    layout.center = true;

    shell.setLayout(layout);
    shell.setText("StackOverflow");

    new Label(shell, SWT.NONE).setText("Label");
    new Button(shell, SWT.PUSH).setText("Button");

    shell.pack();
    shell.open();

    while (!shell.isDisposed())
    {
        if (!display.readAndDispatch())
        {
            display.sleep();
        }
    }

    display.dispose();
}
+7

All Articles