Jump to content

Upload Java program

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Escape

Escape

    Newbie

  • Members
  • Pip
  • 2 posts
Hi guys,

I wrote a pretty simple script in Java that basically draws some stuff using JPanel, and now I would like to put it online for my friend to see. I have a domain set up and everything, but I'm a huge HTML noob =\
I know HTML makes it really easy to upload JApplets by using the applet tag, is there something similar for JPanel?

Otherwise, whats the best way to put my script online?

Thanks a lot!

#2
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
Create a class that extends JApplet and add the JPanel to your JApplet class.

import javax.swing.JApplet;


public class BorderLayoutCentering extends JApplet {

	JPanel the_panel_you_want_to_add;

	public void init() {

		add( the_panel_you_want_to_add );

	}

}

I haven't played with applets in a while, but if you're jpanel class uses other java files, then you'll need to archive them into a .jar file.
After this, create an html file and open it with a text editor.

<applet code="folderInsideJar.TheClassName.class" archive="jarFiles.jar"

	width="900" height="400">

</applet>

The code tag tells us where to find your .class file.
If you're using several .class files then you'll need to archive them and add the jar file name to the archive tag.
If you're not using several.class files you should be able to get away without using a jar archive.

All of this can be found using a google search of "adding applet to web page"

#3
Escape

Escape

    Newbie

  • Members
  • Pip
  • 2 posts
Thanks a lot dude!

The JPanel class is independent, and I'm only using one .class file (as I said, this is a pretty simple script).
Ill try this out asap, thanks again for the swift response!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users