Re: JFrame resizing
- From: Stephan Lukits <stephan.lukits@xxxxxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 10:56:17 +0200
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
.
- Follow-Ups:
- Re: JFrame resizing
- From: Stephan Lukits
- Re: JFrame resizing
- References:
- JFrame resizing
- From: Stephan Lukits
- Re: JFrame resizing
- From: Andrew Thompson
- Re: JFrame resizing
- From: Stephan Lukits
- JFrame resizing
- Prev by Date: Re: JFrame resizing
- Next by Date: Re: JFrame resizing
- Previous by thread: Re: JFrame resizing
- Next by thread: Re: JFrame resizing
- Index(es):