I need some help with a Netbeans GUI with 2 buttons and 1 text area. I have 2 issues, but let me explain what I'm trying to do. First button will collect data from 2 text fields (a and b) and this is stored in a 2D array. The second button will process 3 calculations from the array data. The text area will display the data in the array when the first button is clicked and then display the calculations when the 2nd button is clicked.
My first button (jbutton1) has the code for the exceptions and declaring the 2D array.
My issue here is that when I click the button to enter the data in the 2D array it should display the data in the text area, but it doesn't. I see my string field, but not the data.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
             
        // exception for minutes entered less than or equal to 0 and not greater than 240
        double jTextField1 = 0;

        try  {
                jTextField1 = Double.parseDouble(
                        this.jTextField1.getText());
            if (jTextField1 <= 0 || jTextField1 > 240){
                throw new Exception();
            }
             }
        catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Invalid input. Minutes can't be less than 0 or more than 240. Please try again",
                    "Error", JOptionPane.ERROR_MESSAGE);
            return;
             }
        double jTextField2 = 0;
        try {
                jTextField2 = Double.parseDouble(
                        this.jTextField2.getText());
                
            if (jTextField2 <=0) {
                throw new Exception();
            }
             }
        catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Invalid input. Earnings must be greater than zero. Please try again"
                   , "Error", JOptionPane.ERROR_MESSAGE);
                   return;
            }

       double[][] earnings = new double[10][2];
        for (int i = 0; i <earnings.length; i++){
            for (int j = 0; j < earnings[i].length; j++){
                earnings[i][j]=2; //example
                System.out.println(earnings[i][j]);
            }
        }
jTextArea1.append("\n Minutes      Earnings\n *************************");
       // separates detail from report and lists all minutes and earnings in array


    }

2nd issue is the 2nd button (jbutton2) should complete the calculations and display them in the text area, but all it shows is my string field. There is an issue with a NullPointerException, but I'm not sure how to correct this without creating additional errors in my calculation code.

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        // TODO add your handling code here:
        JButton2 button2 = new JButton2("Click me");
        
        //Displays in text area report title
        jTextArea1.append("Report of your wages to Date:");
        jTextArea1.append("\n"); //start a new line

//add total minutes tutoring and display  in text area
    int totalmin = 0;
    int[] data = null;
        for (int jTextField1 : data)
        {
            totalmin = totalmin + jTextField1;
            jTextArea1.append("Total Minutes Spent Tutoring =" + totalmin);
    }                                        
//add total earnings and display in text area
      int totalearn = 0;
        for (int jTextField2 : data)
        {
        totalearn = totalearn + jTextField2;
        jTextArea1.append("Total Earnings= " + totalearn);

    }

    //calculates average per hour wage
    int average = 0;

    {
        average = totalearn / (totalmin / 60);
        jTextArea1.append("Average Per Hour Wage= " + average);
       jTextArea1.append("%\n"); //add a break between lines
       //notes in text area the minimum wage
        jTextArea1.append("Minimum Wage is currently = $6.55");
    }

    //wage analysis based on average and current minimum wage


    if (average < 6.55)
        {
        jTextArea1.append("Your average wages per hour are below average");
        }
       else if (average >= 6.55 && average <= 6.55*2)
        {
        jTextArea1.append("Your average wages per hour are then average");
        }
       else
     {
        jTextArea1.append("Your average wages per hour are above average");

    }
    }

I'm very new at Java and any help would be greatly appreciated!!!!

no idea with this code snipped, but:

1/ change jTextField1 to http://download.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html - Number Instance, just allovee chars 0-9

adtv..
- remove parse
- integer Instance
- double Instance


2/ JTextArea is very EDT sensitive, probably more that 50pct you never show ...
pack this outPut only

addToTextArea("Report of your wages to Date:");

public void addToTextArea (final String str){
  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
       jTextArea1.append(str);
    }
  });
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.