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

This would be a simplified code example from 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 true; }
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 );
}
}

But this code works at my side only the first time
and when I maximize the window, then it snaps back.

regards
Stephan
.



Relevant Pages

  • Re: JFrame resizing
    ... class Test extends JFrame { ... public void paint(Graphics g) { ... Dimension calculateSize() { ...
    (comp.lang.java.gui)
  • Re: JFrame resizing
    ... public void paint(Graphics g) { ... g.drawString("A test string", 50, 75); ... Dimension calculateSize() { ... It works only occasionally at resizing and always at maximizing. ...
    (comp.lang.java.gui)
  • JFrame resizing
    ... class Test extends JFrame { ... public void paint(Graphics g) { ... java version "1.6.0_05" ...
    (comp.lang.java.gui)