Reputation: 13915
I need to have a reference to the Client because I need to invoke a setWinTitle
to change the title of current window. How to fix it?
public class Client {
public static void main(String[] args){
JPanel gui= startGUI();
...
}
private static JPanel startGUI(){
f = new JFrame();
JPanel gui = new JPanel(this); // error
}
public void setWinTitle(String tite){
f.setTitle(tite);
}
}
public class JPanel extends javax.swing.JPanel {
Client client;
public JPanel(Client cl) {
client= cl;
initComponents();
}
...
}
Upvotes: 0
Views: 627
Reputation: 292415
You need to create an instance of Client
:
JPanel gui = new JPanel(new Client());
Upvotes: 3