This lab puts together everything you learned till now: communication between cl
ID: 673621 • Letter: T
Question
This lab puts together everything you learned till now: communication between classes, the creation and display of graphical components, and tracking of user interaction. Although it is work intensive, you should be able to handle all the requirements.
What will you learn
communication between classes
use of graphical components
Deliverables
Updated files for app.java, myJFrame.java, myJPanel.java, myJPanel1.java, myJPanel2.java, student.java
Contents
In panel 1
The ActionListener has to be implemented in myJPanel1
It has to ask for first name and last name using JTextFields.
It asks for the student’s age using a JSlider.
It has to have a OK button.
When the user clicks the OK button a new student is created in p2
Students’ first name from the first JTextField
Students’ Last name from the second JtextField
Student’s age from the JSlider value
The statement student st1 = new student etc… has to be executed in myJPanel2.java
In panel 2
A button with the student’s name
A button with the student’s picture
Have the option to show at least 3 different students (show just one at a time)
For instance, if the name typed is “fred”, show a fred.jpg; if its “john”, show a john.jpg.
The layout is yours to pick.
See drawing next page.
JFrame PO P1 P2 The user types the first name here Student is created here The user types the last name here Picture of the student shown here Age 20 40 OKExplanation / Answer
public class Board extends JPanel { public Board() { BoardMethods a = new BoardMethods();//BoardMethods handles logic a.printBoard(getBoard());//irrelevant to question, helps determine winner JPanel panelLORDY = new JPanel(new FlowLayout()); //JButton alphaButton = new JButton("Hi"); //alphaButton.setBounds(213,131,100,100); //add(alphaButton); } public int[][] getBoard(){ return boardEvalMatrix; } public void paintComponent(Graphics g){ g.setColor(Color.BLUE); g.fillRect(0, 0, 1456, 916); Graphics2D newG = (Graphics2D) g; newG.setStroke(new BasicStroke(15)); g.setColor(Color.YELLOW); for(int a = 0; a < 6; a++)//rows for board --- rowHeight is 127 g.drawRect(128, 68 + (a*127), 1200, 127); g.setColor(Color.BLACK); newG.setStroke(new BasicStroke(8)); for(int a = 0; a < 6; a++)//columns for board --- columnWidth is 171 g.drawRect(128 + (a*171), 68, 171, 764); for(int a = 0; a < 6; a++)//give rows black line in middle g.drawRect(128, 68 + (a*127), 1200, 127); //g.drawString("H", 213, 131); center point //g.drawLine(50,0, 1456, 916); //width 1456 length 916 - school computer monitors JButton alphaButton = new JButton("Hi"); alphaButton.setBounds(213,131,100,100); bored.add(alphaButton); } } public class gameBoard extends JPanel { private Board bored; private RoundButton[][] buttonArray;//holds all roundButtons on board private JPanel resetPanel, quitPanel; public gameBoard() { setLayout(new BorderLayout()); buttonArray = new RoundButton[6][7]; for(int a = 0; aRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.