nao sei mais o que fazer to fazendo uma aplicação desktop para um jogo de pedra papel ou tesoura em certa parte fui forçado a tentar serializar um objeto para que seja usado em outra classe , so que nao consigo resolver este problema, postarei os codigos correspondentes ok. Grande abraço a todos.
[color=darkblue][size=18]ERRO GERADO,TANTO PARA O STREAM SERVER QUANTO PARA STREAMCLIENT [/size][/color]
modificando no cliente apenas a linha
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: pepate.beta.StreamClient
[code]04/11/2007 23:35:47 pepate.beta.telaprincipal
SEVERE: null
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: pepate.beta.StreamServer
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at pepate.beta.telaprincipal.(telaprincipal.java:60)
at pepate.beta.conexao.botaoconectarMouseClicked(conexao.java:221)
at pepate.beta.conexao.access$000(conexao.java:15)
at pepate.beta.conexao$1.mouseClicked(conexao.java:59)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:177)
at java.awt.Dialog$1.run(Dialog.java:1039)
at java.awt.Dialog$3.run(Dialog.java:1091)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Dialog.java:1089)
at java.awt.Component.show(Component.java:1419)
at java.awt.Component.setVisible(Component.java:1372)
at java.awt.Window.setVisible(Window.java:801)
at java.awt.Dialog.setVisible(Dialog.java:979)
at pepate.beta.conexao$6.run(conexao.java:242)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.io.NotSerializableException: pepate.beta.StreamServer
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at pepate.beta.conexao.botaoconectarMouseClicked(conexao.java:211)
… 37 more
[/code]
[size=18][color=blue]CLIENT[/color][/size]
package pepate.beta;
import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.io.Serializable;
public class StreamClient
{
public int flag ;
public String jogada;
Socket client = null;
BufferedReader in = null;
PrintWriter out = null;
public String numeroip;
public String opcaocliente;
public String opcaoserver;
public StreamClient()
{
flag = 0 ;
}
public void conectando(String ip)
{
try {
//numeroip = ip;
client = new Socket(ip, 2222);
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintWriter(client.getOutputStream(), true);
} catch (UnknownHostException ex) {
Logger.getLogger(StreamClient.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(StreamClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void fazjogada(String escolha)
{
opcaocliente = escolha;
out.println(escolha);
}
public void lejogada()
{
try {
opcaoserver = in.readLine();
} catch (IOException ex) {
Logger.getLogger(StreamClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
public String daresultado ()
{
if (opcaocliente.equals(opcaoserver))
{
return "empate";
}
if (opcaocliente.equals("pedra") && opcaoserver.equals("papel") )
{
return "servervenceu";
}
if (opcaocliente.equals("papel") && opcaoserver.equals("pedra"))
{
return "clientevenceu";
}
if (opcaocliente.equals("pedra") && opcaoserver.equals("tesoura"))
{
return "clientevenceu";
}
if (opcaocliente.equals("tesoura") && opcaoserver.equals("pedra"))
{
return "servervenceu";
}
if (opcaocliente.equals("pedra") && opcaoserver.equals("tesoura"))
{
return "clientevenceu";
}
if (opcaocliente.equals("tesoura") && opcaoserver.equals("papel"))
{
return "clientevenceu";
}
if (opcaocliente.equals("papel") && opcaoserver.equals("tesoura"))
{
return "servervenceu";
}
else
return "deu velha 0.0";
}
public void desconectar()
{
try
{
out.close();
in.close();
client.close();
}
catch (IOException ex)
{
Logger.getLogger(StreamClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
[size=18][color=blue]SERVER[/color][/size]
package pepate.beta;
import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.io.Serializable;
public class StreamServer
{
static int flag;
static String jogada;
static int opcao;
public String opcaocliente;
public String opcaoserver;
ServerSocket server = null;
Socket clientConn = null;
BufferedReader in = null;
PrintWriter out = null;
public StreamServer()
{
flag = 0;
}
public void conectando()
{
try {
// Cria um server socket (socket() + bind() + listen())
// creates a server socket (socket() + bind() + listen()
server = new ServerSocket(2222);
clientConn = server.accept();
in = new BufferedReader(new InputStreamReader(clientConn.getInputStream()));
out = new PrintWriter(clientConn.getOutputStream(), true);
} catch (IOException ex) {
Logger.getLogger(StreamServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void fazjogada(String escolha)
{
opcaoserver = escolha;
out.println(escolha);
}
public void lejogada()
{
try {
opcaocliente = in.readLine();
} catch (IOException ex) {
Logger.getLogger(StreamServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void desconectar()
{
try {
out.close();
in.close();
server.close();
clientConn.close();
}
catch (IOException ex)
{
Logger.getLogger(StreamServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
public String daresultado ()
{
if (opcaocliente.equals(opcaoserver)) {
return "empate";
}
if (opcaocliente.equals("pedra") && opcaoserver.equals("papel")) {
return "servervenceu";
}
if (opcaocliente.equals("papel") && opcaoserver.equals("pedra")) {
return "clientevenceu";
}
if (opcaocliente.equals("pedra") && opcaoserver.equals("tesoura")) {
return "clientevenceu";
}
if (opcaocliente.equals("tesoura") && opcaoserver.equals("pedra")) {
return "servervenceu";
}
if (opcaocliente.equals("pedra") && opcaoserver.equals("tesoura")) {
return "clientevenceu";
}
if (opcaocliente.equals("tesoura") && opcaoserver.equals("papel")) {
return "clientevenceu";
}
if (opcaocliente.equals("papel") && opcaoserver.equals("tesoura")) {
return "servervenceu";
} else {
return "deu velha 0.0";
}
}
}
// Imprime a mensagem
// prints the message
// if (in.readLine().equals("ok"))
// {
// System.out.println(/*in.readLine()*/"Voce disse ok para mim?");
// }
// e responde
// and replies
// out.println(JOptionPane.showInputDialog("Digite menssagem"));
/* out.close();
in.close();
server.close();
clientConn.close();
*/
// }
[size=18][color=blue]CLASSE AONDE OCORRE CONEXAO,E AONDE TENTO SERIALIZAR[/color][/size]
/*
* conexao.java
*
* Created on 3 de Novembro de 2007, 21:12
*/
package pepate.beta;
import java.io.*;
/**
*
* @author Zer0
*/
public class conexao extends javax.swing.JDialog
{
public int flagbotao = 1;
public int flagjogada1 = 1;
public int flagjogada2 = 1;
public StreamServer novoserver;
public StreamClient novoclient;
/** Creates new form conexao */
public conexao(java.awt.Frame parent, boolean modal)
{
super(parent, modal);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents()
{
grupoderadio = new javax.swing.ButtonGroup();
gifpensando = new javax.swing.JLabel();
botaoconectar = new javax.swing.JToggleButton();
botaocancelar = new javax.swing.JToggleButton();
radiocliente = new javax.swing.JRadioButton();
radioservidor = new javax.swing.JRadioButton();
caixaip = new javax.swing.JTextField();
tituloip = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("conectar");
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
setResizable(false);
gifpensando.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pepate/beta/conectando.gif"))); // NOI18N
botaoconectar.setText("Conectar");
botaoconectar.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
botaoconectarMouseClicked(evt);
}
});
botaoconectar.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botaoconectarActionPerformed(evt);
}
});
botaocancelar.setText("Cancelar");
botaocancelar.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
botaocancelarMouseClicked(evt);
}
});
grupoderadio.add(radiocliente);
radiocliente.setSelected(true);
radiocliente.setText("Cliente");
radiocliente.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
radioclienteclicado(evt);
}
});
grupoderadio.add(radioservidor);
radioservidor.setText("Servidor");
radioservidor.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
radioservidorclicado(evt);
}
});
tituloip.setText("IP SERVIDOR :");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(gifpensando, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(botaoconectar, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(botaocancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(tituloip, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(caixaip, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addComponent(radioservidor)
.addGap(48, 48, 48)
.addComponent(radiocliente, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43)))
.addGap(10, 10, 10))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(radioservidor)
.addComponent(radiocliente, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(gifpensando, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(43, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tituloip)
.addComponent(caixaip, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(botaoconectar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(botaocancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
pack();
}// </editor-fold>
private void botaoconectarActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
}
private void radioclienteclicado(java.awt.event.MouseEvent evt)
{
flagbotao = 1;
caixaip.setEnabled(true);
botaoconectar.setText("Conectar");
caixaip.setText("");
}
private void radioservidorclicado(java.awt.event.MouseEvent evt)
{
flagbotao = 2;
caixaip.setEnabled(false);
botaoconectar.setText("Aguardar");
caixaip.setText("Aguarde Conexao do Cliente");
}
private void botaocancelarMouseClicked(java.awt.event.MouseEvent evt)
{
System.exit(0);
}
private void botaoconectarMouseClicked(java.awt.event.MouseEvent evt)
{
if (flagbotao == 1)
{
novoclient = new StreamClient();
novoclient.conectando(caixaip.getText());
try{
OutputStream dados = new FileOutputStream(new File("dados.dat"));
ObjectOutputStream servclient = new ObjectOutputStream(dados);
servclient.writeObject(novoclient);
dados.close();
}
catch (IOException e)
{
}
}
if (flagbotao == 2)
{
novoserver = new StreamServer();
novoserver.conectando();
try
{
OutputStream dados = new FileOutputStream(new File("dados2.dat"));
ObjectOutputStream servclient = new ObjectOutputStream(dados);
servclient.writeObject(novoserver);
dados.close();
}
catch (IOException e)
{
}
}
this.dispose();
new telaprincipal(null,true,flagbotao).setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
conexao dialog = new conexao(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent e)
{
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JToggleButton botaocancelar;
private javax.swing.JToggleButton botaoconectar;
private javax.swing.JTextField caixaip;
private javax.swing.JLabel gifpensando;
private javax.swing.ButtonGroup grupoderadio;
private javax.swing.JRadioButton radiocliente;
private javax.swing.JRadioButton radioservidor;
private javax.swing.JLabel tituloip;
// End of variables declaration
}
[size=18][color=blue]CLASSE PRINCIPAL DO JOGO AONDE DESERIALIZARIA O OBJETO E USARIA PARA SETAR AS OPÇOES[/color][/size]
/*
* telaprincipal.java
*
* Created on 3 de Novembro de 2007, 18:13
*/
package pepate.beta;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Zer0
*/
public class telaprincipal extends javax.swing.JDialog
{
public StreamServer server;
public StreamClient client;
static int flagtipo = 0;
public int flagbotoes = 0;
/** Creates new form telaprincipal */
public telaprincipal(java.awt.Frame parent, boolean modal,int tipo)
{
super(parent, modal);
flagtipo = tipo;
if (flagtipo == 1)
{
ObjectInputStream servecliente = null;
try {
InputStream dados = new FileInputStream(new File("dados.dat"));
servecliente = new ObjectInputStream(dados);
client = (StreamClient) servecliente.readObject();
dados.close();
} catch (ClassNotFoundException ex) {
Logger.getLogger(telaprincipal.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(telaprincipal.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
servecliente.close();
} catch (IOException ex) {
Logger.getLogger(telaprincipal.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
if (flagtipo == 2)
{
ObjectInputStream servecliente = null;
try {
InputStream dados = new FileInputStream(new File("dados2.dat"));
servecliente = new ObjectInputStream(dados);
server = (StreamServer) servecliente.readObject();
dados.close();
} catch (ClassNotFoundException ex) {
Logger.getLogger(telaprincipal.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(telaprincipal.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
servecliente.close();
} catch (IOException ex) {
Logger.getLogger(telaprincipal.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents()
{
botaopedra = new javax.swing.JToggleButton();
gifpensando = new javax.swing.JLabel();
botaopapel = new javax.swing.JToggleButton();
botaotesoura = new javax.swing.JToggleButton();
tituloescolhaopcao = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("faca sua jogada");
setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
botaopedra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pepate/beta/pedra.jpg"))); // NOI18N
botaopedra.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
botaopedra.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
botaopedraMouseClicked(evt);
}
});
botaopedra.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
botaopedraActionPerformed(evt);
}
});
gifpensando.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pepate/beta/pensando1.gif"))); // NOI18N
botaopapel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pepate/beta/papel.jpg"))); // NOI18N
botaopapel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
botaopapel.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
botaopapelMouseClicked(evt);
}
});
botaotesoura.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pepate/beta/tesoura.jpg"))); // NOI18N
botaotesoura.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
botaotesoura.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent evt)
{
botaotesouraMouseClicked(evt);
}
});
tituloescolhaopcao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pepate/beta/facajogada.gif"))); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(botaopedra, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(111, 111, 111)
.addComponent(botaopapel, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
.addComponent(botaotesoura, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(19, 19, 19))
.addGroup(layout.createSequentialGroup()
.addGap(112, 112, 112)
.addComponent(tituloescolhaopcao, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(164, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(254, 254, 254)
.addComponent(gifpensando, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(253, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(tituloescolhaopcao)
.addGap(18, 18, 18)
.addComponent(gifpensando)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(botaotesoura, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(botaopapel, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(botaopedra, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33))
);
pack();
}// </editor-fold>
private void botaopedraActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
}
private void botaopedraMouseClicked(java.awt.event.MouseEvent evt)
{
if (flagbotoes != 1)
{
if (flagtipo == 1 )
{
client.fazjogada("pedra");
System.out.println("client fez jogada");
client.lejogada();
System.out.println("client leu jogada");
System.out.println("" + client.daresultado());
client.desconectar();
System.out.println("" + "client desconectou");
System.exit(0);
}
if (flagtipo == 2)
{
server.fazjogada("pedra");
System.out.println("server fez jogada");
server.lejogada();
System.out.println("server leu jogada");
System.out.println("" + server.daresultado());
server.desconectar();
System.out.println("" + "server desconectou");
System.exit(0);
}
flagbotoes = 1;
}
}
private void botaopapelMouseClicked(java.awt.event.MouseEvent evt)
{
// TODO add your handling code here:
}
private void botaotesouraMouseClicked(java.awt.event.MouseEvent evt)
{
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
telaprincipal dialog = new telaprincipal(new javax.swing.JFrame(), true, flagtipo);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JToggleButton botaopapel;
private javax.swing.JToggleButton botaopedra;
private javax.swing.JToggleButton botaotesoura;
private javax.swing.JLabel gifpensando;
private javax.swing.JLabel tituloescolhaopcao;
// End of variables declaration
}