关键是全屏以后,如何在全屏的画面中显示一个还原的按钮。
谢谢!

解决方案 »

  1.   

    可以定义一个旗标boolean flag
    当为true时,按钮是最大化功能
    为false时,是还原功能.
      

  2.   

    初始化一个还原的按钮,setVisible(false),全屏以后setVisible(true)
      

  3.   

    写了一段程序:
    public class Win
        extends JApplet {
            ......
        JFrame f;
        JButton b = new JButton("Button");
        private boolean flag = false;   //旗标
        public Win(JFrame jf) {
               f = jf;
        }
            ......
        public void init() {
            ......
            Container cp = getContentPane();
            cp.setLayout(new FlowLayout());
            b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                       if (!flag) {
                          f.setExtendedState(Frame.MAXIMIZED_BOTH);//最大化
                          flag = !flag;
                       }
                       else {
                          f.setExtendedState(Frame.NORMAL);//还原
                          flag = !flag;
                       }
                  }
             });
             cp.add(b);
          }    public static void main(String[] args) {
              ......
              JFrame frame = new JFrame();
              Win applet = new Win(frame);
              ......
        }