🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Ops--- Confused btwn actionPerformed and actionAdapter

#147
From: Bruce Houghtron
Date: Sat, 17 May 2008 21:02
69 lines
3289 bytes
"Bruce Houghtron" <bhought@globalserve.net> wrote in message 
news:482f4730$1@newsgroups.borland.com...
>
>> Keep it simple, go into the code under jbInit()  and rewrite it like 
>> this;
>>
>> JButton 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();
>>    }
>> });
>>
>> JButton jButton1 = 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: <482f47d0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <477bab15$1@newsgroups.borland.com> <482f42e9$1@newsgroups.borland.com> <482f4730$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> <482f42e9$1@newsgroups.borland.com> <482f4730$1@newsgroups.borland.com>
Subject: Ops--- Confused btwn actionPerformed and actionAdapter
Date: Sat, 17 May 2008 17:02:11 -0400
Lines: 71
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; Response
NNTP-Posting-Host: 209.90.146.90
Message-ID: <482f47d0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1211058128 209.90.146.90 (17 May 2008 14:02:08 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail