Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2012, 04:32 AM
Authorized User
 
Join Date: Feb 2012
Posts: 30
Thanks: 5
Thanked 4 Times in 4 Posts
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?





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.