• Post Reply Bookmark Topic Watch Topic
  • New Topic

JList:Displaying a set of URL's

 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
I am displaying a set of URL's in a JList in my applet. I want to go to a URL when I click on it. Is it possible to do that by adding a listener to the list. What would I specify in the listening code. This is not necessarily an applet question I guess. Thanks in advance .
 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have to use the URL class.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems more of a GUI question, so to the GUI forum it goes.
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

one way is to use a MouseListener and JList#locationToIndex.

Kai
 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kai. I did use mouselistner and locationtoindex.
I have another problem though. I have certain dynamically inserted items in the JList,those of which I don't want to listen to mouse clicks. So, I removedMouseListener, whenever I inserted that item and addedMouseListner, again when an action was performed. I have a weird problem. It works the first time, but thereafter, though the remove code is being executed ( I checked with print to system.out) , it is not removing the listener for that item. I wonder what is causing the problem.
I can post the code anywhere, if possible and if anyone can help. I am sure there are no logical errors.
Thank you
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!