Layout of dialog components

I'm not sure of the layout class is used by addDialogComponent and I haven't inspected the code but the result if often untidy. In my dialogs I would prefer any checkboxes to be left aligned and string, numeric, selectors etc to be right aligned. I had expected this to be simple via either the setLocation or setAlignmentX - I've not experienced any problem with setTooltipText!

Quote:

DialogComponentNumber c_count = new DialogComponentNumber(
new SettingsModelIntegerBounded(
DeNovoNodeModel.CFGKEY_COUNT,
DeNovoNodeModel.DEFAULT_COUNT,
Integer.MIN_VALUE, Integer.MAX_VALUE),
"Desired number of derivatives", 1, 5);

addDialogComponent(c_count);
c_count.getComponentPanel().setAlignmentX(1.0f);
c_count.setToolTipText("THINK attempts to generate the specified number of drug-like derivatives");

I suspect the complication relates to subcomponents etc but I haven't been able to figure this out. Any suggestions would be appreciated.

Hi!

The DefaultComponents are not really designed to be custom layed out. We didn't really think anybody would try it. They are all added to a panel with BoxLayout and appear below each other, centered horizontally.
The panel you get with getPanel() has by default no layout manager, so it depends on the
individual component, what it does, how it arranges its Swing components (I didn't check them all, but most don't do any special layout handling).
I don't know what happens, if you set a new layout manager in that panel...

- Peter.

Thanks for the response.

First my opinionated preamble: for KNIME to take-off in the Life Sciences the GUI for every node needs the best possible look and feel with no more development effort than creating a similar dialog in a web page using HTML etc. The DialogComponent* series of classes go along way to achieving this - which is great! Obviously mainstream software vendors to the pharmaceuticals will be prepared to invest more effort but if some of the flaws and documentation could be improved then pharmaceuticals and biotechs would be empowered to develop their own nodes.

Looking at the code for DialogComponent, its apparent that it creates a panel into which subcomponents (and in some cases additional panels) are inserted. I remain confused about setAlignmentX not least because it does something about the horizontal position which I can't rationalise and the popup help text from Eclipse suggests that it should be setting the vertical alignment!

Following your suggestion I tried

Quote:

c_count.getComponentPanel().setLayout( new FlowLayout(2) );

which behaves as expected (right alignment of the panel created by DialogComponent).

1 Like