GUI Designer - Where I will find the generated code?
Answered
Hello,
I try to use the GUI Designer of IntelliJ IDEA 2016.1.2 an d I have read https://www.jetbrains.com/help/idea/2016.1/gui-designer.html
"Binary class files. This is the default option. When selected, no Java source code is generated for GUI forms and components. When the project compiles, IntelliJ IDEA simply creates the necessary compiled runtime classes.
-
"Java source files.If this option is selected, the GUI Designer writes Java source code for the form and its components to the source file of the class to which the form is bound, on compiling, running or debugging. During compilation, two blocks of code are added to the form's class:
- A private method
$$$setupUI$$$()
that contains the GUI initializer code for the bound form and its components. - A call to the
$$$setupUI$$$()
method."
- A private method
When I start a new class TestForm with GUIForm then I will get two files "TestForm.java" and "TestForm.form". In last is the xml-code of the class. But in the class TestForm.java I don't find the code of my build gui like
contentPane.setLayout(new GridBagLayout());
((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {133, 47, 0, 0, 0};
Instead I see only
public class TestForm {
private JTextField textField1;
private JPanel panel1;
private void createUIComponents() {
// TODO: place custom component creation code here
}
}
Where is
Java source files.If this option is selected, the GUI Designer writes Java source code for the form and its components to the source file of the class
realized?
Can you explain me, what I do wrong?
Best regards
Andreas
Please sign in to leave a comment.
Are you sure you have enabled this option?
Yes, how I said. Here's my setting for it:
Use Build | Make, generated code will appear in the source file (in a section collapsed by default).
If the issue remains, please provide a sample project illustrating the problem and the exact steps to reproduce.
Thanks Serge, it runs:
Hi Serge, what do you mean by "Build|Make"? Is "Make" supposed to be an option in the "Build" menu? This is what mine looks like:
It was renamed to Build | Build several years ago.
Okay, I built it but I still can't seem to find the source code. You stated that it's in "a section collapsed by default" so I clicked every button for collapsible menus and files that I could find, but it's still not coming up.
File a bug at https://youtrack.jetbrains.com/issues/IDEA and attach a sample project to reproduce this issue.
UPDATE: I found some source code in the affiliated ".java" file, but if I open the ".form" file in notepad, I get an .xml file. I haven't seen any mention of xml with GUI though...
(Sorry, I promise this is the last question)
It's by design, source code is generated from the xml .form file.
Serge Baranov the issues occurs at the my example project https://github.com/Kolyall/GUIExample
Idea version
IntelliJ IDEA 2019.3.2 (Community Edition)
Build #IC-193.6015.39, built on January 21, 2020
Runtime version: 11.0.5+10-b520.30 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.3.0-26-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1921M
Cores: 12
Registry:
Non-Bundled Plugins: mobi.hsz.idea.gitignore
Serge Baranov also I posted the question to stackoverflow https://stackoverflow.com/questions/59896471/why-swing-gui-form-builder-doesnt-create-fields/59896556#59896556
Serge Baranov issues is posted here https://youtrack.jetbrains.com/issue/IDEA-231382
Thank you for posting the issue on our tracker, we will shortly deal with it.
Probably caused by https://youtrack.jetbrains.com/issue/IDEA-207997 .
I tried UI Designer with Gradle, and It didn't work. So I created a new Maven project and, voila, it worked.