Derived from JApplet, my init() method has the following:
Container content=getContentPane();
display = new JPanel();
controls = new JPanel();
displayPanel = new DataDisplayPanel( this );
displayPanel.setPreferredSize(new Dimension( 840, 712 ));
displayPanel.setBackground( Color.BLACK );
display.add( displayPanel );
content.add( display );
content.add( controls );
DataDisplayPanel is just derived from JPanel, with MouseListener
interfaces overriden. I have embedded the applet tag in a webpage (the
relevant code is '<applet code="IceDisplayApplet.class" width="1000"
height="1000">
</applet>'). Now I know that init() is called, as I have a call to
initialise data before the above calls to initialise
the gui are called, and the data init process works just fine.
But when I try and display the applet using appletviewer, I get
nothing at all. Can anyone suggest why?
One thing I do think of was that I have written all my class
declarations in one file, and when I run the compiler,
these of course get split into different files, Class1.class,
Class2.class etc. I have combined these classes into
a jar file and added this is an archive tag in the above applet code
snippet but it still doesn't work. What am I doing wrong? Someone on
another forum suggested to another poster that a .pack() call was
missing, but I have run JApplets without this call, and they work just
fine.
Best wishes
Paul
It probably is. So this time I will try
working with a code snippet. If my suggestions
do not fix the stated problem, try posting an
SSCCE.
> ...
> Derived from JApplet, my init() method has the following:
>
> Container content=getContentPane();
content.setLayout(new FlowLayout())
>
> display = new JPanel();
> controls = new JPanel();
>
> displayPanel = new DataDisplayPanel( this );
> displayPanel.setPreferredSize(new Dimension( 840, 712 ));
> displayPanel.setBackground( Color.BLACK );
>
> display.add( displayPanel );
>
> content.add( display );
> content.add( controls );
pack()
...
> ... Someone on
> another forum suggested to another poster that a .pack() call was
> missing, but I have run JApplets without this call, and they work just
> fine.
That would largely be by accident.
--
Andrew Thompson
http://pscode.org/
>content.add( display );
> content.add( controls );
you are missing a content.setLayout. Very rarely is the defaut layout
what you want.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
><applet code="IceDisplayApplet.class"
I suggest always putting your classes in a Jar when you write an
Applet and put them all in a real package.
see http://mindprod.com/jgloss/applet.html
>Thanks, it works!
that was the key to making it work?