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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!