This is a debug oriented question, but i've been very confused why some of my objects are returning NULL values.
I have a GUI here that takes strings from the text field when a button is clicked,
public class USAdditionalGUI extends javax.swing.JFrame {
public String AreaCode; // declare Strings
public String Exchange;
public String LastFour;
public String State;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// On button click use getText() to collect the strings from the
//`enter code here` fields and store them into the declared strings.
AreaCode = jTextField3.getText();
Exchange = jTextField1.getText();
LastFour = jTextField2.getText();
State = jTextField4.getText();
}
The next class has get methods for each of the String varibles, and here lies the problem, I create an object to the GUI class and try to access the String information but it keeps coming up NULL when I print it out.
public class TRFUSAddressFormatting{
private String State;
private String areacode; // 3 digits
private String digitExchange; // 3
private String lastfour; // 4
USAdditionalGUI usobj = new USAdditionalGUI();
public String getState(){
State = usobj.State;
System.out.println(State); // Why does this print NULL!!?!?!
return State;
}
}
Am I accessing the string correctly?
getState()is called, the button 1 has not been clicked yet, or it has been clicked on another USAdditionalGUI instance.