Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaFx Part 1 Build a simple GUI program. 1. DisplayStudent Create the DisplayStudent class. It will extend Application and contain a start() method, and a

JavaFx

Part 1 Build a simple GUI program.

1. DisplayStudent Create the DisplayStudent class. It will extend Application and contain a start() method, and a main() method too if you wish to use that style. 2. Set the title on the primary Stage to Display Student. 3. We want to create a GUI that looks like this figure. The visible components (other than the Stage) is a TextArea and two Labels below it. To get the layout to look the way it does we will use two BorderPanes. (Could we use other layout panes and get the identical result?) 4. The first BorderPane will layout the TextArea above (by placing it in the Top part) and the two Labels below (by placing them in the Bottom part of the pane). But how to layout the two Labels? 5. The second BorderPane will layout the Labels by putting one in the Left part and one in the Right part. Then we put the second BorderPane in the Bottom part of the first pane. 6. Load the Text area with a couple of lines of test data using the appendText() method twice, one method call per line (hint: a string that ends in \012 will cause a newline to be displayed in the TextArea, otherwise the appended lines will run together). 7. Put text into the two Labels as shown above, Connected to Test and Number of Students = 2. 8. The only buttons that have to work now are the buttons on the title bar (including the Exit button). Hints: Use the following code to create your Scene: Scene scene = new Scene(new VBox(), 400, 260); Use this code to add your pane to the Scene: ((VBox) scene.getRoot()).getChildren().addAll(pane); Using a VBox as the base will help with part 2.

Part 2 Adding menus

1. DisplayStudent We will add some code to the DisplayStudent class. 2. Add a MenuBar and two Menus: File and Edit. After creating the MenuBar, include it first in the addAll() method for your scene (so you add the MenuBar and then the pane). 3. On the File menu add three menu items: Connect, Close & Exit. 4. On the Edit menu add two menu items: Search and Clear. 5. When the program starts make sure the TextArea is blank, the left hand Labels text says No Connection and the right hand Label says Number of Students = 0. 6. When File Connect is clicked; Put up an Input Dialog that asks for a database name. Store the input from the user in a String variable called database_name. Set the text in the left hand Label to Connected to xxxx where xxxx is the database_name. 7. When File Close is clicked; Put up a Confirmation Dialog box. If the user response is OK then set the database_name string to null. Set the left hand Label to No Connection. If Cancel is clicked, do nothing to the labels. 8. When File Exit is clicked; Put up a confirmation dialog box. If the use clicks OK, shut down the program, other wise just continue execution. 9. When Edit Search is clicked; Check to see if the database_name is null. If so put up an Error dialog. If the database name is not null put up an Input Dialog requesting a Student ID number. Store the input from the user in a String variable called search_id and then put some test data into the TextArea. Set the right hand Label to Number of students = n where n is the number of lines of test data. 10. When Edit Clear menu item is clicked; Clear out the data in the TextArea. Set the right hand Label to Number of students = 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What is the performance evaluation objective of transfer pricing?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago