0

Swingアプリケーションを実行しています。MouseEnteredおよびMouseExitedのボタンのテキストの色を変更したいと思います。

private void jButton2MouseEntered(java.awt.event.MouseEvent evt) {                                      
      this.jButton2.setBackground(Color.red); 
    }                                     
    private void jButton2MouseExited(java.awt.event.MouseEvent evt) {                                     
       this.jButton2.setBackground(Color.lightGray);
    }    

これが私が背景色を変更する方法です。ボタンのテキストの色を変更する方法。

前もって感謝します。

4

1 に答える 1

2

このメソッドを使用してButton.setForeground(Color.red);、新しいフォントの色を設定できます。

private void jButton2MouseEntered(java.awt.event.MouseEvent evt) {                                      
      this.jButton2.setBackground(Color.red); 
      this.Button.setForeground(Color.red);
    }                                     
    private void jButton2MouseExited(java.awt.event.MouseEvent evt) {                                     
       this.jButton2.setBackground(Color.lightGray);
       this.Button.setForeground(Color.lightGray);
    }  
于 2012-07-13T05:50:01.817 に答える