Hi,
I have a mini java swing program where by it has 3 separate classes.
- application.java
- question.java
- test.java
Now, the application.java is the main application that will invoke the result.
At the test.java, there's a constructor method as follows:
Question.java is mainly the getter and setter.public String getResult() { int score = 0; String[] choices; String score = ""; for (int i = 0; i < test.length; i++) { if (test[i].getCorrect() == test[i].getAns()) { score++; } else { score += "Question " + (i + 1) + " is " + test[i].getCorrect() + "\n"; } return result;
At the Test.java,
there's a line which I'd like a vertical bar to appear in this JOptionPane there.
JOptionPane.showMessageDialog(null, newTest.getResult()).
Can anybody tell me how to go about doing it?
I have read up so much but yet is totally confused.
One of the examples mentioned that you have to create a JTextArea like below.
p2 = new JPanel(); p2.add(jtxtDetails = new JTextArea("abc").
But, what I want to achieve is really get the newTest.getResult into the JTextArea.
Am really bad about Java programming hence hope someone can shows me how to achieve it.
Many thanks.