Question: In Java using NETBEANS Create an Application that has two JButtons one that has the text Red and the other that has the text Blue

In Java using NETBEANS

In Java using NETBEANS Create an Application that has two JButtons one

Create an Application that has two JButtons one that has the text Red and the other that has the text Blue When the Red button is clicked change the background of the application window to red When the blue button is pressed change the background of the application window to blue SpecificS enn sJo Create a JPanel to hold your Buttons . Set the layout of the JPanel to a GridLayout that is one row by two columns . Add the JButtons to the Panel . Set the layout of the content pane to a flow layout .Add the JPanel to the content pane son MSJc The actionPerformed method needs to distinguish which JButton generated the event. This can be accomplished by using the getSource method from the ActionEvent argument public void actionPerformed(ActionEvent ae) JButton btn (JButton) ae.getSource); // getSource returns the JButton that generated the event. if(btn your button) Please note that "your button" is not real code It means that you should put the name of one of the buttons you created there

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!