java - JToggleButton - How to change the color? -


I can set the color of the button, but once the button is pressed its color is blue - the standard. Should i be black How can I change it?

The current code is below:

  public JPanel gameboard () {JPanel pBoard = new JPanel (); PBoard.setSize (5 * horizontalOptions, 5 * verticalOptions); PBoard.setLayout (New Grid Layout (Horizontal Option, Vertical Option)); Jb = new JToggleButton [vertical option * horizontal option]; Int k = 0; For (int i = 0; I & lt; verticalOptions; i ++) {for (jt; j & lt; horizontalOptions; J ++) {jb [k] New JToggleButton ("", false) =; Jb [k] .setPreferredSize (new dimension (100, 100)); Jb [k] .setBackground (Color.white); Jb [k] .setborder (BorderFactory.createLineBorder (Color.black)); Jb [k] .setForeground (Color.black); PBoard.add (jb [k]); K ++; }} Return Peabird; }}  

After

You can change it in UIManager :

  UIManager.put ("ToggleButton.select", Color.BLACK);  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -