10 Replies - 1534 Views - Last Post: 08 December 2012 - 11:50 AM Rate Topic: -----

#1 RourkeOkeffe  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 89
  • Joined: 27-October 12

Action listener JOptionPane error

Posted 08 December 2012 - 11:05 AM

Can someone tell me how i can have the showMessageDialog in the catch statement without having a compilation error
addressBar.addActionListener(new ActionListener() {

			// navigate webBrowser to user-entered URL
			public void actionPerformed(ActionEvent event) {

				try {
					URL url = new URL(addressBar.getText());
					webBrowserPane.goToURL(url);
				}

				catch (MalformedURLException urlException) {
					 JOptionPane.showMessageDialog(this, "This is the dialog message" 
				                ,"This is the dialog title", JOptionPane.ERROR_MESSAGE);
				}
			}
		});


Is This A Good Question/Topic? 0
  • +

Replies To: Action listener JOptionPane error

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,991
  • Joined: 20-September 08

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:19 AM

http://technojeeves....free/118-errors
Was This Post Helpful? 0
  • +
  • -

#3 RourkeOkeffe  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 89
  • Joined: 27-October 12

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:22 AM

It says its not appropriate for the signature of action listener.Which can only accept Integers or Strings which doesn't help me any further
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,991
  • Joined: 20-September 08

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:25 AM

http://technojeeves....free/118-errors
Was This Post Helpful? 0
  • +
  • -

#5 RourkeOkeffe  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 89
  • Joined: 27-October 12

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:27 AM

The method showMessageDialog(Component, Object, String, int) in the type JOptionPane is not applicable for the arguments (new ActionListener(){}, String, String, int)

That is the error
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,991
  • Joined: 20-September 08

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:30 AM

Have you got a JFrame somewhere in the same class, or even is the main class a JFrame subclass?
Was This Post Helpful? 0
  • +
  • -

#7 RourkeOkeffe  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 89
  • Joined: 27-October 12

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:33 AM

View Postg00se, on 08 December 2012 - 11:30 AM, said:

Have you got a JFrame somewhere in the same class, or even is the main class a JFrame subclass?

The class extends JToolBar and implments HyperlinkListener
Was This Post Helpful? 0
  • +
  • -

#8 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,991
  • Joined: 20-September 08

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:37 AM

Quote

The class extends JToolBar
What's the name of it?
Was This Post Helpful? 0
  • +
  • -

#9 RourkeOkeffe  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 89
  • Joined: 27-October 12

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:45 AM

Toolbar is the name
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,991
  • Joined: 20-September 08

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:47 AM

Change this to Toolbar.this
Was This Post Helpful? 1
  • +
  • -

#11 RourkeOkeffe  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 89
  • Joined: 27-October 12

Re: Action listener JOptionPane error

Posted 08 December 2012 - 11:50 AM

View Postg00se, on 08 December 2012 - 11:47 AM, said:

Change this to Toolbar.this

Thanks very much dude.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1