Share
Explore BrainMass

Java UI Buttons Program

Need help need to be extended to JFrame. Attached is the same problem. your earliest assistance is greatly appreciated as I have a final in which to study for, so the sooner the better so that assignment can be posted. Thanks.

The files must be named as below:
Buttons.java
Ensure you include ALL files required to make your program compile and run.

I would like to see your .java files only.
Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter. 4
Basic Requirements
Write a complete program named Buttons that implements a window with three buttons - left, blue, and reset. When the left button is clicked, the window's contents (the three buttons) shifts left. When the blue button is clicked, the window's background color changes to blue. When the reset button is clicked, the window's contents shifts back to the original center alignment and the window's background color changes back to its original color.
In implementing the reset functionality, don't try to figure out a color constant that's used for the window's original color value. That's counterproductive because the color might be different on different computers. Instead, retrieve and save the window's original color and then when the color needs to be reset, use that saved original color value.
Original display:

After Left button is clicked:

After Blue button is clicked:

After Reset button is clicked:

Attachments

Solution Preview

Please find attached Buttons.java which implements your requirements. Has comments that are easy to follow. Good luck

You can compile and run this program if you have java sdk.

To compile:

javac.exe -g Buttons.java

The to run

java Buttons

The java source code is attached in file and also below:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Buttons extends JFrame {
JButton btnLeft=new JButton("Left");
JButton btnBlue=new JButton("Blue");
JButton btnReset=new JButton("Reset");
Container contentPane;
...

Solution Summary

The solution contains a single java source file: Buttons.java. This source was compiled and tested, and instructions provided how to compile and run program. When launched the program will display a simple form with 3 buttons- Left, Blue and Reset. When the left button is clicked, the window's contents (the three buttons) shifts left. When the blue button is clicked, the window's background color changes to blue. When the reset button is clicked, the window's contents shifts back to the original center alignment and the window's background color changes back to its original color.

$2.19