This is a project for class, I have to do it their particular way, which requires taking a couple textfields for input, adding the entries to a 2d array, and displaying the results in a textArea for each submitted record. Then perform various calculations on the array data and display the results in the textarea.
My problem is getting it to display cleanly in the textArea. Since I'm just concatenating spaces in between two variables on the same line, when the first variable has a different number of characters from other rows it looks terrible. I need to have like a column offset for the second column of data rather than my hacked up appending " " spaces.
Code:
public class myClass extends javax.swing.JFrame {
double tutorMinutes;
double tutorPay;
double [][] tutorArray = new double[1][2];
double defaultAmt = 0.00;
public myClassStart() {
initComponents();
//Initialize the Text Area headings
jTextArea2.append("Minutes: ");
jTextArea2.append(" ");
jTextArea2.append("Payment: ");
jTextArea2.append("\n");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//ENTER BUTTON PRESSED
for(int i = 0; i < tutorArray.length; i++){
for(int j = 0; j < tutorArray[i].length; j++){
//Assign input from the text fields to variables
tutorMinutes = Double.parseDouble(jTextField1.getText());
tutorPay= Double.parseDouble(jTextField2.getText());
//Assign the variables to indexes in the array
tutorArray[j][0] = tutorMinutes;
tutorArray[j][1] = tutorPay;
//Reset text entry fields
jTextField1.setText(String.valueOf(defaultAmt));
jTextField2.setText(String.valueOf(defaultAmt));
//Append the new entry to the textArea
jTextArea2.append(String.valueOf(tutorArray[j][0]));
jTextArea2.append(" "); //spacing I want
jTextArea2.append(String.valueOf(tutorArray[j][1]));
jTextArea2.append("\n");
}
}
}
}
Any ideas? Thanks.
Bookmarks