🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #145

Re: Confused btwn actionPerformed and actionAdapter

#145
From: Bruce Houghtron
Date: Sat, 17 May 2008 20:41
60 lines
2977 bytes
Keep it simple, go into the code under jbInit()  and rewrite it like this;

JButton2 jButton2 = new JButton();
jButton2.setBackground(Color.pink);
jButton2.setBounds(new Rectangle(100, 188, 85, 32));
jButton2.setFont(new java.awt.Font("Dialog", 1, 14));
jButton2.setText("Cats");
jButton2.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(ActionEvent e) {
    Cats();
    }
});

JButton1 jButton2 = new JButton();
jButton1.setBackground(Color.green);
jButton1.setBounds(new Rectangle(100, 120, 85, 32));
jButton1.setFont(new java.awt.Font("Dialog", 1, 14));
jButton1.setText("Dogs");
jButton1.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(ActionEvent e) {
    Dogs();
    }
});


an
"Daniel " <dantsg@gmail.com> wrote in message 
news:477bab15$1@newsgroups.borland.com...
>
> Dear fellow developers,
>
> When I clicked a component for instance a button, the event handler code 
> as in below appears under Source tab. Could anyone please explain to me 
> how it works and why does the action_Performed method appear two times, 
> once by itself as a method and then another time under a class unknown to 
> me called actionAdapter? All I want to do is just code one event handler 
> that handles all button clicks, like so:
> public void button_actionPerformed(ActionEvent e, Object arg);
> {   ...... etc  }
>
> Here's theh code generated by JBuilder when I double-clicked a button:
> public void jButton10_actionPerformed(ActionEvent e) {
>    }
> }
>
> class Frame2_jButton10_actionAdapter implements ActionListener {
>    private Frame2 adaptee;
>    Frame2_jButton10_actionAdapter(Frame2 adaptee) {
>        this.adaptee = adaptee;
>    }
>
>    public void actionPerformed(ActionEvent e) {
>        adaptee.jButton10_actionPerformed(e);
>    }
> }
>
> Thanks in advance for explaining to me.
>
>
> 
Technical Details
Message-ID: <482f42e9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <477bab15$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,92daee7594067bd5
X-Google-Attributes: gidf74b3,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Bruce Houghtron" <bhought@globalserve.net>
From: "Bruce Houghtron" <bhought@globalserve.net>
Newsgroups: borland.public.jbuilder.java.language
References: <477bab15$1@newsgroups.borland.com>
Subject: Re: Confused btwn actionPerformed and actionAdapter
Date: Sat, 17 May 2008 16:41:16 -0400
Lines: 62
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 209.90.146.90
Message-ID: <482f42e9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1211056873 209.90.146.90 (17 May 2008 13:41:13 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail