import java.awt.*;
import javax.swing.*;
public class FrameTest
{
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
JFrame frame = new SimpleFrame();
frame.setUndecorated(true);
frame.setResizable(true);
frame.setTitle("AAAAAAAAA");
frame.toFront();
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}
class SimpleFrame extends JFrame
{
public SimpleFrame()
{
add(new Content());
pack();
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenWidth = screenSize.width;
int screenHeight = screenSize.height;
setSize(screenWidth/2,screenHeight/2);
setLocationByPlatform(true);
Image image = Toolkit.getDefaultToolkit ().getImage ("C:\\Users\\Asuna\\Pictures\\00010.JPEG");
setIconImage(image);
}
}
class Content extends JComponent
{
public static final int MESSAGE_X = 75;
public static final int MESSAGE_Y = 100;
private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 200;
public void paintComponent(Graphics g)
{
g.drawString("BBBBBBBBBBBBBBBBBB",DEFAULT_WIDTH/2,DEFAULT_HEIGHT/2);
}
public Dimension getPreferredSize()
{
return new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT);
}
}
为什么用上frame.setUndecorated(true); 这个方法就会报错 不就只是把标题栏去掉吗
繁星点点滴滴
相关分类