Adding intelliJ form to JPanel won't fill 100%

Hi all
I created ui from using the intelliJ UI wizard and set its class to to extend JPanel,

then i am adding it To JFrame programmatically so it will appear under a Text area:

private static void myWnd() {
JFrame frame = new JFrame("intelliJ form sample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400,600));
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

BorderLayout layout = new BorderLayout();
JPanel panel = new JPanel(layout);
JTextArea text = new JTextArea();
text.setPreferredSize(new Dimension(400,400));
panel.add(text,BorderLayout.NORTH);
panel.add(new PanelIdea(),BorderLayout.CENTER);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}

The intellij created form won't fill 100% of the container (below the Text area), any idea why?

1 comment

Hello sharon,

Hi all
I created ui from using the intelliJ UI wizard and set its class to to
extend JPanel,
then i am aadding it To JFrame programmatically so it will appear
under a Text area:

private static void myWnd() {
JFrame frame = new JFrame("intelliJ form sample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400,600));
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
BorderLayout layout = new BorderLayout();
JPanel panel = new JPanel(layout);
JTextArea text = new JTextArea();
text.setPreferredSize(new Dimension(400,400));
panel.add(text,BorderLayout.NORTH);
panel.add(new PanelIdea(),BorderLayout.CENTER);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
The intellij created form won't fill 100% of the container (below the
Text area), any idea why?


I'm just not sure that the reason is in IDEA. The form you design in IDEA's
editor can be gotten with $$$getRootComponent$$$() call like:

panel.add(new Some().$$$getRootComponent$$$(), BorderLayout.CENTER);

The behavior of the form class gotten by "new Some()" is not defined in code
generated by IDEA. The reason is somewhere in manually created code.

In other words, the class, bound to a form, is not a panel you design in
IDEA. The field of this class is a panel.

Alexander.


0

Please sign in to leave a comment.