Create a jpanel inside of the frame

Assignment Help JAVA Programming
Reference no: EM131587051

In this assignment you will continue the Bus Route Search Engine mini-project by creating a small user interface application. The classes you create must be compatible with either the classes for the past two assignments (the ones you submitted last week and the week before), or our posted solution. Please indicate which in a comment at the top of the classes. Hint: If you have NetBeans installed, then you can approach this homework by using the Design tab. With the Design tab, you can create your UI by dragging and dropping the swing controls. Once you are done with the UI, you can copy/paste your source code into a new Java file to work on for the remaining tasks. Please see the "Creating Simple GUI in NetBeans" video under Week 4 for a quick example on how to create a user interface in NetBeans using drag and drop.

Q1: The first part of the assignment involves creating very basic GUI controls: a frame, panel, and slider.Create a JFrame. Add a title to the frame called "Bus Route Reservation". Set the frame size to 475 by 500 pixels. Create a JPanel inside of the frame. You will be adding all of your UI components to this JPanel.

Inside of the panel, create a label that says "Choose Color." Right below it, make a slider that changes the background color of the panel when the slider is moved to a particular color. The slider values should be RGB color values from 0 to 255 (or black to white). Assume that the RGB values for red, green, and blue are the same value - for instance: (240, 240, 240). The slider label's text should be replaced with the RGB value that the slider is currently on.

Q2: Add functionality to search for an Itinerary.Create labels and text fields that allow the user to enter a bus type, a source bus station, and a destination bus station, as well as the departure time and the arrival time to search for one or more available bus routes in an Itinerary. Also, create a ComboBox (see Chapter 11) that will allow the user to select from a list of bus route Itineraries. Each item in the ComboBox represents an Itinerary element, e.g. the first comboBox element is the first Itinerary in the array.

Methods:
Your BusFrame class should include the following methods (The methods that check for validation must have message dialogs indicating to the user if the information entered in each text field is invalid):
initComponents() : Method used to initialize UI components and controls
default constructor : Inside the default constructor, call the initComponents() method
convertTime(String input) : converts time string (from text input -- ie departure time text field) to a Time object and returns the Time object
checkValidBusType() : returns true if entered bus type is valid and exists in BusType enum and can be converted to a BusType object
checkValidBusStations(String src, String dest) : will return true if both the source and destination bus stations entered in the text fields exist in BusStation enum
checkValidTime(String depTime, String arriveTime) : checks if the time is in valid format (hh:mm a) and returns true if it is in the correct format

Make sure all text fields have error checking and exception handling for invalid input. For example, if the user enters an integer as a departure time instead of a String (ie 1200 instead of 12:00 PM), a JOptionPane error message should appear stating, "Incorrect format for departure time." If the bus type they entered is not in the BusType enum, then the option pane should say, "Bus type unavailable. Please choose a different bus type." If the bus station they entered is not in the BusStation enum, then the option pane should say, "Unknown city." Make sure the times are in hh:mm a format.

Q3: Create a button that says Search and a button that says View. When the user clicks Search, the validation methods will get called and check if the text fields are valid and display error messages if they are not. If the search returns itineraries, a combobox will get populated. When the user clicks View, if all the fields are filled out and have valid input, a JOptionPane with a message dialog should appear stating, "Bus route search successful!" The frame should open a new JFrame with the title, "Bus Route Information," and a size of 475 by 500 pixels. This frame has the bus route information displayed in a JTextArea.

Q4: In the RouteFrame class, you will need to display information for each BusRoute in the Itinerary.

The addTo() method shown in the UML diagram is used to add information to the JTextArea for both one-way and connecting bus routes (when applicable). It takes in a String val, which is the string of information that needs to be appended to the JTextArea. (For instance, if you would like to append the String "Bus", that is the String that needs to be passed in inside your addTo() method call in the RouteFrame class). You need to display the following information in a JTextArea:
Bus Type: Display the bus type
Departure Bus Station: Display the source bus station
Departure City: Display the departure city based on the departure bus station (use the getBusStationCity() method you implemented in the Unit 2/3 assignment to get the bus station city)
Destination Bus Station: Display the destination bus station
Destination City: Display the destination city based on the destination bus station (use the getBusStationCity() method again)
Departure Time: Display the departure time
Arrival Time: Display the arrival time
Bus Number: Display the bus number
Cost: Display the total cost, which should be computed by the Itinerary object.

