How to set background color of a button in Java GUI?

后端 未结 7 1080
名媛妹妹
名媛妹妹 2020-12-06 00:30

Below is the code which creates 9 buttons in gridlayout form on a specific pannel3. What i want is to make the background of each button black with grey text over it. Can a

相关标签:
7条回答
  • 2020-12-06 01:20

    Simple:

    btn.setBackground(Color.red);

    To use RGB values:

    btn[i].setBackground(Color.RGBtoHSB(int, int, int, float[]));

    0 讨论(0)
提交回复
热议问题