0

I could to set the color of the button, but once the button is pressed its color is blue - standard. I want to be black. How do I change it?

Below is the current code:

    public JPanel gameBoard(){

        JPanel pBoard = new JPanel();
        pBoard.setSize(5*horizontalOptions,5*verticalOptions);
        pBoard.setLayout(new GridLayout(horizontalOptions,verticalOptions));
        jb = new JToggleButton[verticalOptions*horizontalOptions];
        int k=0;
        for(int i=0;i<verticalOptions;i++){
            for(int j=0;j<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 pBoard;
    }

}
user3868442
  • 117
  • 1
  • 4
  • 12
  • [read more](http://stackoverflow.com/questions/7434845/setting-the-default-font-of-swing-program) here about keys that UIManager sets. – Braj Aug 01 '14 at 11:06

1 Answers1

2

You can change that in UIManager:

UIManager.put("ToggleButton.select", Color.BLACK);
alex2410
  • 10,904
  • 3
  • 25
  • 41