Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2093

how to add listener to li

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Ray Ma" <ray.ma@THRWHITE.remove-dii-this>
Subject how to add listener to li
Message-ID <1184877904.793570.42730@m37g2000prh.googlegroups.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 39
Date Wed, 27 Apr 2011 15:37:09 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918629 96.60.20.240 (Wed, 27 Apr 2011 10:37:09 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:37:09 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2093

Show key headers only | View raw


  To: comp.lang.java.gui
Hi, there

I have a component class C1 that mainly contains a JTextField and I
hope it can change text value when a button in another component class
C2 is pressed.
If there's no access restriction, I know I can addActionListener to
that button like:

myButton.addActionListener(new ActionListener(){
          public void ActionPerformed(e){
                  String textStr =button.getText() ;
                  myTextField.setText(textStr); //direct access to
myTextField
          }
});

But for security reason, I don't want C1 has direct access to C2's
textField. In stead, I hope to add event listener in C2 for the
textField, so that the textField can get noticed when button press
event occurs. It will then check the button's actionCommand and decide
whether to get the button's text or not.

If I use:
myTextField.addActionListener() it's actually listen to event that
occur on the textField component, not any event occur on other
components.

AbstractButton class has "fireActionPerformed()" method but it's
protected and I don't know how to use.

Is anyone know how to achieve this?

thanks

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread


Thread

how to add listener to li "Ray Ma" <ray.ma@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000

csiph-web