I have most of the BusFrame.java created but I am having issues with Questions 3 and 4. I am unsure of how to use the public Itinerary[] findItineraries from the RouteManager.java class to populate the combo box. And I am unsure of how to use the search button to validate the info in the text boxes is correct before searching and populating the combo box. I also don't know how to use the view button to display the info choosen.

Attachment:- java code.rar

Reference no: EM131587051

Questions Cloud

Create a reconciliation schedule to reconcile net income : Prepare a reconciliation schedule to reconcile 2011 net income and December 31, 2011 stockholders%u2019 equity from a U.S. GAAP basis to IFRS.
Explains the concept of community policing to local citizens : Create a brochure using the Brochure Builder for distribution in your area that explains the concept of community policing to local citizens.
What technique will be used for data collection : What technique will be used for data collection, What is your hypothesis or hypotheses
What is a reasonable conclusion of given statement and why : You get on an elevator. There are nine people already in the elevator, and six floor-indicator buttons are lit.
Create a jpanel inside of the frame : Create a JPanel inside of the frame. You will be adding all of your UI components to this JPanel - the first comboBox element is the first Itinerary in array
The difference between gross and net take home pay : Define and discuss the following: Estimated and contingent liabilities and The difference between gross and net take home pay
Where you have worked or have firsthand knowledge : Where you have worked or have firsthand knowledge? Would this be different if the business had a less desirable and less expensive inventory?
Data analysis-economics mba course : Looking for direction for my final course project for my Data Analysis, Economics MBA course.
Compare the grandparents role in the collectivist family : Compare the grandparents' role in the collectivist family to the grandparents' role in the individualist family

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write and test a java program to read in multiple lines

A palindrome is defined as a string of 1 or more characters that contains a word, a phrase or a number that reads the same forward and backward, ignoring case, punctuation and white space.

  Create an artificial life environment

Create an artificial life environment. You should have at least three types of agents: Herbivore, Carnivore, Plant

  Determine the number of quarters

You have an amount of change (such as 41 cents or 72 cents) and you want to figure out how many quarters, dimes, nickels and pennies that is. Your change will always be an integer value between 0 and 99.

  Write program that can be used to read an extract from a log

Write a program that can be used to read an extract from a log for one elevator and print the following statistics: the total \uptime", that is the total time the elevator was in service, Σ(tdown - tup) (in years).

  Create java servlets

Create a new JSON "view" (e.g., a JSP page that only displays the JSON representation of the data)

  Create an application for an animal-fur trimming service

create an application for an animal-fur trimming service. the business is open 15 weeks of the year from april through

  Splitting a linked list into two sublists in equal sizes

Write the definition of the method splitMid. Also write a program to test your method. (Use either the class UnorderedLinkedList or the class OrderedLinkedList to test your method)

  Development of a real-time driver tracking system

Development of a Real-Time Driver Tracking System. Putting comments on every major function and methods explaining its use and brief description.

  Write a class named retailitem that holds data

Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables:description-a string that holds a brief description of the item.unitsOnHand-an int that holds the number of units cur..

  Java program for real estate agent

Write down java program for real estate agent. Program must perform the following tasks: ask users for average house price for the each of past 5 years for single family residence of 1500 square feet.

  Create a virtual directory

Create a Web archive file and attach to this assignment. Do not copy (cut and paste) any example code, create your own code and use the examples as a guide.

  Size of the frame to be set a little bit larger than content

I need the size of the frame to be set a little bit larger than its content, which is a label. Also, the location could be set so that it could be appeared not at the upper left corner of the screen. And we can set the foreground and background co..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd