//the object to send : import java.io.Serializable; /** * a new session is created on the server * * @author dbrenner * */ public class SessionAddConfirmation extends BombermanPDU implements Serializable { private static final long serialVersionUID = 3933489005749159277L; public SessionAddConfirmation(int senderId, int priority) { super(senderId, priority); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(super.toString()); return sb.toString(); } } // here it is send: public class MainMenuFrame extends JFrame implements ActionListener,KeyListener{ JButton b1=new JButton("connect"); JButton b11=new JButton("do something"); JButton b2=new JButton("exit"); JTextField j1=new JTextField("Strtrinnngg"); Socket MyClient; ObjectOutputStream oos=null; public MainMenuFrame(){ j1.setEnabled(true); addKeyListener(this); this.setTitle("client!"); this.getContentPane(); b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { System.out.println("versuche zu verbinden!"); //connect------------------- try{ MyClient = new Socket("192.168.123.101", 12345); j1.setText("verbunden"); } catch(Exception exception){ System.out.println("verbindung fehlgeschlafen"); } // TODO Auto-generated method stub } }); b2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { System.exit(0); System.out.println("button2 pressed"); // TODO Auto-generated method stub } }); b11.addActionListener(new ActionListener(){ //================================================================================= //================================================================================ //=============================================================================== public void actionPerformed(ActionEvent e) { LevelFieldType typeFieldType=null; LevelField levf=new LevelField(typeFieldType,new Position(0,0)); LinkedList ll=new LinkedList(); LinkedList lp=new LinkedList(); LevelConfiguration levelc=new LevelConfiguration(true,1,1,1,1,1,1,1,1,1,1,1,1); Level level=new Level("andi","heute",levelc,ll,lp); try{ oos=new ObjectOutputStream(MyClient.getOutputStream()); Object ob=new SessionAddRequest(1,1,"testsession",level); oos.writeObject(ob); } catch(IOException exception){ System.out.println(exception); } System.out.println("addrequest gesendet!"); // TODO Auto-generated method stub } }); Panel panel=new Panel(); panel.add(b1); panel.add(b11); panel.add(b2); panel.add(j1); this.add(panel); this.setSize(300,300); this.setVisible(true); } /** * @param args */ public static void main(String[] args) { //MainMenuFrame mmf=new MainMenuFrame(); // TODO Auto-generated method stub MainMenuFrame mMF=new MainMenuFrame(); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub } }