Swing question: Minimum size respected on windows, not on linux?


M

mrstephengross

I have a simple Swing application. My JFrame uses a BoxLayout, and I
set a minimum size for it:

myFrame.setLayout(new BoxLayout(myFrame.getContentPane(),
BoxLayout.Y_AXIS);
myFrame.setMinimumSize(new Dimension(500, 500));

On Windows, the application respects my minimum size requirements and
does NOT let me shrink the window smaller than 500x500. On Linux, I
can shrink the window as much as I want.

How can I make Linux respect the minimum size requirements?

Thanks,
--Steve
 
Ad

Advertisements

K

Knute Johnson

mrstephengross said:
I have a simple Swing application. My JFrame uses a BoxLayout, and I
set a minimum size for it:

myFrame.setLayout(new BoxLayout(myFrame.getContentPane(),
BoxLayout.Y_AXIS);
myFrame.setMinimumSize(new Dimension(500, 500));

On Windows, the application respects my minimum size requirements and
does NOT let me shrink the window smaller than 500x500. On Linux, I
can shrink the window as much as I want.

How can I make Linux respect the minimum size requirements?

Thanks,
--Steve

I tried the code below on both Windows XP and Fedora 9. They work
identically and in neither case can the frame be sized smaller than the
minimum size. Also, it pays no attention to maximum size.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class test {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setPreferredSize(new Dimension(400,300));
f.setMinimumSize(new Dimension(200,150));
f.setMaximumSize(new Dimension(600,450));
f.pack();
f.setVisible(true);
}
});
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top