Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

getActionListeners() in Java 1.3?  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am WAY puzzled. I'm using 1.3.1, and I am trying to run someone else's code he wrote in 1.2. When I try to compile, I get a "cannot resolve symbol" for the JMenuItem method getActionListeners().
So I went to the 1.3 API, and sure enough, there is no JMenuItem getActionListeners() method. I mean, there isn't any such method inherited from anywhere, either. It's there in 1.2, and it's there in 1.4, inherited from AbstractButton. Not there in 1.3.
What the heck?!? Do I have to install 1.2 or 1.4 to run this program? And what are we supposed to do instead of that method in 1.3?
- SA
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no method getActionListeners in JMenuItem in Java 1.2.
It's inherited from class AbstractButton "since 1.4". That's all there is to it.
Yer bud is a liar! They aren't using Java 1.2.
 
Sylvia Allen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OOOOOOH! You're SO right. I just went and checked 1.2 again. My bud must have upgraded in the middle of the project w/out telling me, is what he must've done. That scum. Thanks, Dirk. Guess I gotta go install 1.4 before I can get any further. What kind of badness is in store for me there, she wonders? I'll go look for that thread elsewhere. Thanks again.
- SA
 
Sylvia Allen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah--so in that case, how WERE you supposed to do something like this in 1.3?
int i; // Counter
JMenuItem origItem; // Item to clone
JMenuItem dupItem; // Duplicate for popup
ActionListener[] listeners; // Listeners for origItem
popupMenu = new JPopupMenu("Menu for Everything");
origItem = saveMenuItem;
dupItem = new JMenuItem(origItem.getText());
listeners = origItem.getActionListeners();
for (i=0; i<listeners.length; ++i)
dupItem.addActionListener(listeners[i]);
popupMenu.add(dupItem);
... etc.
 
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps
getListeners(class.ActionListener)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!