aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 1400
    
    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: 36598
    
  16
Sounds like a Swing-related topic. Moving
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Explicitly throwing events & calling listener methods?
 
Similar Threads
Doubt in ternary operator
Is it possible to enable a button at load time?
why doesn't this code work?
To many Frames
Frame Attack!