Question
Below is a code creating 4 simple buttons. I need to modify it so I can give color to the buttons and the background please
Below is a code creating 4 simple buttons. I need to modify it so I can give color to the buttons and the background please help
import java.awt.*; import javax.swing.*;
class ButtonFrame extends JFrame { JButton Button1 ; JButton Button2 ; JButton Button3 ; JButton Button4 ;
// constructor for ButtonFrame ButtonFrame(String title) { super( title ); setLayout( new FlowLayout() );
Button1 = new JButton("Button 1"); Button2 = new JButton("Button 2"); Button3 = new JButton("Button 3"); Button4 = new JButton("Button 4"); add( Button1 ); add( Button2 ); add( Button3 ); add( Button4 ); // add the button to the JFrame setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }
public class ButtonDemo { public static void main ( String[] args ) { ButtonFrame frm = new ButtonFrame("Basic GUI");
frm.setSize( 400, 80 ); frm.setVisible( true ); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started