2012-02-14 16 views
0

基本的なComboBox UIの配色をどのように変更しますか?私が試みたのは、setForeGround、setBackground、setOpaque(true)、setOpaque(false)setBorderです。しかし、これらのどれも動作しません。basicComboBoxUIの配色をどのように変更しますか?

私のコードは今ある:

enter image description here

しかしセクション(白領域)ドロップダウン何のためにあるのか、私が本当にしたいように見えるように:

weaponCB.setBounds(27,250,150,30); 
    weaponCB.setUI(new BasicComboBoxUI()); 
    weaponCB.setForeground(Color.white); 
    weaponCB.setBackground(Color.black); 
    weaponCB.setBorder(whiteBorder); 
    weaponCB.setFont(new Font("Trajan Pro", Font.BOLD, 15)); 
    lP.add(weaponCB, new Integer(2)); 

これが表示されるものです表示、(黒色の領域は "LANCE"白)、すなわち、背景が黒、境界線が白、単語が白色になります。これが可能で、あなたがどのように教えたら、それは私にとって大きな助けになるでしょう。ありがとう。

答えて

0

私はweaponCB.setUI(新しいBasicComboBoxUI())を配置すると非常に奇妙ですが、 setBackgroundとsetForegroundとsetBorderの下で、コンボボックスは期待どおりに動作します。ボーダーだけが表示されません。

weaponCB.setBounds(27,250,150,30); 
    weaponCB.setForeground(Color.white); 
    weaponCB.setBackground(Color.black); 
    weaponCB.setBorder(whiteBorder); 
    weaponCB.setFont(new Font("Trajan Pro", Font.BOLD, 15)); 
    lP.add(weaponCB, new Integer(2)); 
    weaponCB.setUI(new BasicComboBoxUI()); 

enter image description here

働いていた別のものだった:

@Override 
      public void paint(Graphics g) { 
       setBackground(Color.black); 
       setForeground(Color.white); 
       super.paint(g); 
      } 
     }); 
関連する問題