Re: JFrame resizing



Stephan Lukits schrieb:
Andrew Thompson schrieb:
On May 28, 9:34 pm, Stephan Lukits <stephan.luk...@xxxxxxxxxxxxxxxx>
wrote:
...
(I actually want to make sure, that the frams' size dosen't
go below a specific size).

<sscce>
> [...]
</sscce>

Thanks for your answer to the above question. This question
unfortunately is a simplification of what I actually want.
Resizing was an important part of the question. Now I try
to be precise and short (excuse my english):


This code is a simplified version of what I have in mind:

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

class Test extends JFrame {
public void paint( Graphics g ) {
if ( isRecalculationNecessary() ) {
setSize( calculateSize() );
repaint();
return;
}
g.drawString( "A test string", 50, 75);
}

boolean isRecalculationNecessary() {
return (getSize().width != 200) || (getSize().height != 100);
}
Dimension calculateSize() {
return new Dimension( 200, 100 );
}
public static void main( String args[] ) {
JFrame f = new Test();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout( null );
f.setSize( 200, 100 );
f.setVisible( true );
}
}


It works only occasionally at resizing and always at maximizing.

regards
Stephan
.