I don't think it is good practice to take away a basic user control
like the ability to resize a window. But you can do it by:
<yourJFrame>.setResizable(false);
> Is there a way do disable the (default) resize option (right corner
> with the mouse)of a Window??
>
> Thanks in advance
>
> Arnoud
java.awt.Window is not resizable as there are no resize handles. You
can resize java.awt.Window objects programatically. So I assume you mean
java.awt.FRame when you say Window.
java.awt.Frame has a method:
public void setResizable(boolean resizable)
Sets whether this frame is resizable by the user.
In JDK1.4, you can use turn off the frame decorations with
frame.setUndecorated(true);
This will make it look like a Window.
Prior to JDK1.4 you may have to listen to ComponentEvent and reset
the size every time in the componentResized(ComponentEvent ce) callback.
You could also override the setSize(Dimension) and setBounds(...) methods.
> Is there a way do disable the (default) resize option (right corner
> with the mouse)of a Window??
>
> Thanks in advance
>
> Arnoud
Sandip Chitale - 23 Aug 2003 02:49 GMT
Here is a more general example of min and max size:
/**
* FrameResize.java
*
* @author Sandip Chitale
*/
import java.awt.*;
import java.awt.event.*;
public class FrameResize extends Frame {
public static void main(String args[])
{
Frame f = new FrameResize();
f.setSize(300, 300);
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
f.addComponentListener(
new ComponentAdapter() {
public void componentResized(ComponentEvent ce)
{
Frame sf = (Frame) ce.getComponent();
sf.removeComponentListener(this);
sf.setSize(
Math.min(Math.max(sf.getSize().width, 200), 500) ,
Math.min(Math.max(sf.getSize().height, 200),500)
);
sf.addComponentListener(this);
}
}
);
}
}// FrameResize
> java.awt.Window is not resizable as there are no resize handles. You
> can resize java.awt.Window objects programatically. So I assume you mean
[quoted text clipped - 22 lines]
> >
> > Arnoud