Hello all, I require some help and I hope I am in the right forum.
I have a project I am attempting to do requiring me to build a window that accepts an input for a student ID number, and answers for a quiz to be taken. The window will have text fields for input of an answer to a question, which will be input into an array, compared with another array which holds the answer key, and then both of those shall be compared with a third which holds points for the correct answer. None of that is related to my problem now, but I thought it might help give an idea of what I am trying to envision the program to do. Right now I have two files, my main class file and my driver file (excuse me if I am naming them incorrectly). In my Class file, I have two void functions that are building the first panel for the user to input his/her student ID number. I have the panel fully built, I believe, besides the button's action listener to apply the information to the variable I set for it. In the driver file, I created a new object, and now I am trying to figure out a way to display it just to test my progress, but I am coming up short, and I cannot seem to find any resources to indicate what or how to do it. I apologize if this is an obvious mistake, but I don't see what I am doing wrong. I would appreciate any help in the matter, as well as any suggestions.
Thank you to anyone who can or will help.
Here is my class file.
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.text.*; public class Quiz extends JFrame { private int studentID; final private int SIZE = 8; private char[] quizAnswerkey = {'a', 'c', 'd', 'd', 'b', 'a', 'c', 'a'}; private char[] quizAnswers = new char[SIZE]; private int[] quizPoints = {10, 5, 10, 5, 5, 15, 20, 10}; private JLabel messageLabel; private JTextField idText; private JButton storeButton; private JPanel panel; public void ID() { setTitle("Student ID info"); setSize(310, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); buildIDpanel(); add(panel); setVisible(true); } private void buildIDpanel() { messageLabel = new JLabel("Please enter your student ID number"); idText = new JTextField(15); storeButton = new JButton("Input"); panel = new JPanel(); panel.add(messageLabel); panel.add(idText); panel.add(storeButton); } }
and here is my driver file
public class QuizDriver { public static void main(String args[] ) { Quiz quiz = new Quiz(); quiz. } }