2011-09-13 8 views
0

こんにちは私はそうプログラミングの専門家ではないので、私はこれを可能にする方法を聞くためにここに来る。アプリケーションの実行中にsetUndecorated()を呼び出す方法は?

問題:フルスクリーンモードでクリックしたクライアントゲームが1回実行されました。setUndecorated()が呼び出されますが、フレームが既に表示されている間はカントしません。

私は新しいフレームを作成する必要があることを理解しましたが、すべてを転送する方法がわかりません。自分自身を試しました。新しいフレームの白い空白の画面が表示されます。私はあなたのいずれかが、私は本当に感謝に感謝役立つことを願って

public Jframe(String args[]) { 
    super(); 
    try { 
     sign.signlink.startpriv(InetAddress.getByName(server)); 
     initUI(); 
    } catch (Exception ex) { 
     ex.printStackTrace(); 
    } 
} 

public void initUI() { 
    try { 
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     JPopupMenu.setDefaultLightWeightPopupEnabled(false); 
     frame = new JFrame(); 
     frame.setLayout(new BorderLayout()); 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     this.setBackground(Color.BLACK); 
     gamePanel = new JPanel(); 
     gamePanel.setLayout(new BorderLayout()); 
     gamePanel.add(this); 
     JMenu fileMenu = new JMenu("Menu"); 

     String[] mainButtons = new String[] { "-", "Donate", "-", "Vote", "-", "Hiscores", "-", "Forums", "-", "Exit"}; 

     for (String name : mainButtons) { 
      JMenuItem menuItem = new JMenuItem(name); 
      if (name.equalsIgnoreCase("-")) { 
       fileMenu.addSeparator(); 
      } else { 
       menuItem.addActionListener(this); 
       fileMenu.add(menuItem); 
      } 
     } 

     JMenuBar menuBar = new JMenuBar(); 
     JMenuBar jmenubar = new JMenuBar(); 
     Jframe.frame.setMinimumSize(new Dimension(773, 556)); 
     frame.add(jmenubar); 
     menuBar.add(fileMenu); 
     frame.getContentPane().add(menuBar, BorderLayout.NORTH); 
     frame.getContentPane().add(gamePanel, BorderLayout.CENTER); 
     frame.pack(); 

     frame.setVisible(true); 
     frame.setResizable(true); 
     init(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
    } 

は、ここに私のコードです!

答えて

0

を見てみる必要がありますが、あなたはそれが見えない、再びそれが見えるようにすることはできませんか?

すなわち

myFrame.setVisible(false); 
myFrame.setUndecorated(true); 
myFrame.setVisible(true); 

"ghostbust555" と指摘したようにしかし、より良い方法があります。これは、その答えはを参照してsetFullScreenWindow()ある

public void goFullScreen() { 
    GraphicsDevice myDevice = 
     GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); 

    // wrap in try because we don't want to lock the app in fullscreen mode 
    try { 
     myDevice.setFullScreenWindow(myFrame); 

     // do your stuff 
     ... 

    } finally { 
     myDevice.setFullScreenWindow(null); 
    } 
} 
+0

myFrame.setVisible(偽); myFrame.setUndecorated(true); myFrame.setVisible(true); これは機能しません。それでもエラーはスローされます。 – Coupon22

関連する問題