我用 
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
gd.setFullScreenWindow(frame);
来实现界面全屏显示,全屏没问题,但是全屏退出时出现了问题,通过采用gd.setFullScreenWindow(null);来实现退出,但是发现界面没有window的最大最小化、关闭状态栏。
请问如何能在退出全屏时能够有window的最大最小化、关闭状态栏。

解决方案 »

  1.   

    偌大个CSDN居然连个灌水的人都没!!!
      

  2.   

    并不清楚你写的具体代码,我用这个方式是有最大化、最小化或还原这些按钮的,你可以把代码贴出来看看。
    你是用的JFrame么还是JDialog什么的?
      

  3.   

    JFrame 
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    gd.setFullScreenWindow(frame);
      

  4.   

    up,我问的是我退出全屏时用 gd.setFullScreenWindow(null); 
    但是没有window 边框,有办法解决没?
      

  5.   

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    =>
    frame.setExtendedState(JFrame.NORMAL);
      

  6.   

    up,贴上全部代码。
    //=====================================================================
    package com.cc502.net;import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import java.awt.BorderLayout;
    import java.awt.Toolkit;
    import javax.swing.WindowConstants;
    import java.awt.Dimension;
    import java.awt.Button;
    import java.awt.GridLayout;
    import java.awt.Label;
    import javax.swing.ImageIcon;
    import java.awt.Graphics;
    import javax.swing.JLabel;
    import java.awt.FlowLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.GraphicsEnvironment;
    import java.awt.GraphicsDevice;
    import java.awt.HeadlessException;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.awt.Font;
    import java.util.Locale;
    import java.awt.DisplayMode;
    import java.awt.Window;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyAdapter;
    import javax.swing.AbstractAction;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowListener;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;/**
     * <p>Title: </p>
     *
     * <p>Description: </p>
     *
     * <p>Copyright: Copyright (c) 2010</p>
     *
     * <p>Company: kthw.ltd</p>
     *
     * @author shenxian
     * @version 1.0
     */
    public class SplitJPane extends JFrame {
        private GraphicsDevice device;
        /**
         * 返回当前window
         */
        public Window getFullScreen() {
            return device.getFullScreenWindow();
        }    /**
         * 退出全屏独占模式
         */
        public void restoreScreen() {
            frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);     
        }
        /**
         * 设置全屏独占模式 ,该方法可以将window设置为全屏模式
         */
        public void setFullScreen(DisplayMode displayMode, JFrame window) {
            window.setUndecorated(true); //取消window装饰
            window.setResizable(false);
            device.setFullScreenWindow(window);
            if (displayMode != null && device.isDisplayChangeSupported()) {
                device.setDisplayMode(displayMode);
            }
        }    public SplitJPane() {
            device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();        final String ImagePatg = "D:\\download\\images\\" ;
            image1 = new ImageIcon(ImagePatg + "001.jpg");
            image2 = new ImageIcon(ImagePatg + "002.jpg");
            image3 = new ImageIcon(ImagePatg + "003.jpg");
            image4 = new ImageIcon(ImagePatg + "004.jpg");
            image5 = new ImageIcon(ImagePatg + "005.jpg");
            image6 = new ImageIcon(ImagePatg + "006.jpg");
            allPaneInfo = new JPanel(new GridLayout(3,3));
            pane1 = new JPanel() {
                public void paintComponent(Graphics g) {
                    // 图片随窗体大小而变化
                    g.drawImage(image1.getImage(), 0, 0, this.getSize().width,
                                this.getSize().height, this);
                }
            };
    //        label = new JLabel(){
    //            public void paintComponent(Graphics g) {
    //                // 图片随窗体大小而变化
    //                g.drawImage(image1.getImage(), 0, 0, this.getSize().width,
    //                            this.getSize().height, this);
    //            }
    //        };
            pane2 = new JPanel(new BorderLayout()){
                public void paintComponent(Graphics g) {
                               g.drawImage(image2.getImage(), 0, 0, this.getSize().width,
                                           this.getSize().height, this);
                }
            };
            pane3 = new JPanel() {
                public void paintComponent(Graphics g) {
                    g.drawImage(image3.getImage(), 0, 0, this.getSize().width,
                                this.getSize().height, this);
                }
            };
            pane4 = new JPanel(){
                public void paintComponent(Graphics g) {
                    g.drawImage(image4.getImage(), 0, 0, this.getSize().width,
                                this.getSize().height, this);
                }
            };
            pane5 = new JPanel(){
                public void paintComponent(Graphics g) {
                    g.drawImage(image5.getImage(), 0, 0, this.getSize().width,
                                this.getSize().height, this);
                }
            };
            pane6 = new JPanel(){
                public void paintComponent(Graphics g) {
                    g.drawImage(image6.getImage(), 0, 0, this.getSize().width,
                                this.getSize().height, this);
                }        };
            allPaneInfo.add(pane1);
            //allPaneInfo.add(label);
            allPaneInfo.add(pane2);
            allPaneInfo.add(pane3);
            allPaneInfo.add(pane4);
            allPaneInfo.add(pane5);
            allPaneInfo.add(pane6);
            frame = new JFrame("分割Panel");
            panelDes = new JPanel(new FlowLayout());
            JLabel label = new JLabel("图片");
            pre = new JButton("上一幅");
            next = new JButton("下一幅");
            panelDes.add(pre);
            pre.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("前1幅");
                    image1 = new ImageIcon(ImagePatg + "201.jpg");
                    pane1 = null ;
                    pane1= new JPanel() {
                        public void paintComponent(Graphics g) {
                            // 图片随窗体大小而变化
                            g.drawImage(image1.getImage(), 0, 0,
                                        this.getSize().width,
                                        this.getSize().height, this);
                        }
                    };
                    frame.repaint();
                }
            });
            allPaneInfo.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 4) {                    
                        restoreScreen();
                    }
                }
            });        panelDes.add(label);
            panelDes.add(next);
            frame.setUndecorated(true);
            frame.getContentPane().add(allPaneInfo, BorderLayout.CENTER);
            frame.getContentPane().add(panelDes, BorderLayout.SOUTH);
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            frame.setSize(800, 600);
            //The following code ensure the window shown on the center of screen.
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            frame.setLocation((dim.width - frame.getWidth()) / 2, (dim.height - frame.getHeight()) / 2);
            frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(frame);
            DisplayMode dm = new DisplayMode(dim.width,dim.height,DisplayMode.BIT_DEPTH_MULTI,DisplayMode.REFRESH_RATE_UNKNOWN);
            this.setFullScreen(dm,frame);
            frame.setVisible(true);
        }
        private JFrame  frame = null;
        private JButton pre = null, next = null;
        private JLabel label = null ;
        private JPanel  pane1 = null;
        private JPanel  pane2 = null;
        private JPanel  pane3 = null;
        private JPanel  pane4 = null;
        private JPanel  pane5 = null;
        private JPanel  pane6 = null;
        private JPanel  allPaneInfo = null;
        private JPanel  panelDes  = null ;
        ImageIcon image1 = null ;
        ImageIcon image2 = null ;
        ImageIcon image3 = null ;
        ImageIcon image4 = null ;
        ImageIcon image5 = null ;
        ImageIcon image6 = null ;
        public static void main(String[] args) {        SplitJPane splitjpane = new SplitJPane();
        }}
    //==================================================================
    请大家看啥原因!