Hello,
I am trying to build a gui with two textfields, a textarea, and a few buttons. The two textfields are for the user to enter in random numbers (one number in each textfield). I then want the person to be able to hit a button that will then take these two values, put them into a two-dimensional array, and then display those values inside the textarea. The person should then be able to enter in two more values, hit the button, those two new values go into the array with the others and the textarea should then display all four values. Here is the part of the code that I am having trouble with:
private void enterButtonActionPerformed(java.awt.event.ActionEvent evt) {
double number1 = 0;
try {
number1 = Double.parseDouble(
this.minutesField.getText());
if (number1 <= 0 || number1 > 240) {
throw new Exception();
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, "Invalid input. Please try again.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
double number2 = 0;
try {
number2 = Double.parseDouble(
this.wagesField.getText());
if (number2 <= 0) {
throw new Exception();
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, "Invalid input. Please try again.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
my[][] array = new my[10][2];
for (int r=0; r<array.length; r++) {
for (int c=0; c<array[r].length; c++) {
}
}
resultsArea.setText("************************\nMinutes Wages\n" + array);
}
When the button is clicked, the textarea then displays the setText message, but the array looks like: '[[Lclass$class;@randomNumbersLetters' - where randomNumbersLetters is a bunch of numbers and letters that change when I enter different values into the textfields and press the button again. There is probably an easy solution to this but as a beginner at Java I am having trouble figuring this out.
Thanks in advance!