Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Java
  4. Arraylist

Arraylist

Scheduled Pinned Locked Moved Java
helpgame-devsalestutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kyosugi
    wrote on last edited by
    #1

    I am doing a micro video application and am experiencing problems with my arraylist. I have 2 separate frame. One is ListGameFrame and the other ListVideoFrame. When I add new games to the ListGameFrame and selects the ListGame option to view, I will also see my items from the videos section. This is my coding for the ListGameFrame for adding games.

    public void addGamesToList(ArrayList<Item> items)
    {
    // Clear any existing rows from the table
    this.clearDataFromTable();

        // For each game in the arraylist, add a row to table
        for (Item i : items)
        {
            String GameID = i.getItemId();
            String GameName = i.getTitle();
    
    
            String\[\] rowData = {GameID,GameName};
            ((DefaultTableModel)tblGames.getModel()).addRow(rowData);
        }
    }
    

    And this my coding for viewing the list of games via a class call VideoManager.

    private static void readGameObjects()
    {
    // Create an ObjectInputStream to read data (from game file)
    ObjectInputStream in = openObjectInputFile(gameFileName);
    if (in == null) // Nothing to read
    return;

        try {
            Item i = (Item)in.readObject();
    
            // While there are game objects to read...
            while (i != null)
            {
                // Add object to game arraylist
                items.add(i);
                i = (Item)in.readObject();
            }
        } catch (EOFException e) {} // Do nothing if EOF reached
        catch (IOException e)
        {
            System.out.println(e.getMessage());
            e.printStackTrace();
            System.out.println("Error in reading customer file");
    
        } catch (ClassNotFoundException e)
        {
            System.out.println(e.getMessage());
            e.printStackTrace();
            System.out.println("Error in file format: Customer file");
        } finally
        {
            try {
                    // Close the file
                    in.close();
            } catch (IOException e)
            {
                System.out.println(e.getMessage());
                e.printStackTrace();
            }
        }
    }
    

    Sorry for the long codes as I do not know how to simplfy the problem I am facing now. May I know if there is any specific problems in my coding which results the game list to also show the video list?

    R F 2 Replies Last reply
    0
    • K kyosugi

      I am doing a micro video application and am experiencing problems with my arraylist. I have 2 separate frame. One is ListGameFrame and the other ListVideoFrame. When I add new games to the ListGameFrame and selects the ListGame option to view, I will also see my items from the videos section. This is my coding for the ListGameFrame for adding games.

      public void addGamesToList(ArrayList<Item> items)
      {
      // Clear any existing rows from the table
      this.clearDataFromTable();

          // For each game in the arraylist, add a row to table
          for (Item i : items)
          {
              String GameID = i.getItemId();
              String GameName = i.getTitle();
      
      
              String\[\] rowData = {GameID,GameName};
              ((DefaultTableModel)tblGames.getModel()).addRow(rowData);
          }
      }
      

      And this my coding for viewing the list of games via a class call VideoManager.

      private static void readGameObjects()
      {
      // Create an ObjectInputStream to read data (from game file)
      ObjectInputStream in = openObjectInputFile(gameFileName);
      if (in == null) // Nothing to read
      return;

          try {
              Item i = (Item)in.readObject();
      
              // While there are game objects to read...
              while (i != null)
              {
                  // Add object to game arraylist
                  items.add(i);
                  i = (Item)in.readObject();
              }
          } catch (EOFException e) {} // Do nothing if EOF reached
          catch (IOException e)
          {
              System.out.println(e.getMessage());
              e.printStackTrace();
              System.out.println("Error in reading customer file");
      
          } catch (ClassNotFoundException e)
          {
              System.out.println(e.getMessage());
              e.printStackTrace();
              System.out.println("Error in file format: Customer file");
          } finally
          {
              try {
                      // Close the file
                      in.close();
              } catch (IOException e)
              {
                  System.out.println(e.getMessage());
                  e.printStackTrace();
              }
          }
      }
      

      Sorry for the long codes as I do not know how to simplfy the problem I am facing now. May I know if there is any specific problems in my coding which results the game list to also show the video list?

      R Offline
      R Offline
      Rajdeep NET
      wrote on last edited by
      #2

      I dont think anybody's going to help you in that code. You should try Sun Developer's Network (SDN).

      I calculate my days on earth..... approximately 55 years remaining for me to expire ;-)

      F N 2 Replies Last reply
      0
      • K kyosugi

        I am doing a micro video application and am experiencing problems with my arraylist. I have 2 separate frame. One is ListGameFrame and the other ListVideoFrame. When I add new games to the ListGameFrame and selects the ListGame option to view, I will also see my items from the videos section. This is my coding for the ListGameFrame for adding games.

        public void addGamesToList(ArrayList<Item> items)
        {
        // Clear any existing rows from the table
        this.clearDataFromTable();

            // For each game in the arraylist, add a row to table
            for (Item i : items)
            {
                String GameID = i.getItemId();
                String GameName = i.getTitle();
        
        
                String\[\] rowData = {GameID,GameName};
                ((DefaultTableModel)tblGames.getModel()).addRow(rowData);
            }
        }
        

        And this my coding for viewing the list of games via a class call VideoManager.

        private static void readGameObjects()
        {
        // Create an ObjectInputStream to read data (from game file)
        ObjectInputStream in = openObjectInputFile(gameFileName);
        if (in == null) // Nothing to read
        return;

            try {
                Item i = (Item)in.readObject();
        
                // While there are game objects to read...
                while (i != null)
                {
                    // Add object to game arraylist
                    items.add(i);
                    i = (Item)in.readObject();
                }
            } catch (EOFException e) {} // Do nothing if EOF reached
            catch (IOException e)
            {
                System.out.println(e.getMessage());
                e.printStackTrace();
                System.out.println("Error in reading customer file");
        
            } catch (ClassNotFoundException e)
            {
                System.out.println(e.getMessage());
                e.printStackTrace();
                System.out.println("Error in file format: Customer file");
            } finally
            {
                try {
                        // Close the file
                        in.close();
                } catch (IOException e)
                {
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                }
            }
        }
        

        Sorry for the long codes as I do not know how to simplfy the problem I am facing now. May I know if there is any specific problems in my coding which results the game list to also show the video list?

        F Offline
        F Offline
        fly904
        wrote on last edited by
        #3

        In all honesty, there is not a lot of information given here, as I don't exactly know what you are trying to do. Are you simply listing the data and adding/removing from it?

        kyosugi wrote:

        May I know if there is any specific problems in my coding which results the game list to also show the video list?

        Can you clarify what you mean by this please. Do you mean on the UI (ie. mistakenly added to it) or actually in the List variable? In which case, debug your code and have a look at where the List is generated/output and see why it is being added. ps.

        kyosugi wrote:

        try {
        Item i = (Item)in.readObject();

        // While there are game objects to read...
        while (i != null)
        {
        // Add object to game arraylist
        items.add(i);
        i = (Item)in.readObject();
        }
        } catch (EOFException e) {} // Do nothing if EOF reached

        Simplified can be:

        Item i;
        while ((i = (Item)in.readObject()) != null)
        items.add(i);

        If at first you don't succeed, you're not Chuck Norris.

        1 Reply Last reply
        0
        • R Rajdeep NET

          I dont think anybody's going to help you in that code. You should try Sun Developer's Network (SDN).

          I calculate my days on earth..... approximately 55 years remaining for me to expire ;-)

          F Offline
          F Offline
          fly904
          wrote on last edited by
          #4

          What are you playing at? If you don't understand it, because of your abundant lack of knowledge, then don't answer it with pure dribble.

          If at first you don't succeed, you're not Chuck Norris.

          1 Reply Last reply
          0
          • R Rajdeep NET

            I dont think anybody's going to help you in that code. You should try Sun Developer's Network (SDN).

            I calculate my days on earth..... approximately 55 years remaining for me to expire ;-)

            N Offline
            N Offline
            Nagy Vilmos
            wrote on last edited by
            #5

            Rajdeep, You are stupid. Your answers are, at best, wrong and often plain misleading. Please, you obviously have no knowledge of java so don't damage other people's future by poluting their brains with this rubbish. Stop. Desist. Go away.


            Panic, Chaos, Destruction. My work here is done.

            L 1 Reply Last reply
            0
            • N Nagy Vilmos

              Rajdeep, You are stupid. Your answers are, at best, wrong and often plain misleading. Please, you obviously have no knowledge of java so don't damage other people's future by poluting their brains with this rubbish. Stop. Desist. Go away.


              Panic, Chaos, Destruction. My work here is done.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Welcome to the seventh sphere of hell that Rajdeep.Net brings along to whatever forum he trolls. So far he worked his way through VB.Net, C# and C++ forums with his idiocy and most often stupid, deceiving posts which he admitted where malicious with intent to hijack and/or harm other peoples property. His posts should be ignored and disregarded, and marked as abusive as his answers are almost always are incorrect and misleading.

              Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

              modified on Wednesday, July 22, 2009 12:11 PM

              N 1 Reply Last reply
              0
              • L Lost User

                Welcome to the seventh sphere of hell that Rajdeep.Net brings along to whatever forum he trolls. So far he worked his way through VB.Net, C# and C++ forums with his idiocy and most often stupid, deceiving posts which he admitted where malicious with intent to hijack and/or harm other peoples property. His posts should be ignored and disregarded, and marked as abusive as his answers are almost always are incorrect and misleading.

                Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

                modified on Wednesday, July 22, 2009 12:11 PM

                N Offline
                N Offline
                Nagy Vilmos
                wrote on last edited by
                #7

                EliottA wrote:

                his answers almost always are incorrect

                ftfy He has a brain that lad. Keeps it in jat under his desk! :laugh:


                Panic, Chaos, Destruction. My work here is done.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups