我需要对 Client 的引用,因为我需要调用 asetWinTitle
来更改当前窗口的标题。如何解决?
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();
}
...
}