Win a copy of Kotlin in Action this week in the Kotlin 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

 
sam mounda
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();
}
。。。
}
 
Craig Wood
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!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!