Results 1 to 5 of 5
- 05-10-2012, 03:52 PM #1
JAVA Applet resize to load problem?
Hello everyone,
My problem in the following code is that the modified component only loads when I resize the applet window. When I add the "labelOne" label, it does not appear instantly but only when I resize the output applet. I'm not using the paint() method as I don't need it.
Any help/assistance would be greatly appreciated.
Cheers.
Java Code:// The "ListenerTesting" class. import java.applet.*; import java.awt.event.*; import java.awt.*; public class ListenerTesting extends Applet implements MouseListener { Panel panelOne; Label labelOne; public void init () { setLayout (new GridLayout (3, 3)); panelOne= new Panel (); panelOne.addMouseListener (this); labelOne= new Label ("X"); add (panelOne); } //init method public void mouseClicked (MouseEvent e) { if (e.getComponent () == panelOne) panelOne.add(labelOne); } //mouseClicked method public void mouseEntered (MouseEvent e) { } //mouseEntered method public void mouseExited (MouseEvent e) { } //mouseExited method public void mousePressed (MouseEvent e) { } //mousePressed method public void mouseReleased (MouseEvent e) { } //mouseReleased method public void paint (Graphics g) { } // paint method } // ListenerTesting class
Last edited by Kratos321; 05-11-2012 at 05:47 AM.
- 05-10-2012, 04:14 PM #2
Re: JAVA Applet resize to load problem?
After a container is visible, you can't just add components to it and have it magically work. You have to revalidate the component after you add something to it. Check out the API for useful functions.
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 05-10-2012, 04:55 PM #3
Re: JAVA Applet resize to load problem?
I'm not using the paint() method as I don't need it.If you don't understand my response, don't ignore it, ask a question.
- 05-10-2012, 05:25 PM #4
Re: JAVA Applet resize to load problem?
If you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 05-11-2012, 03:09 AM #5
Similar Threads
-
Settlers of Catan Java Applet won't load
By ragalie in forum Java AppletsReplies: 5Last Post: 02-23-2012, 05:00 PM -
Java Applet Will Not Load.
By PaulMoretti in forum Advanced JavaReplies: 3Last Post: 08-16-2011, 06:19 PM -
hide the java applet load widow from the browser document body
By sagngh8 in forum Java AppletsReplies: 1Last Post: 08-14-2011, 04:07 AM -
Java Security Applet will not load under a specific user.
By MartyF in forum Java AppletsReplies: 0Last Post: 03-31-2008, 05:35 PM
Bookmarks