我已經創建了一個陣列曼一類:使用數組作爲參數來
public main blah blah{ man = man[10]; }
曼具有諸如
Man.name; Man.age; ...
在曼類,存在打開一個新的一個OnClick方法顯示其名稱和年齡的窗口。
public Man(){ Onclick(){ InfoWindow showinfo = new InfoWindow(this.getid()) // If this is Man[2] the id would be 2. }
而且在信息窗口類:
public class InfoWindow extends JFrame{ public InfoWindow(Man selectedMan){ setSize(300, 200); JLabel info = new JLabel(selectedMan.getname()); add(info); info.setVisible(true); } }
基本上,這是想acomplish(顯示在僞代碼),通過一個人[I]成當創建一個窗口類,顯示的信息相關對那個男人。這就是我如何實際執行它,但它不起作用,我敢肯定在某些部分我有一個誤解。
任何幫助?
實際代碼:
***MAN CLASS*** private class MouseListenerHandler extends MouseAdapter { public void mousePressed(MouseEvent e) { InfoWindow manShowInfo = new InfoWindow(this); Not Working. Getting "constructor not defined" unitShowInfo.setVisible(true); } } *InfoWindow class* public class InfoWindow extends JFrame { public InfoWindow(Man selectedMan){ setSize(300, 200); JLabel label = new JLabel(selectedMan.getName()); add(label); label.setVisible(true); } And the Man[] is created in the main class. }
對症狀的描述將有所幫助。它不是在編譯?它拋出一個異常(哪個例外)?它只是在默默地失敗嗎?還有別的嗎? – 2010-04-18 01:47:16