2017-05-14 5 views
0

実際には、ゲーム用の「設定」ウィンドウを作成しようとしています。別のウィンドウの背景色を設定したいと思います。私は何をすべきか分かりません。いくつかのアイデアpls?別のJFrameのJComboBoxを使用して、JFrameのバックゴールカラーを設定するにはどうすればよいですか?

+0

可能な複製(http://stackoverflow.com/questions/15995375/how-to-display- [私のコンボボックスで選択した色を表示する方法]色選択のコンボボックス) –

答えて

0

さまざまな場所で実装できます。方法の一つは、たとえば、コンストラクタである:

public YourClassPanel() { 
// to set Look&Feel  
      try { 
       UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); 
      } catch (ClassNotFoundException ex) { 
       Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex); 
      } catch (InstantiationException ex) { 
       Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex); 
      } catch (IllegalAccessException ex) { 
       Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex); 
      } catch (UnsupportedLookAndFeelException ex) { 
       Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex); 
      } 
      SwingUtilities.updateComponentTreeUI(this); 
      this.addWindowListener(new WindowAdapter() { 
       @Override 
       public void windowClosing(WindowEvent e) { 
        ControlPanel.tgp = null; 
       } 
      }); 

      this.setBounds(0, 0, 710, 580); 
      this.setTitle("Buffer Allocation Panel"); 
      this.setPreferredSize(null); 
      this.setResizable(false); 

    this.setBackground(Color.yellow); //to set Background 
    this.setForeground(Color.magenta); // to set Foreground 
    this.setOpaque(a!=255); // to set Opaque 

     } 
0

JPanel背景の色をPropertiesに設定します。

+0

私はJavaの初心者です –

+0

あなたはより良く説明できますか? –

関連する問題