i have some code that i am trying to recompile and understand, but i have a method that does not compile and i wish to find the good work around. the method is as follows.
private void launchEventPanel(String title) {
EventQueue.invokeLater(new Runnable(title) {
public void run() {
JFrame myFrame = new JFrame();
myFrame.setTitle("Conference Call");
myFrame.setIconImage(CallConference.this.myCore.myPanel.myIconManager.getPromptIcon(CallEMart.class.toString()));
myFrame.getContentPane().add(CallConference.this.myEventPanel, "Center");
myFrame.pack();
myFrame.setVisible(true); } }); }
the second line of the EventQueue.invokeLater does not compile, i get the error “Anonymous class implements interface, cannot have arguments”.
any help and work around is highly appreciated. thanks!
Well, as the message says: java.lang.Runnable is an interface so you cannot pass title to its constructor.
Use:
instead.
Note that title isn’t used anywhere. If you need it inside the Runnable, you need to declare it final: