This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList error

 
Rob Brew
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.

Getting there slowly but miffied about this:


C:\Users\rob\Documents\TextArea1.java:72: cannot find symbol
symbol : class ListSelectionEvent
location: class TextArea1.ListBoxClick
public void valueChanged(ListSelectionEvent lse) {
^
C:\Users\rob\Documents\TextArea1.java:40: addListSelectionListener(javax.swing.event.ListSelectionListener) in javax.swing.JList cannot be applied to (TextArea1.ListBoxClick)
list.addListSelectionListener(new ListBoxClick());
^
C:\Users\rob\Documents\TextArea1.java:71: TextArea1.ListBoxClick is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
class ListBoxClick implements ActionListener {
^
3 errors

Tool completed with exit code 1


Thanks in advance.

Rob.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12020
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not 100% sure, but I think when you do

import javax.swing.*;

you only get the first level below "javax.swing"

However, the ListSelectionEvent is two levels below:

javax.swing.event.ListSelectionEvent

So I would either explicitly import that, or import this:

import javax.swing.event.*;


note: I have not tried this, it's a somewhat educated guess.
 
Rob Brew
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried what you suggested fred but still get the same error.
 
Dielson Sales
Greenhorn
Posts: 4
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Brew wrote:Tried what you suggested fred but still get the same error.

It must be another error. Could you post the error again, when you try to import everything?
 
Rob Brew
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure.


C:\Users\Rob\Documents\TextArea1.java:41: addListSelectionListener(javax.swing.event.ListSelectionListener) in javax.swing.JList cannot be applied to (TextArea1.ListBoxClick)
list.addListSelectionListener(new ListBoxClick());
^
C:\Users\Rob\Documents\TextArea1.java:72: TextArea1.ListBoxClick is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
class ListBoxClick implements ActionListener {
^
2 errors

Tool completed with exit code 1
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12020
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how is going from 3 errors to 2 errors the same thing?
 
Rob Brew
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Fred, will repost the code.

 
Dielson Sales
Greenhorn
Posts: 4
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think you're getting this error because you're implementing ActionListener in you class ListBoxClick, and the method addListSelectionListener asks for a ListSelectionListener. Both extend EventListener, but they are different.

You should implement ListSelectionListener and override the method valueChanged.
 
Rob Brew
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorted, thanks Dielson
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic