Re: Size
On Apr 1, 3:01 am, "Francois Lionet" <flio...@hotmail.fr> wrote:
Sub: Size
'Size matters', but note that much more important
than size, is a meaningful subject line.
For instance..
'size of GUI client area'
...would be a much better subject line for this question.
I need to resize a JFrame (with caption) so that the client area is exactly
640x480.
Do you? Why? Needing to set the size of any
GUI component is (except in some special
situations) an indication of a poorly designed,
and fragile, GUI.
..If I do a setSize(640, 480) the client area is smaller due to the
caption and border of the frame. I need to get the size of the caption and
of the borders. But where can I find that information? (or is it a way to
resize the frame base on the client area size?)
Stop p*ssing about with the frame, and concentrate
on the *content*.
<sscce>
import java.awt.*;
import javax.swing.*;
public class INeedToBesomeArbitraryFixedSize {
public static void main(String[] args) {
JLabel bigLabel = new JLabel("I am big!");
bigLabel.setPreferredSize(
new Dimension(640,480));
JOptionPane.showMessageDialog(null, bigLabel);
// note that I neither, know, nor care, how big
// the JOptionPane of this GUI is..
}
}
</sscce>
Note also that comp.lang.java.gui is a group
that specialises in such matters.
Andrew T.