Allora, ho provato a fare così:
codice:
import javax.swing.JApplet;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
public class ServerApplet extends JApplet
{
private JButton button;
private ExecutorService executor;
public void init()
{
executor = Executors.newFixedThreadPool (1);
button = new JButton ("Start Server");
button.addActionListener
(
new ActionListener()
{
public void actionPerformed (ActionEvent event)
{
executor.execute
(
new Runnable()
{
public void run()
{
Server server = new Server();
server.runServer();
}
}
);
executor.shutdown();
}
}
);
add (button);
}
}
Il frame si apre correttamente e funziona bene, però nello stesso tempo in cui lo apro, vengono lanciate una marea di eccezioni che la finestra del dos non riesce a contenere XD Poi se chiudo il frame e tento di riaprirlo, vengono lanciate altre eccezioni e la nuova finestra non viene più aperta!