This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Explicitly throwing events & calling listener methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Explicitly throwing events & calling listener methods?" Watch "Explicitly throwing events & calling listener methods?" New topic
Author

Explicitly throwing events & calling listener methods?

ramya narayanan
Ranch Hand

Joined: Oct 06, 2008
Posts: 338
Dear All,
I need a clarification on whether we can manually generate some event & call eventlistener methods.
See in the below program, without clicking the button1 i.e. AnnotationEnabled is it possible to generate ActionEvent & call the actionPerformed(ActionEvent ae) method.



MyBestRegards.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

Its possible, just see the last line of init method.

public void init()
{
text=new JTextField(25);

//pane.setLayout(new FlowLayout());
pane.setLayout(null);
JRadioButton buttonone=new JRadioButton("AnnotationEnabled");
buttonone.setBounds(50,50,200,30); //x,y,width,height
pane.add(buttonone);
buttonone.addActionListener(this);

JRadioButton buttontwo=new JRadioButton("AnnotationDisabled");
buttontwo.setBounds(260,50,200,30);
pane.add(buttontwo);
buttontwo.addActionListener(this);

//add textbox to the container panel
pane.add(text);
text.setBounds(50,90,100,30);
ButtonGroup buttongroup=new ButtonGroup();
buttongroup.add(buttonone);
buttongroup.add(buttontwo);
buttontwo.doClick();

}


Swastik
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38020
    
  22
Sounds like a Swing-related topic. Moving
 
wood burning stoves
 
subject: Explicitly throwing events & calling listener methods?
 
Similar Threads
Frame Attack!
Doubt in ternary operator
Is it possible to enable a button at load time?
To many Frames
why doesn't this code work?