Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I prevent swing components from resizing automatically when maximizing jInternalFrame?

I’m coding a simple application with DB connections and one of the components I’m using most is jInternalFrame inside a jDesktopPane.
After pressing a specific button (File > Connect) a jInternalFrame gets added inside the jDekstopPane and is automatically maximized to fit the entire desktop pane. The problem is that the jToolBar on the top of the internal frame gets resized (as you can see by clicking here).
Of course, if I de-maximize the internal frame the sizes of the components are correct (as seen here).
If it can be of help, this is the snippet of code I’m using to maximize the internal frame on its opening:

try {
    this.setMaximum(true);
} catch (PropertyVetoException e) {
    System.out.println("ERRORE!");
}

Edit: I also tried messing with the Layout Space but I’m not sure that’s the right spot to look for an answer.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can set a preferred, minimum and maximum size for components. Just try setting the maximum size of your JToolBar with

.setMaximumSize(new Dimension(Integer.MAX_VALUE, desiredHeight))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading