File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Button" Watch "Button" New topic


josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
import java.awt.*;
import java.awt.event.*;
class btn extends Button implements ActionListener{
public static void main(String s[]){
Frame w = new Frame();

Button b = new Button("ok");

btn bt = new btn();
w.setLayout(new FlowLayout());

public void actionPerformed(ActionEvent e){
once i run the program only when i resize or drag or maximize the window do i get the button .What should i do to get the button the moment i run?
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
It looks like the problem is that you're adding the Button to the Frame after the Frame is made visible - Java doesn't bother redrawing unless you tel it to. The simplest solution is to move setVisible(true) to the end of the constructor.

"I'm not back." - Bill Harding, Twister
subject: Button
It's not a secret anymore!