This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet is not visible. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet is not visible." Watch "Applet is not visible." New topic
Author

Applet is not visible.

Punya Pratap Singh
Ranch Hand

Joined: Nov 23, 2010
Posts: 80
import java.applet.Applet;
import java.awt.Graphics;


public class Test extends Applet {

StringBuffer buffer;

public void init() {
buffer = new StringBuffer();
addItem("initializing... ");
}

public void start() {
addItem("starting... ");
}

public void stop() {
addItem("stopping... ");
}

public void destroy() {
addItem("preparing for unloading...");
}

private void addItem(String newWord) {
System.out.println(newWord);
buffer.append(newWord);
repaint();
}

public void paint(Graphics g) {

g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);


g.drawString(buffer.toString(), 5, 15);
}
}


when I run this applet (Run-as java Applet) from eclipse nothing Appears Why? please Expalin .
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3946
    
  17

Hi Punya,

This thread doesn't really belong in the Threads forum, I don't think. I am moving it to the more appropriate Applet forum.

Also, as I noted in your last thread - please use Code tags to make the code more readable. You can edit your post by pressing the Edit button in the top right corner of the post, and then add the code tags by selecting the code and pressing the Code button at the top of the editor. You can also manually enter the code tags by putting [code] at the start of the code and [\code] at the end.


Steve
Punya Pratap Singh
Ranch Hand

Joined: Nov 23, 2010
Posts: 80
Thanks for your suggestion Steve,I will take care of It for my further Posts ..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

Punya Pratap Singh wrote:Thanks for your suggestion Steve,I will take care of It for my further Posts ..

Why not take care of it for this post? Leaving the code unformatted after Steve's suggestion just implies you don't think it is important.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Looking at your code, it should work fine (as far as it goes.) I don't know about this "Run as applet" option in Eclipse, though -- how does it know the dimensions to use for the applet? Perhaps it's too small, so you're not seeing anything?


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet is not visible.
 
Similar Threads
Help Needed Urgently!!! -- Showing image
Synchronizing Block code
Exception when using setup() in a junit testcase
Phasor applet-some prbs already compiled code written here
Punction Correct (Sentances)