How to add a read-only DialogComponentString

Want to add an input,but the input value selected from the other UI.
I searched the API DOC,did not find method to set input component read-only,It’s possible to set input component read only?

another question:
How to set dialog UI component align(left or right)?


Hi @lou,
You can add a read only compont as a label:

DialogComponentLabel label = new DialogComponentLabel("read only value");

// update the text
label.setText("new text");

However, this does not have a settings model, so you need to store the selected value somewhere else.
In your case it might be a good idea to use a list selection component like: DialogComponentStringSelection, it provides a dropdown list where a user selects an option.

In the DefaultNodeSettingsPane you can only chose horizontal or vertical dialog component placement, if you want to layout the dialog yourself you need to fall back to the NodeDialogPane, create a JPanel and customize its layout with e.g. a GridBagLayout.


1 Like

You can get to the underlying swing component too, in order to change the layout detail, e.g., with your code above:

JLabel jLabel=(JLabel) label.getComponentPanel().getComponent(0);

See also and the JavaDoc for JLabel.setHorizontalAlignment()



Nice hack Steve :nerd_face: :+1:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.