> If you are creating an application that is going to be run in an
> applet, do you start out creating a regular application an moving it
> to an applet or just creating it as an applet, beginning to end. Size
> of project is moderat to large. Thanks.
It depends on a lot of things. If my program is only going to be an
Applet, I create it as an Applet. Often if my program can be contained
in a Panel or drawn on a Canvas, I extend that component and can either
add it to an Applet or an application. See the simple example below of
test.java which extends Canvas and draws a blue oval in a yellow
background. The test1.java is an Applet and will display the test
class. test2.java is an application and will also display the test class.
import java.awt.*;
public class test extends Canvas {
public void paint(Graphics g) {
int w = getWidth();
int h = getHeight();
g.setColor(Color.YELLOW);
g.fillRect(0,0,w,h);
g.setColor(Color.BLUE);
g.fillOval(w/4,h/4,w/2,h/2);
}
}
import java.awt.*;
import java.applet.*;
public class test1 extends Applet {
public void init() {
test t = new test();
t.setPreferredSize(new Dimension(400,300));
add(t);
}
}
<html>
<head>
</head>
<body>
<applet code="test1.class" width="640" height="480">
</applet>
</body>
</html>
import java.awt.*;
import java.awt.event.*;
public class test2 {
public static void main(String[] args) {
final Frame f = new Frame("test2");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
test t = new test();
t.setPreferredSize(new Dimension(400,300));
f.add(t,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}
Sometimes you can make a hybrid that is both an Applet and an
application. The following code can be run as an Applet or as an
application. The Applet is a handy component, it extends Container and
Panel and can be used for anything that those components can be used for.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class test3 extends Applet {
public void paint(Graphics g) {
int w = getWidth();
int h = getHeight();
g.setColor(Color.BLUE);
g.fillRect(0,0,w,h);
g.setColor(Color.YELLOW);
g.fillOval(w/4,h/4,w/2,h/2);
}
public static void main(String[] args) {
final Frame f = new Frame("test3");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
test3 t3 = new test3();
t3.setPreferredSize(new Dimension(400,300));
f.add(t3,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}

Signature
Knute Johnson
email s/nospam/linux/
Andrew Thompson - 16 May 2008 02:06 GMT
On May 13, 1:45 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > If you are creating an application that is going to be run in an
> >applet, do you start out creating a regular application an moving it
> > to anappletor just creating it as an applet, beginning to end. Size
> > of project is moderat to large. Thanks.
>
> It depends on a lot of things.
I only had time to glance at what Knute said,
but I think I basically agree with his take
on it.
For trivial things - direct to applet, for
anything beyond that, hybrid.
This project sounds like it should be an hybrid.
Is there a particular reason the app. is not
being launched using webstart? The maintenance
costs of a JWS app. will be lower in the long
run.
--
Andrew T.
PhySci.org
jmDesktop - 16 May 2008 03:25 GMT
> On May 13, 1:45 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
> wrote:
[quoted text clipped - 23 lines]
> Andrew T.
> PhySci.org
Well, I hadn't even heard of webstart until now. My main problem is,
after I figure this part out, is how do I connect my applet (or
webstart?) to the server. it's an internet app, but I need more than
just a servlet, jsp. It's for a game. Thanks.
Arne Vajhøj - 16 May 2008 03:37 GMT
>> On May 13, 1:45 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
>> wrote:
[quoted text clipped - 21 lines]
> webstart?) to the server. it's an internet app, but I need more than
> just a servlet, jsp. It's for a game. Thanks.
Your applet will be allowed to connect to the same server it was
fetched from.
HTTP or plain socket as you want.
Arne
On Mon, 12 May 2008 06:43:23 -0700 (PDT), jmDesktop
<needin4mation@gmail.com> wrote, quoted or indirectly quoted someone
who said :
>If you are creating an application that is going to be run in an
>applet, do you start out creating a regular application an moving it
>to an applet or just creating it as an applet, beginning to end. Size
>of project is moderat to large. Thanks.
start as an Applet. See http://mindprod.com/jgloss/applet.html
for how to turn it into a hybrid.
Most of my Applets are hybrids. See http://mindprod.com/products.html
and all come with source.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
> If you are creating an application that is going to be run in an
> applet, do you start out creating a regular application an moving it
> to an applet or just creating it as an applet, beginning to end. Size
> of project is moderat to large.
For size > small I would find it very tempting to develop and
test classes in app context and then move it into applet context
later.
Arne
Roedy Green - 13 May 2008 11:19 GMT
>For size > small I would find it very tempting to develop and
>test classes in app context and then move it into applet context
>later.
It is easier to debug an application than an Applet. I debug my
hybrids as applications. However, the structure is Applet plus a main
method to let them also behave as applications.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com