I'm facing problems when changing a variable that is initiallized in the constructor of another object
JFrame:
public class Window extends JFrame {
private String ip = "default";
private String port = "default";
private String nameClient = "default";
// getters and setters, including setPort ...
public void setPort(String port) {
this.port = port;
}
public Window() {
JLabel numPort = new JLabel(port);
numPort.setBounds(149, 77, 46, 14);
add(numPort);
}
}
In the test class:
public class TestWindow {
public static void main(String[] args){
String validate = "1234";
Window tester = new Window();
tester.setPort(validate);
}
}
Sorry for the noob question, but I cant understand why the Jlabel doesnt change here. If needed I can post the whole code (trying to make a chat-like swing app)
Thanks