0

我需要对 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();
    }
...
}
4

1 回答 1

3

您需要创建一个实例Client

JPanel gui = new JPanel(new Client());
于 2012-06-03T22:53:32.403 回答