L
Lukasz
I wrote this small test applet (ignore combination of applet and
japplet components):
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.*;
import javax.swing.*;
import javax.swing.border.*;
/*
<APPLET CODE="Test.class" WIDTH="980" HEIGHT="500">
</APPLET>
*/
public class Test extends Applet implements ActionListener {
JFrame ramka;
JButton push, back, frame, cancel;
Choice lista;
TextField pole;
JTextField pole2;
public void init() {
setLayout(null);
push = new JButton("Push");
push.addActionListener(this);
push.setBounds(20, 20, 90, 25);
add(push);
back = new JButton("Back");
back.addActionListener(this);
back.setBounds(20, 20, 90, 25);
frame = new JButton("Ramka");
frame.addActionListener(this);
frame.setBounds(20, 60, 90, 25);
cancel = new JButton("Cancel");
cancel.addActionListener(this);
cancel.setBounds(20, 20, 90, 25);
ramka = new JFrame();
ramka.setSize(400,450);
ramka.setLocation(500,200);
ramka.setDefaultLookAndFeelDecorated(true);
ramka.setLayout(null);
pole = new TextField("pole");
pole.setSize(200, 25);
pole.setLocation(10, 50);
pole2 = new JTextField("pole2");
pole2.setSize(200, 25);
pole.setLocation(10, 100);
lista = new Choice();
lista.setLocation(10,240);
lista.setSize(300,20);
lista.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent evt2){
}
}
);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == push) {
removeAll();
repaint();
add(back);
add(frame);
} else if (e.getSource() == back) {
removeAll();
repaint();
add(push);
} else if (e.getSource() == frame) {
ramka.getContentPane().add(cancel);
ramka.getContentPane().add(pole);
ramka.getContentPane().add(pole2);
ramka.getContentPane().add(lista);
ramka.setVisible(true);
} else if (e.getSource() == cancel) {
ramka.setVisible(false);
}
}
}
The problem is that, when this applet is unsigned, and I start it
through this html file:
<HTML>
<HEAD></HEAD>
<BODY>
<CENTER><APPLET ALIGN=Center
CODE="Test.class"
WIDTH="980"
HEIGHT="500"</APPLET></CENTER>
</BODY>
</HTML>
everything works fine and without any problems.
But when I sign it, and put in the html file line ARCHIVE="Test.jar" ,
the applet won't even initiate.
I can go around that by putting:
lista = new Choice();
lista.setLocation(10,240);
lista.setSize(300,20);
lista.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent evt2){
}
}
);
into == frame) { part. Then applet starts, but while pressing frame
button, nothing happens, the JFrame does not show up. I noticed this
problem in some other places in my applet, and problem occures with
Choice lists.
In my opinion an effect of signing an applet should be only releasing
it from sand box, I don't know what to do about it now, to make it work
properly.
Any ideas?
japplet components):
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.*;
import javax.swing.*;
import javax.swing.border.*;
/*
<APPLET CODE="Test.class" WIDTH="980" HEIGHT="500">
</APPLET>
*/
public class Test extends Applet implements ActionListener {
JFrame ramka;
JButton push, back, frame, cancel;
Choice lista;
TextField pole;
JTextField pole2;
public void init() {
setLayout(null);
push = new JButton("Push");
push.addActionListener(this);
push.setBounds(20, 20, 90, 25);
add(push);
back = new JButton("Back");
back.addActionListener(this);
back.setBounds(20, 20, 90, 25);
frame = new JButton("Ramka");
frame.addActionListener(this);
frame.setBounds(20, 60, 90, 25);
cancel = new JButton("Cancel");
cancel.addActionListener(this);
cancel.setBounds(20, 20, 90, 25);
ramka = new JFrame();
ramka.setSize(400,450);
ramka.setLocation(500,200);
ramka.setDefaultLookAndFeelDecorated(true);
ramka.setLayout(null);
pole = new TextField("pole");
pole.setSize(200, 25);
pole.setLocation(10, 50);
pole2 = new JTextField("pole2");
pole2.setSize(200, 25);
pole.setLocation(10, 100);
lista = new Choice();
lista.setLocation(10,240);
lista.setSize(300,20);
lista.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent evt2){
}
}
);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == push) {
removeAll();
repaint();
add(back);
add(frame);
} else if (e.getSource() == back) {
removeAll();
repaint();
add(push);
} else if (e.getSource() == frame) {
ramka.getContentPane().add(cancel);
ramka.getContentPane().add(pole);
ramka.getContentPane().add(pole2);
ramka.getContentPane().add(lista);
ramka.setVisible(true);
} else if (e.getSource() == cancel) {
ramka.setVisible(false);
}
}
}
The problem is that, when this applet is unsigned, and I start it
through this html file:
<HTML>
<HEAD></HEAD>
<BODY>
<CENTER><APPLET ALIGN=Center
CODE="Test.class"
WIDTH="980"
HEIGHT="500"</APPLET></CENTER>
</BODY>
</HTML>
everything works fine and without any problems.
But when I sign it, and put in the html file line ARCHIVE="Test.jar" ,
the applet won't even initiate.
I can go around that by putting:
lista = new Choice();
lista.setLocation(10,240);
lista.setSize(300,20);
lista.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent evt2){
}
}
);
into == frame) { part. Then applet starts, but while pressing frame
button, nothing happens, the JFrame does not show up. I noticed this
problem in some other places in my applet, and problem occures with
Choice lists.
In my opinion an effect of signing an applet should be only releasing
it from sand box, I don't know what to do about it now, to make it work
properly.
Any ideas?