Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

call a class from action performed

Posted on 2007-08-01
5
Medium Priority
?
247 Views
Last Modified: 2013-12-29
Simple question. I am new at this and want to learn this part. I know how to call am a inner class I made it outter now. I want to know that when I press a button in a action performed Event what code do i need to add to call it up, it has its own window. It name is StopWatch()
0
Comment
Question by:Drop_of_Rain
  • 4
5 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 19611422
Make your class an ActionListener!

;JOOP!
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
ID: 19611449
Change your class declaration to:
public class Xyz implements ActiomListener
{

now you can say:

  JButton b = new JButton();
     b.addActionListener(this);

Then 'actionPerformed()'
has access to all variables in the class.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 19611473
In the same class you can add Timers to have the same access to public void actionPerformed(ActionEvent a)
{
    Object o = a.getSource();

     if(o == b) // it's the button

And so on ....

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 19611480
OK.
0
 

Author Comment

by:Drop_of_Rain
ID: 19611508
I'm posting another question can you look for it, it comes up from the comment you made in the question.
it's about implements runable and actionListener maybe rewting the class
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question