I am fairly new to Java GUI so ANY help you give is greatly appreciated.
There is a scenario for showing warning message if not data is entered in GUI. These warning messages are displayed in the GUI however soon after that program fails with a NullPointerException
private void addActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String tempdate = date.getText();
if(tempdate.isEmpty() ){
datelabel.setVisible(true);
}
String tempttl = total.getText();
if(tempttl.isEmpty() ){
totallabel.setVisible(true);
typelabel.setVisible(true);
}
String temptype = null;
if (rain.isSelected()){
temptype = rain.getText();
}
if (snow.isSelected()){
temptype = snow.getText();
}
if (sleet.isSelected()){
temptype = sleet.getText();
}
if (hail.isSelected()){
temptype = hail.getText();
}
if (mixed.isSelected()){
temptype = mixed.getText();
}
if(temptype.isEmpty() ){
typelabel.setVisible(true);
}
if(tempdate.matches("^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$")) {
ArrayList <Precipclass> list = ListPrecipitation(tempdate,tempttl,temptype);
Object rowdata[] = new Object[3];
for (int i = 0; i < list.size(); i++) {
rowdata[0]=list.get(i).pDate;
rowdata[1]=list.get(i).pType;
rowdata[2]=list.get(i).pTotal;
model.insertRow(i, rowdata);
}
}
}