We use cookies to collect and analyze information on site performance and usage,
to provide social media features and to enhance and customize content and advertisements.
import java.awt.*;
import java.awt.event.*;
public class TestNoMaximize {
MyFrame theFrame;
public static void main (String args[]){
TestNoMaximize t = new TestNoMaximize();
t.theFrame = new MyFrame("A Dummy Frame");
t.theFrame.setVisible(true);
}
}
class MyFrame extends Frame {
public MyFrame(String title){
super(title);
addWindowListener
(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
// no minimize or maximize
this.setResizable(false);
this.setSize(200,200);
}
public void paint(Graphics g) {
g.drawString("try to resize me...", 50, 50);
}
}
There is no way to allow minimizing but not maximizing unless you trap the maximizing
in the paint method and then resize to the original size.
import java.awt.*;
import java.awt.event.*;
public class TestNoMaximize {
MyFrame theFrame;
public static void main (String args[]){
TestNoMaximize t = new TestNoMaximize();
t.theFrame = new MyFrame("A Dummy Frame");
t.theFrame.setVisible(true);
}
}
class MyFrame extends Frame {
public MyFrame(String title){
super(title);
addWindowListener
(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
this.setSize(200,200);
}
public void paint(Graphics g) {
Dimension d = this.getSize();
if (d.getHeight() != 200 && d.getWidth() != 200)
this.setSize(200,200);
g.drawString("try to maximize me...", 50, 50);
}
}
NOTE: These How-to may not work with the Microsoft JVM. It's a feature...