My code goes like this
class ActionPanel extends JPanel{
private JButton calculate;
private JLabel sup;
private Border border;
public ActionPanel(){
calculate = new JButton("Calculate Bill");
calculate.setOpaque(true);
calculate.setBackground(Color.BLUE);
sup = new JLabel("Total Cost", SwingConstants.CENTER);
setLayout(new GridLayout(0,1));
add(sup);
add(calculate);
}
}
this goes to form part of a JFrame but when it is displayed after running the program the JButton won't change color unless I do setBorderPainted(false); but then the button looks weird because it has no border, what can I do so that the JButton changes color but I don't lose the Border