try { FileInputStream f = new FileInputStream("Saver.tmp"); ObjectInput s = new ObjectInputStream(f); Button b =(Button)s.readObject(); add(b); } catch (Exception e) { System.out.println(e); }