import java.awt.*; import java.awt.event.*; import javax.swing.*; public class NoFrameWindow extends JWindow implements ActionListener { //Eclipseの場合、シリアライズ可能クラスでこれがないと警告が出る private static final long serialVersionUID=0; //ウィンドウ消去ボタン(Frameのようにボタンがないので必要) JButton exitButton=new JButton("終了"); // public NoFrameWindow(){ // JPanel panel=new JPanel(); panel.setLayout(new FlowLayout()); panel.add(exitButton); //コンテナ枠 Container cp=getContentPane(); cp.add(panel,BorderLayout.CENTER); // exitButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==exitButton){ //その環境で利用可能なグラフィックデバイスを取得 GraphicsDevice device=GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); //既にフルスクリーンなら先にそれを解除 if(device.isFullScreenSupported()){ if(device.getFullScreenWindow()==this){ device.setFullScreenWindow(null); //フルスクリーンを解除 } } //ウィンドウ消去 dispose(); } } }