Write a Java program that constructs a Graphical User Interface using JavaFX.Java Programming

Minimal Submitted Files

You are required, but not limited, to turn in the following source file:

Assignment12.java (no need to change)
ControlPane.java (no need to change)
TextControlPane.java (It needs to be completed)
TextPane.java (it needs to be created and completed)

Requirements to get full credits in Documentation

  1. The assignment number, your name, StudentID, Lecture day/time, and a class description need to be included at the top of each file/class.
  2. A description of each method is also needed.
  3. Some additional comments inside of methods (especially for a "main" method) to explain code that are hard to follow should be written.

New Skills to be Applied

In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed:


Classes may be needed:  
Button Event handling
Slider Event handling
Timeline animation

Program Description

Class Diagram:

Write a Java program that constructs a Graphical User Interface using JavaFX.

The  GUI program should contain two sets of four buttons for a text, "Start", "Stop", "Clear" and "Change the text". The first three buttons will be organized horizontally, and there should be a textfield where a user can enter a text, and the button “Change the text” should be  under the textfield (see the snapshot of the GUI). Under the button “Change the text”, there should be a label "Rate", then below it, there will be a slider that a user can use to change the rate (speed) of a text. Right hand side of the buttons, a textfield, a label and a slider there are panes, each pane showing a text with their initial color. The top should be red and the bottom one should be blue with their background black. The picture below shows a snap shot of the GUI. Each pane should keep printing the given text.

 (The size of the applet here is approximately 550 X 400).

When "Stop" button is pushed, the corresponding text printing movement stops. When "Start" button is pushed, the text printing movement should start printing again.


A user should be able to change the color of the text of each pane (top or bottom) using the Color Picker.

By entering another text in each textfield and pushing the button for "Change the text", will make the panel to start printing the newly entered text in their corresponding pane.

By moving each slider, a user should be able to change the rate of text printing. When a rate increases, the corresponding text printing is done faster. Note that these two sets of text printings can have a completely independent movement of each other.

Pushing the "Clear" button should clear all texts printed in the corresponding pane.
In the following snapshot, the clear button for the top pane was pushed, thus only the top pane was cleared.


Here is how it should work:

Play media comment.

Class description

TextPane class

TextPane class a subclass of Pane class. It is used to define a pane where texts are drawn. It has the following additional attributes:

Attribute name

Attribute type




current x coordinate of the text/string to be drawn



current y coordinate of the text/string to be drawn



each step that the current x coordinate moves for the text/string for each timeline ticks



each step that the current x coordinate moves for the text/string for each timeline ticks



current string to be drawn in a pane



color that is used to draw the string



a given string will be drawn with this time line ticking

The following constructor method should be provided:

public TextPane(Color color, String initialString)

The current color is initialized to the value of the color parameter, and the string1 is initialized to the value of the initialString parameter.
The background of this pane should be set to black color. The x1 and y1 should be initialized to 0, and The stepX and stepY should be set to 30. The timeline1 should be instantiated with its duration of 1000 mill seconds and an object of TextHandler class that you will be defining. The timeline1’s rate should be 1.  Then it should start by calling play() method.

The following method should be implemented:

public void resume()

The timeline1 should start again using its start method.

public void suspend()

The timeline1 should stop using its stop method.

public void changeColor(Color anotherColor)

It sets the member variable currentColor using the parameter.

public void clear()

It should remove all text drawn in its pane.

public void changeString(String string2)

It sets the member variable string1 using the parameter.

public void setRate(int rate1)

This method set the rate of the timeline1 using its parameter. (Hint: setRate method of the Timeline class)

TextHandler class

This class can be defined as a private class of the TextPane. It implements ActionHandler<ActionEvent> interface.

public void handle(ActionEvent event)

Its handle method defines how texts are drawn in the pane. stepX should be added to x1 and stepY should be added to y1, then a new object of the Text class (javafx.scene.text package) should be created using the updated x1, y1, currentColor, and string1, and it should be added to the pane that is displaying them.
Also the drawn texts should not go outside of the panel. If x1+stepX < 0 or x1+stepX > getWidth()-string1.length()*7,
then the sign (+ or -) of stepX should be changed.
If x1+stepY < 0 or y1+stepY > getHeight(),
then the sign (+ or -) of stepY should be changed.


Instructions Files

Java Programming Experts

Neno S.
Java Programming

60 Answers

Ray Bjork
Java Programming

90 Answers

View More Experts

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

256 Experts Online