Re: JFrame resizing



"Stephan Lukits" <stephan.lukits@xxxxxxxxxxxxxxxx> wrote in message news:g1jfmb$fp4$00$1@xxxxxxxxxxxxxxxxxxxx
Hello Group,
why doesn't the following code work?

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

class Test extends JFrame {

public void paint( Graphics g ) {
if ( getSize().width != 200 || getSize().height != 100 ) {
System.out.println("Frame Size is different");
setSize( 200, 100 );
}
g.drawString( "A test string", 50, 75);
}

public static void main( String args[] ) {
JFrame f = new Test();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout( null );
f.setVisible( true );
}
}

I'd expect it to change the frames' size after the user has
resized the frame. But that happen only occasionally.
(I actually want to make sure, that the frams' size dosen't
go below a specific size).

cat /proc/version:
Linux version 2.6.21.4-eeepc (root@LinuxPC) (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #5 Thu Nov 8 17:17:35 UTC 2007

java -version:
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)

Also on the subject of JFrame resizing, why is it that I can restrict the minimum size of a JFrame using setMinimumSize() but I cannot restrict the maximum size using setMaximumSize()? The latter appears to have no effect on the sizing constraints of a JFrame.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@xxxxxxxxx
[Replace the "SixFour" with numbers to email me]

.



Relevant Pages

  • JFrame resizing
    ... class Test extends JFrame { ... public void paint(Graphics g) { ... java version "1.6.0_05" ...
    (comp.lang.java.gui)
  • Re: Manipulating a Third-Party Java Application from another Java Application
    ... Then you can probably locate the JFrame from within ... Based on the configuration file I found on the wrapper, ... own code as you suggest (my Java experience is limited, ... since Swing doesn't use the Win32 API for much. ...
    (comp.lang.java.programmer)
  • Re: OutOfMemoryError with socket communication
    ... If you want a special JFrame-based reusable component it is a good idea to subclass JFrame, and implement your special component in accordance with the JavaBeans specification. ... Always prefer composition over inheritance. ... Don't specialise your code. ... I've been reading "Killer Games Programming (in Java)". ...
    (comp.lang.java.programmer)
  • Re: creating a JFrame via JNI
    ... Am I having a Mac problem? ... jobject jframe; ... Passing to Java. ... Note that the exception was thrown in native code, ...
    (comp.lang.java.programmer)
  • creating a JFrame via JNI
    ... I get an unhandled native exception when trying to create a JFrame from ... The error message is unhelpful and untraceable even on Google. ... Passing to Java. ... An extra oddity is that line 8 in GUIApp.java is indeed the JFrame ...
    (comp.lang.java.programmer)