Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get the instance of class that includes the component which activats action ev  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class myone extends JFrame
{
mylistener oblistener;
JLabel mylabel;
JButton addbtn;
...
addbtn=new JButton("add");
addbtn.addActionListener(oblistener);
...
}

the above is a main class,how to get the instance of myone that includes the variable addbtn from below?

public class mylistener extends WindowAdapter implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Object ob= e.getSource();
}
。。。
}
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
sam mounda
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
excellent,very thanks!!!
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!