Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Java Programming 24-Hour Trainer by Yakov Fain
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Java Programming 24-Hour Trainer by Yakov Fain
This is the forum to discuss the Wrox book Java Programming 24-Hour Trainer by Yakov Fain; ISBN: 978-0-470-88964-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Java Programming 24-Hour Trainer by Yakov Fain section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 6th, 2012, 04:32 AM
Authorized User
Points: 61, Level: 1
Points: 61, Level: 1 Points: 61, Level: 1 Points: 61, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Location: Romania
Posts: 18
Thanks: 3
Thanked 1 Time in 1 Post
Question java.awt.Component.getName() in Lesson 11

Hello,

Working on the Try It section from Lesson 11, I am trying to get the name of the button that triggered the mouseClicked() method. I figured I could use java.awt.Component.getName(), like this:

Code:
    public void mouseClicked(MouseEvent e) {
        javax.swing.JButton currentButton = (JButton)e.getComponent();
        System.out.println(currentButton.getName());
        if (currentButton.getText() == ""){
        ....
but the result I get is null.

Would you please help me understand what is going on?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot invoke getName() on the array type File[] fuadlutfi85 JSP Basics 1 July 13th, 2007 04:43 AM
java.awt.event error in swing app. Mr. Monkey Java GUI 2 March 27th, 2007 10:48 AM
AWT / Swings dharmesh_g Java GUI 7 June 30th, 2005 06:11 PM
awt event model help thanasis_gr Java GUI 2 October 20th, 2004 09:10 AM
Images in Frame AWT Window cyrusds_asp Java GUI 1 November 2nd, 2003 09:05 PM



All times are GMT -4. The time now is 10:17 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.