• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Displaying status bar in JApplet

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm an absolute beginner to Java and this question may seem trivial, but I tried to solve this problem for the past 3 days and it seems that I'm stuck...
I'm writing a JApplet which displays a few GUI compotnents (JTextField, JLabel) and which is also supposed to display a message in the status bar.

I created all the GUI components objects and attached them to the interface in method init().
In method paint() I used showStatus method to display a message in the satus bar. I also used repaint().
The problem is that when the applet loads it shows only the status bar message - and no interface that I created in init().
Why is that?
I tried puting showStatus in intit() but it gets wiped out by the "Applet started " message.
I also noticed that the repaint() wipes out the GUI components that I created in init(). But if I don't use I can't display the status bar message (but the interface is intact!).
How do I display both the interface and the status bar? Could anyone help me understand this?
TIA...
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i don't think u need the paint and the repaint methods to display anything in the display area.u can do the same using the init().if your status bar information is not being displayed b'coz of the applet started info.,it means u r not using the showStatus() properly.
the showStatus()expects a Strinmg in the arguement.
try this out this might work
String h="hello";
showStatus(h);
 
Agnes Lapka
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karan, thanks for responding.
I'm afraid , that putting showStatus in init() doesn't help - I tried ( I checked the syntax of this method and I did use it correctly). The problem was that the message I displayed in the status bar (in init() ) showed up for a fraction of a second and got wiped out but 'Applet started'.
I had to use paint() and repaint() because I needed to draw on the Applet as well.
Anyway, I resolved this problem thanks to Manfred from the Applets message board.
He suggested that I use super.paint() in paint(). And it works!
Both the interface created in init() and the message in the status bar show up.
The only problem is that the messages I paint on the applet are flickering. I understatnd this is due to the use of repaint(), but I have to use it. I don't know how to get rid of this problem...
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic