このメソッドはJFrameオブジェクトの内部にあります。そのJFrameオブジェクトをその内部クラスのメソッドの引数としてどのように渡すことができますか? 私のコードは次のとおりです。 コメントは私が行うに興味を持って何かを説明:あなたのメソッドが静的でない場合内部クラスからクラスオブジェクトにアクセス
public void runTime(){ ActionListener action = new ActionListener(){ public void actionPerformed(ActionEvent e){ count++; text.setText(new Integer(count).toString()); while (count==2012){ //I want to pass the frame that holds this rather than null, how it is possible? JOptionPane.showMessageDialog(null, "HelloEnd", "End of World", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("explode.jpg")); break; } } }; tr = new Timer(1000,action); tr.start(); }
可能重複[あなたはJavaで匿名内部クラスから外側のクラスへの参照を取得する方法は?](http://stackoverflow.com/questions/31201/how-do-youを試してみてください-get-a-enclasses-an-an-an-inner-class-from-an-an-inner-class-i) – Riduidel