• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JList error

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried what you suggested fred but still get the same error.
 
Greenhorn
Posts: 4
Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So how is going from 3 errors to 2 errors the same thing?
 
Rob Brew
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Fred, will repost the code.

 
Jason Rebeka
Greenhorn
Posts: 4
Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorted, thanks Dielson
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic