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...
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);
posted 19 years ago
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...