wood burning stoves 2.0
The moose likes Swing / AWT / SWT and the fly likes how to see button in an applet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to see button in an applet ?" Watch "how to see button in an applet ?" New topic

how to see button in an applet ?

Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88
Hi all,
I have an applet in which i call a method from my paint() method to add two buttons, the paint() method transfers control to the method and i get the two buttons on the applet screen but i can see those only if I enlarge the applet screen, otherwise the screen is blank . I am giving the code below :

public void afterQuestions(){
add(reviewbutton); //this is the first button
add(scorebutton); //this is the second button


after this method i should ideally see the buttons in my applet on the top-centre ..

Impossible is I M Possible
Mehul Sanghvi
Ranch Hand

Joined: Feb 04, 2002
Posts: 134

Following one of the following sequences should do the trick

Sequence 1:


Sequence 2:

Hope this helps.

Mehul K. Sanghvi.
Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88
Hi mehul,
Sorry, but that didn't work .I can Still see those buttons if :
1) I double click on the top most part of the window.( as we do to enlarge the window to fit into full screen ).
2) I click the edge of the window and drag the mouse ( as we do to increase the size of a window);
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Mehul's reply has more to do with how to show the applet in the first place, but what you're doing is changing the components contained in an applet that's already on-screen. Whenever you remove and/or add components to a visible container, you have to call validate() on the container -- in this case, the applet. validate() tells the layout manager that you're done making changes, and the layout should be recalculated. The screen will be repainted automatically.

This belongs in our Swing/AWT/SWT forum, so I'm moving it over there for any further discussion.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link: http://aspose.com/file-tools
subject: how to see button in an applet ?
It's not a secret anymore!