set/get methods in class "hostel_DtRm" (Acronym for date and room). I make it very simple so you get the point.
public class hostel_DtRm {
private String guests;
// Constructor
public hostel_DtRm (){}
// Set guests method
public void setguests(String guests) {
this.guests=guests;
}
//get guest method
public String getguests() {
return guests;
}
Another Class called "LogedInMain", where the set methods from "hostel_DtRm" are populated.
public class LogedInMain {
private hostel_DtRm dtrm;
public LogedInMain(hostel_DtRm dtrm ) {
this.dtrm=dtrm;
initialize();
........
.....
Populating the set and get methods from "hostel_DtRm" class from the "LogedInMain" class
hostel_DtRm dtrm= new hostel_DtRm();
dtrm.setguests(guests.getText());
dtrm.setstartdate(((JTextField)checkin.getDateEditor().getUiComponent()).getText());
dtrm.setenddate(((JTextField)checkout.getDateEditor().getUiComponent()).getText());
"TEST" is the class where I want to manipulate the acquired data.
public class TEST {
private hostel_DtRm dtrm;
public TEST( hostel_DtRm dtrm) {
this.dtrm=dtrm;
initialize();
}
private void initialize() {
JLabel guest = new JLabel(dtrm.getguests());
guest.setForeground(Color.DARK_GRAY);
guest.setBounds(41, 141, 86, 27);
LogedInmain.add(guest);
Instead of acquiring the guest number I get a beautiful "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
What I did wrong?