[Solved]Reading L04 Content Pages Lesson 04 Graphical User Interfaces Complete Assignment Accordin Q37075167
After reading all L04 content pages in Lesson04: Graphical User Interfaces, you will complete this assignmentaccording to the following information:
Assignment Objectives
- Practice on implementing a MVC project
- Start working with Java Graphics
- Implement interfaces combined with Graphics
Deliverables
A zipped Java project according to the How to submit Labs andAssignments guide.
O.O. Requirements (these items will be part of your grade)
- One class, one file. Don’t create multiple classes in the same.java file
- Don’t use static variables and methods
- Encapsulation: make sure you protect your class variables andprovide access to them through get and set methods
- all the classes are required to have a constructor thatreceives all the attributes as parameters andupdate the attributes accordingly
- Follow Horstmann’s Java Language Coding GuidelinesLinks to anexternal site.
- Organized in packages (MVC – Model – View Controller)
Contents
Create a graphic application that will display data from theclasses that implemented TableMember and TableData.
FootballPlayerData
FootballPlayerData will now implement a second interface, calleddisplayable.
Graphics
VERY IMPORTANT: This table implements theTableData interface. So, if you build one graphical panel for onetable, and if the panel is modularized and parametrized, this panelis automatically ready to display any other table that implementsTableData. This is because if one panel knows how to handle anddisplay one TableData interface, it knows how to handle and displayany class that implements the TableDatainterface.
The graphics don’t have to look exactly like that but thegeneral structure should be like the schema below. You will useJLabels and/or JButtons for the basic units of display.
All these classes belong to View.
- View creates the InitialPanel, the first and enclosingpane
- InitialPanel has one other panel (in future assignments it willhave more panels)
- CenterPanel.java
- with a row of buttons with the headers from the table
- each attribute name in its own button
- the number of buttons depend on the size of the array returnedby getHeaders( )
- with a row of buttons with the lines from the table
- each attribute value in its own button
- the number of lines depend on the value of the attributelinesBeingDisplayed
- with a row of buttons with the headers from the table
- CenterPanel.java
The NetBeans Project
This new assignment brings in a new interface, Displayable, andnew classes in View, InitialFrame, InitialPanel andCenterPanel.
You should keep building from your previousTableMember/TableData Netbeans project.
- <default package>
- App.java
- Controller
- Controller.java
- Model
- Displayable.java
- FootballPlayer.java
- FootballPlayerData.java
- Height.java
- Model.java
- Person.java
- TableData.java
- TableMember.java
- View
- CenterPanel.java
- InitialFrame.java
- InitialPanel.java
- View.java
Below is the suggested initial code in app and in Controller.Your code may vary, this is a suggestion.
public class app{ public static void main(String[] args) { View view = new View(); Model model = new Model(); Controller controller = new Controller(model, view); }}public class Controller{ Model model; View view;public Controller(Model m, View v){ model = m; view = v; view.CenterInitialSetup(model.getFpData().getLinesBeingDisplayed(), model.getFpData().getHeaders().size()); view.CenterUpdate(model.getFpData().getLines(model.getFpData().getFirstLineToDisplay(), model.getFpData().getLastLineToDisplay()), model.getFpData().getHeaders());}
Here are some comments on the code:
Functionality
There is a new class in this project, CenterPanel.Java
- CenterPanel
- it is the panel in charge of displaying the data
- it has a row of buttons or labels to display the headers. Thisrow should be graphically distinct from the lines below it. Thiscan be done by using labels, and/or by using a different backgroundand/or a different font.
- it has also a number of lines to display the table data. Theselines should be graphically distinct from the headers
- it needs a layout, most likely a GridLayout
There is also a new Interface, Displayable.java
- Displayable.java
package Model;public interface Displayable{ public int getFirstLineToDisplay(); public int getLineToHighlight(); public int getLastLineToDisplay(); public int getLinesBeingDisplayed(); public void setFirstLineToDisplay(int firstLine); public void setLineToHighlight(int highlightedLine); public void setLastLineToDisplay(int lastLine); public void setLinesBeingDisplayed(int numberOfLines); }
- Displayable.java
- public int getFirstLineToDisplay();
- public void setFirstLineToDisplay(int firstLine);
- these first two methods are about an int attributethat will hold the number of the first line to be displayed. Thenumber represents the index of an element in the array of the classthat implements the TableData interface.
- public int getLineToHighlight();
- public void setLineToHighlight(int highlightedLine);
- the two methods above are about an int attribute thatwill hold the number of the line on the screen that should behighlighted. It will be used only in a later assignment but it ispart of the interface and needs to be implemented even if it is notfully functional yet.
- public int getLastLineToDisplay();
- public void setLastLineToDisplay(int lastLine);
- these two methods are about an int attribute that willhold the number of the last line to be displayed. The numberrepresents the index of an element in the array of the class thatimplements the TableData interface.
- public int getLinesBeingDisplayed();
- public void setLinesBeingDisplayed(int numberOfLines);
- these two methods are about an int attribute that willhold the number of the lines that will appear on the screen at onetime. It will be most likely 20 but it should a variable. Theapplication should work with any number of lines. So if this numberis set to 10 or 15, this is the number of lines that should appearon the screen.
FAQ – Frequently Asked Questions
Updating Graphics
If you make changes in the layout or add and remove one or manycomponents at once, then you might force the Panel to be updatedusing the method validate().
validate( ) recalculates the layout after some changesare made.
You may also need to repaint().
repaint( ) forces the screen to be refreshed.
For instance,
add(p1);add(p2);…remove(p1);remove (p2);add(p3);add(p4);validate();repaint();
Arrays of JButtons
Keep in mind that graphics components are classes and objectsjust like any other class and object in Java. The only differenceis that they have the ability to have a graphical display.
Then, yes, you can have an array of JButtons or JPanels forinstance.
ArrayList<JButton> buttonArray; // declares the JButton ArrayListArrayList<JLabel> labelArray; // declares an ArrayList of JLabelsWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageWe were unable to transcribe this imageShow transcribed image text
Expert Answer
Answer to After reading all L04 content pages in Lesson 04: Graphical User Interfaces, you will complete this assignment according… . . .
OR

