package graphics; import java.awt.*; import javax.swing.*; public class ButtonApplication { public static void main(String[] args) { JFrame window = new JFrame("Frame with buttons in a panel"); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set up the primary panel JPanel primary = new JPanel(); primary.setBackground(Color.black); // Add three buttons to the primary panel JButton button1 = new JButton("red"); primary.add(button1); JButton button2 = new JButton("green"); primary.add(button2); JButton button3 = new JButton("blue"); primary.add(button3); // Add the primary panel to the frame and display window.getContentPane().add(primary); // component added to content pane window.pack(); // sets the frame's size to accommodate its components window.setVisible(true); // displays the frame } }