必须要自己重写吗?
因为在 JDK 1.4 中, JFrame 的API有简单的方法.
在 main 方法中加入: JFrame.setDefaultLookAndFeelDecorated(true);
就可以了, 而且比你想要的还要好. :)
因为在 JDK 1.4 中, JFrame 的API有简单的方法.
在 main 方法中加入: JFrame.setDefaultLookAndFeelDecorated(true);
就可以了, 而且比你想要的还要好. :)
解决方案 »
- struts2.3.1.2中使用<sx:tree>标签生成动态树形结构的问题
- 看了很久没看出来哪里有问题,大家帮忙啊
- mybatis怎么和spring结合
- 有关hibernate中批量更新的问题,在线等...
- structs下的系统安全性问题
- AXIS生成的WEBSERVICE里如何连接MYSQL数据库
- 视频JAVA教材
- 100分:关于如何解决邮件附件名称乱码问题(另贴给分,这个请放心)
- 急,在线请教送100分
- struts - error 提示问题! (有请 kui(kui) 及各位高手 进来解答)
- j2ee 在window2k 下的安装和配置 问题?
- 在线等待!急,请问jbuilder里怎么自动生成get和set方法亚?
跟他说 "Java讲究的就是 Component Reuse & Code Reuse"
不必要 "Re-invent Wheel"
以及 ICONIFIED 和 NORMAL 常量
提示一下 frameInstance.setState(ICONIFIED);
mport javax.swing.*;
import java.awt.event.*;
import java.awt.*;public class JFrameMenuMini extends JFrame implements ActionListener
{
public JMenuBar createMenuBar()
{
JMenuBar menuBar = new JMenuBar();
JMenu opMenu = new JMenu("Operation");
JMenuItem minMenuItem = new JMenuItem("Minimize");
JMenuItem maxMenuItem = new JMenuItem("Maximize");
minMenuItem.setActionCommand("minimize");
maxMenuItem.setActionCommand("maximize");
minMenuItem.addActionListener(this);
maxMenuItem.addActionListener(this);
opMenu.add(minMenuItem);
opMenu.add(maxMenuItem);
menuBar.add(opMenu); return menuBar;
}
public void actionPerformed(ActionEvent e)
{
if("minimize".equals(e.getActionCommand()))
{
this.setState(JFrame.ICONIFIED);
}
else
{
this.setState(JFrame.NORMAL);
}
}
public static void main(String[] args)
{ JFrameMenuMini frame = new JFrameMenuMini(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(frame.createMenuBar());
frame.pack();
frame.setVisible(true); }}