• 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

ActionAdapter

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everyone
any idea how to write this code in difrent way and to have the same result when i click the JButton
Code:
class bbtSave_actionAdapter implements java.awt.event.ActionListener {
AddPersonsData adaptee;

bbtSave_actionAdapter(AddPersonsData adaptee) {
this.adaptee = adaptee;
}
thanks in advance
Greg
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Same effect as... what? You didn't show us the actionPerformed() method, which is the one that gets called when the button is pushed.
 
Greg Davis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sorry about that
here is the code again:

JButton bbtSave = new JButton("Save");
bbtSave.setBackground(Color.RED);
bbtSave.addActionListener(new bbtSave_actionAdapter(this));
panel1.add(bbtSave);
class bbtSave_actionAdapter implements java.awt.event.ActionListener {
AddPersonsData adaptee;

bbtSave_actionAdapter(AddPersonsData adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.saveData(e);
}
}
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that's awfully simple, isn't it? Not really any way to rewrite the actionPerformed method, of course.

What's your motivation for changing this? Simple or shorter code? You could use an anonymous class like this:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic