Hola a todos! Estoy comenzando a aprender a programar java, tengo 2 dudas; consiste en introducir 3 notas, redondearlas para luego sacar un promedio. Este código se puede volver mas eficiente y eficaz? Tengo problemas para que los datos pasen al txtArea, se que usa "setText" para agregar el texto, "append"para añadir. Pero aun asi no me sale

package JAVA;
import java.awt.EventQueue;
import javax.swing.JDialog;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
public class Catorce extends JDialog {
/**
*
*/
private static final long serialVersionUID = 2409303291509567329L;
private JTextField textField_Nota1;
private JTextField textField_Nota2;
private JTextField textField_Nota3;
private JTextArea txtS;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Catorce dialog = new Catorce();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the dialog.
*/
public Catorce() {
getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14));
setTitle("Reportes");
setBounds(100, 100, 450, 300);
getContentPane().setLayout(null);
JLabel lblNota_1 = new JLabel("Nota 1");
lblNota_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNota_1.setBounds(10, 11, 46, 14);
getContentPane().add(lblNota_1);
JLabel lblNota_2 = new JLabel("Nota 2");
lblNota_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNota_2.setBounds(10, 36, 46, 14);
getContentPane().add(lblNota_2);
JLabel lblNota_3 = new JLabel("Nota 3");
lblNota_3.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNota_3.setBounds(10, 61, 46, 14);
getContentPane().add(lblNota_3);
textField_Nota1 = new JTextField();
textField_Nota1.setBounds(83, 9, 86, 20);
getContentPane().add(textField_Nota1);
textField_Nota1.setColumns(10);
textField_Nota2 = new JTextField();
textField_Nota2.setBounds(83, 34, 86, 20);
getContentPane().add(textField_Nota2);
textField_Nota2.setColumns(10);
textField_Nota3 = new JTextField();
textField_Nota3.setBounds(83, 59, 86, 20);
getContentPane().add(textField_Nota3);
textField_Nota3.setColumns(10);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 92, 414, 158);
getContentPane().add(scrollPane);
JTextArea txtS = new JTextArea();
txtS.setBackground(Color.WHITE);
scrollPane.setViewportView(txtS);
JButton btnProcesar = new JButton("Procesar");
btnProcesar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
double nota1 = 0, nota2 = 0, nota3=0;
long rpt1 = 0, rpt2 = 0, rpt3 = 0 ;
int suma;
nota1 = leerNota1();
nota2 = leerNota2();
nota3 = leerNota3();
rpt1 = Redondear1(nota1);
rpt2 = Redondear2(nota2);
rpt3 = Redondear3(nota3);
suma = Suma( rpt1, rpt2, rpt3);
//System.out.println(rpt1);
//System.out.println(rpt2);
//System.out.println(rpt3);
//System.out.println(suma);
mostrarResultado(rpt1, rpt2, rpt3, suma);
}
});
btnProcesar.setBounds(322, 8, 89, 23);
getContentPane().add(btnProcesar);
}
double leerNota1(){
return Double.parseDouble(textField_Nota1.getText());
}
double leerNota2(){
return Double.parseDouble(textField_Nota2.getText());
}
double leerNota3(){
return Double.parseDouble(textField_Nota3.getText());
}
long Redondear1(double nota1){
return Math.round(nota1);
}
long Redondear2(double nota2){
return Math.round(nota2);
}
long Redondear3(double nota3){
return Math.round(nota3);
}
int Suma(long rpt1, long rpt2, long rpt3){
//Se añade int para transformar de long a int
return (int)((rpt1 + rpt2 + rpt3)/3);
}
void mostrarResultado(long rpt1, long rpt2, long rpt3, int suma){
[color=blue][u]txtS.setText("Reporte");[/u][/color]
txtS.append("Nota 1 es: " + rpt1 + "\n");
txtS.append("Nota 2 es: " + rpt2 + "\n");
txtS.append("Nota 3 es: " + rpt3 + "\n");
txtS.append("Promedio: " + suma+ "\n");
}
}Cuando ejecuto me sale error en la línea <<txtS.setText("Reporte");>> y en <<mostrarResultado(rpt1, rpt2, rpt3, suma);>>.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Apreciaría mucho su ayuda para entender en qué fallé.