Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setLocation is acting wierd-may be a refresh problem

807597May 2 2005 — edited May 2 2005
My html page seems to correctly load the java program and set a button at the location (-100,100). I've seen it print there. On the initial run, the button shows just fine. When I lower the applet area so that only the top quarter is showing and the button is also below the screen, I hit the browser refresh/reload button. This is when things go wacky. The button now shows at the top center of the applet defined area. Anybody know what I am lacking to keep the button in its place?

Applet:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>test</TITLE>
<META NAME="GENERATOR" CONTENT="Arachnophilia 3.9">
<META NAME="FORMATTER" CONTENT="Arachnophilia 3.9">

</HEAD>
<BODY BACKGROUND="" BGCOLOR="#e6ebe2" TEXT="#000000" LINK="#0000ff" VLINK="#0000ff" ALINK="#0000ff">
<br><br><br><br><br><br><br><br><br><br><br><br>
<CENTER><applet code="jewelry3custom.class" 
width="750" height="300" >
</applet></CENTER>
</BODY>
</HTML>
Java Program:
/*
 *		Created on Apr 25, 2005 7:16:27 AM
 */


import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

public class jewelry3custom extends Applet
{
Button b1 = new Button("Click Here");
Button b2 = new Button("Click Here2");

public void init()
{
setBackground(Color.white);
}

public void start()
{
setLocation(-100,100);
add(b1);
}

public void paint(Graphics g)
{
}

public void stop()
{
}

public void destroy()
{
}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2005
Added on May 2 2005
2 comments
107 views