How to use Java AWT setBackground

You have added the JPanel over the JFrame which completely blocks out the underlying container on which you have set the color. You could do this instead: public Gui(String title) { super(title); JPanel pane = new JPanel(); setBounds(100, 100, 500, 500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container con = this.getContentPane(); pane.setBackground(new Color(0, 0, 0)); con.add(pane); setVisible(true); }

Java: Custom Buttons in showInputDialog

You can use custom component instead of a string message, for example: import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; public class TestDialog { public static void main(String[] args) { Object[] options1 = { “Try This Number”, “Choose A Random Number”, “Quit” }; JPanel panel = new JPanel(); panel.add(new JLabel(“Enter number between 0 and 1000”)); … Read more