• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to see button in an applet ?

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :
[code]

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

stopflicker=false;
}

after this method i should ideally see the buttons in my applet on the top-centre ..
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Following one of the following sequences should do the trick

Sequence 1:
applet.add(button);
applet.show();

OR

Sequence 2:
applet.show();
applet.add(button);
applet.repaint();

Hope this helps.

Regards,
Mehul K. Sanghvi.
 
Mahesh Bhatt
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic