JButton没有改变颜色(Java)

时间:2018-02-11 02:07:10

标签: java swing jbutton

我正在尝试制作一个完全黑色的按钮(带有灰色字样)。但是,我的button.setBackground(color.black)只给按钮一个黑色轮廓。 这是我的代码:

public class Main{

 protected static JFrame window;

 public static void main(String args[]){
  window = new JFrame();
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.setSize(1200,800); 
  window.setVisible(true);  
  window.setResizable(false);
  window.setBackground(Color.gray);

  BottomButtons seeProgress = new BottomButtons(window, "See Progress", 200, 710);
  }
}


public class BottomButtons {

 public static JButton button;

 bottomButtons(JFrame window, String name, int x, int y){
  button = new JButton(name);
  button.setForeground(Color.LIGHT_GRAY);
  button.setBackground(Color.BLACK);
  window.add(button);
  button.setBounds(x, y, 250, 60);
  button.setOpaque(true);
 }
}

0 个答案:

没有答案
相关问题