当前位置: 技术问答>java相关
怎样使一个JFrame不能被最大化?
来源: 互联网 发布时间:2015-11-16
本文导语: 怎样使一个JFrame不能被最大化?也就是只能是我设的大小! | import java.awt.*; import java.awt.event.*; import javax.swing.*; public class IconImageTest extends JFrame { public IconImageTest() { setTitle("Icon Image")...
怎样使一个JFrame不能被最大化?也就是只能是我设的大小!
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class IconImageTest extends JFrame
{
public IconImageTest()
{
setTitle("Icon Image");
setSize(300,200);
setResizable(false);
ImageIcon image = new ImageIcon("images/host16.gif");
setIconImage(image.getImage());
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public static void main(String[] args)
{
JFrame frame = new IconImageTest();
frame.setVisible(true);
}
}
import java.awt.event.*;
import javax.swing.*;
public class IconImageTest extends JFrame
{
public IconImageTest()
{
setTitle("Icon Image");
setSize(300,200);
setResizable(false);
ImageIcon image = new ImageIcon("images/host16.gif");
setIconImage(image.getImage());
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public static void main(String[] args)
{
JFrame frame = new IconImageTest();
frame.setVisible(true);
}
}
|
JFrame.setResizable(boolean resizable);
|
JFrame.setResizable(false)