Unable to add intelliJ form to JFrame

I made two JFrame windows
First I add programmatically Swing JPanel
To the second window I add Idea UI created panel

But I am unable to see the panel created by Idea
Attached is the program source

Any help will be appreciated
Thank you
Sharon



Attachment(s):
panelProblem.zip
6 comments

Hello sharon,

I made two JFrame windows
First I add programmatically Swing JPanel
To the second window I add Idea UI created panel
But I am unable to see the panel created by Idea
Attached is the program source
Any help will be appreciated
Thank you
Sharon


The reason why it does not work now is that you create "new PanelIdea()",
but the form you edit in UI designer is not that object. It is another JPanel
(review the code to see it). You need to do the following.

1. Provide some field bound to the root JPanel of IDEA form. For this purpose
open UI designer. In property inspector of root JPanel provide some value
in "Field name" field.

2. Recompile. Your IDEA form class will get new method "public JComponent
$$$getRootComponent$$$()".

3. In your test class instead "panel.add(new PanelIdea(), BorderLayout.CENTER);"
write "panel.add(new PanelIdea().$$$getRootComponent$$$(), BorderLayout.CENTER);"

Alexander.


0

Hi Alexander
Now i remember you already gave me this answer but I was unable to do it ..

I gave the root JPanel value on the "filed name" as you can see in the picture (i gave name to all the components on this panel)

I recompiled the project ( Build -> rebuild project).
But I was unable to spot $$$getRootComponent$$$()" method, it wasn't added to the form.

Please help
Thank you
Sharon



Attachment(s):
panel.jpg
0

Hello sharon,

Hi Alexander Now i remember you already gave me this answer but I was
unable to do it ..

I gave the root JPanel value on the "filed name" as you can see in the
picture (i gave name to all the components on this panel)

I recompiled the project ( Build -> rebuild project). But I was unable
to spot $$$getRootComponent$$$()" method, it wasn't added to the
form.

Please help
Thank you
Sharon


Your picture is correct. For me in the same case $$$getRootComponent$$$()
is generated.

But anyway, this method is not the main point. Actually, we need the field.
Is mainPanel field inserted into the source? If yes, then it's Ok, you can
manually write any method like getMainPanel() and use it instead of missing
$$$getRootComponent$$$().

Alexander.


0

Thank you very much,
I am able to see the panel now,

The only problem is that the panel wont get 100% of its parent component ,
Why don't the JPanel (mainPanel) have the property "Horizontal Size policy"

How can i tell the form to occupy 100% of the parent panel?


Thank you

Sharon

0

Hello sharon,

The only problem is that the panel wont get 100% of its parent
component , Why don't the JPanel (mainPanel) have the property
"Horizontal Size policy"


Basically, because such properties are provided by layout of parent component.
If you place, say, a button on a panel with IntelliJ GridLayout, the button
inspector contains Horizontal size policy. But if you place the same button
on a panel with BorderLayout, then it does not, just because BorderLayout
does not provide such properties.

In terms of your test project this depends on what you have written in MainTst
class. BTW for me your panel looks correctly. Maybe, you could attach one
more screenshot and show what's wrong.

Alexander.


0

I believe you don't get the auto generation of "public JComponent $$$getRootComponent$$$()" if you do not specify a name for the JPanel in the UI Designers property window under "field name".  I have used "mainPanel" here.

Screen shot 2011-12-18 at 4.05.13 PM.png  

0

Please sign in to leave a comment.