Intellij Swing Designer overwriting code from custom component
Answered
Hi everyone, I'm having an issue with the Custom create functions with the swing editor.
When I have the button checked for a specific item (say a radiobutton) I need to create the element in craeteUIComponents() but then whatever I set for it (for example the text) it is overwritten by whats in the editor.
private void createUIComponents() {
// TODO: place custom component creation code here
radioButton1 = new JRadioButton("TEST");
}
private void $$$setupUI$$$() {
createUIComponents();
...
radioButton1.setText("RadioButton1");
root.add(radioButton1, new com.intellij.uiDesigner.core.GridConstraints(3, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
It will turn out like this:
I understand the "why" I just need the "how to set my own text"
Thanks, Aidan.
Please sign in to leave a comment.
Set the text in the UI Designer or override it at the later state (in the form class constructor).
I cent set it in the UI Designer because I need to set it programmatically and do you mean the code that the designer generates? Because I cant to that because it overwrites itself on every build to update changes made in the designer.
You can change it in the form class constructor which is called later than the $$$setupUI$$$ method.