My awt Frame won't show up!!!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   K_Tilghman
Posted On:   Sunday, March 31, 2002 03:05 PM

I am just trying to get a basic frame to show up I am opening the html file on the internet and I see nothing but the gray html box, no frame, no words what am I missing? Here is my html file Here is the java file import java.awt.*; import java.applet.*; public class BasicFrame {br> public static void main(String[] args) { Helloworld world=new Helloworld(); world.setVisible(true); } } class Helloworld extends Frame{ public Helloworld()    More>>


I am just trying to get a basic frame to show up

I am opening the html file on the internet and I see

nothing but the gray html box, no frame, no words

what am I missing?


Here is my html file













Here is the java file

import java.awt.*;

import java.applet.*;


public class BasicFrame

{br>
public static void main(String[] args)

{

Helloworld world=new Helloworld();

world.setVisible(true);

}


}



class Helloworld extends Frame{

public Helloworld()


{

super("hello world");

final int width=100, height=100;

setSize(width,height);

}


public void paint(Graphics g)

{

g.drawString("Hello World",10,50);

}

}

   <<Less

Re: My awt Frame won't show up!!!

Posted By:   Rahi_Parsi  
Posted On:   Sunday, April 28, 2002 02:28 PM

I'm not sure what you're trying to do, so check the following:

(a) If you want your html page to be your frame, then
create an applet instead of a frame and size the page
to fit that applet, for example:


public class BasicApplet extends Applet
{ public void init(){}

public void paint(Graphics g)
{ g.drawString("Hello World",20,20);}

}

Then set your html page size to fit the applet, and
it will look like a regular windows app.

(b) Or if you want to run an applet and a frame, using the
applet from part (a):

class BasicFrame extends Frame
{ public BasicFrame(String title,int w,int h)
{ super(title);
setSize(w,h);
setVisible(true);
}

public void paint(Graphics g)
{ ...}

}

//Inside BasicApplet...
BasicFrame frame;
public void init(){ frame=new BasicFrame("App 1.1",120,100);}
About | Sitemap | Contact