Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Serialisation not working

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Serialisation not working

    What objects include the com.apple.laf.AquaMenuBarBorder object? i know that JMenuBars do so i can't serialise those.
    I am trying to serialise a class that holds the following variables
    JButtonExt[][] board;
        int extraWidth;
        Turn currentClick = Turn.One;
     
        Player currentPlayer;
        Player[] players;
        String[][] playerInfo;
     
        int numSquares;
        int squaresWide;
        int squaresHigh;
     
        boolean waiting = false;
        boolean useDB;
     
        BoardType boardType;
        GameType gameType;
     
        Dimension gameBoardBounds;

    the JButtonExt class holds strings, booleans, ImageIcon, while the player class holds strings, int, JLabels and JButtonExt. BoardType and GameType are both enums.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Serialisation not working

    How do you know it's not working? Are you getting an error or something?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Member
    Join Date
    Apr 2012
    Posts
    161
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Default Re: Serialisation not working

    Have you implemented the Serializable interface?

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Serialisation not working

    yeah i have implemented the serialisable interface on every class that I. I know that it fails because it tells me that the JMenuBar is not serialisable and stops the code

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Serialisation not working

    Break the problem down....try to serialize each one of those by themselves. I would presume when you do so one will manifest the problem, which you can further diagnose in a similar manner. I presume you are on a mac given the class you mention (eg *Aqua) - are serializing a JFrame anywhere within the code?

  6. #6
    Junior Member
    Join Date
    May 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Serialisation not working

    yeah I've tried that. but i can get all of them to work by themselves. i can get it to work by setting some of them transient and working out which ones actually work but it may work the first time and doing everything exactly the same the next time it won't work. yes i am on a mac and this is the only time i serialise any piece of code.

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Serialisation not working

    Then I recommend posting an SSCCE which will allow someone to reproduce the problem. Somewhere in your code is a non serializable object (probably a JMenuBar), whether directly or indirectly, and based upon what you posted we cannot help find it.

  8. #8
    Junior Member
    Join Date
    May 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Serialisation not working

    its all good. I've found a way to save it using a database. i know its probably not as good but i already has a database in my application and have used sql before

Similar Threads

  1. Working with $
    By whome in forum What's Wrong With My Code?
    Replies: 20
    Last Post: April 11th, 2012, 03:00 PM
  2. [SOLVED] Working on Win 7 and not on XP
    By shaumux in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 4th, 2011, 05:36 PM
  3. Why isn't this working?
    By javapenguin in forum What's Wrong With My Code?
    Replies: 14
    Last Post: January 21st, 2011, 04:08 PM
  4. Cannot seem to get this working
    By OttawaGuy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 28th, 2010, 03:41 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM