M
Madhur Ahuja
Hello
I currently make use of a program which employs both *AWT Buttons* and
*swing JButtons*.
In the *actionPerformed(ActionEvent e)* function of my program
how do I handle events coming from both types of buttons.
Currently I am doing this :
public void actionPerformed(ActionEvent e)
{
JButton obj=null;
Button obj1=null;
try
{
obj=(JButton)e.getSource();
}
catch(Exception ClassCastException)
{
}
try
{
obj1=(Button)e.getSource();
}
catch(Exception ClassCastException)
{
}
if(obj==start) /*start is of type Button*/
{
}
if(obj1==reset) /*reset is of type JButton*/
{
}
This generates ClassCastException everytime I click a button.
But I am sure there must be a way
to avoid this.
--
Winners dont do different things, they do things differently.
Madhur Ahuja
India
Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com
I currently make use of a program which employs both *AWT Buttons* and
*swing JButtons*.
In the *actionPerformed(ActionEvent e)* function of my program
how do I handle events coming from both types of buttons.
Currently I am doing this :
public void actionPerformed(ActionEvent e)
{
JButton obj=null;
Button obj1=null;
try
{
obj=(JButton)e.getSource();
}
catch(Exception ClassCastException)
{
}
try
{
obj1=(Button)e.getSource();
}
catch(Exception ClassCastException)
{
}
if(obj==start) /*start is of type Button*/
{
}
if(obj1==reset) /*reset is of type JButton*/
{
}
This generates ClassCastException everytime I click a button.
But I am sure there must be a way
to avoid this.
--
Winners dont do different things, they do things differently.
Madhur Ahuja
India
Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com