Results 1 to 5 of 5
  1. #1
    alacn's Avatar
    alacn is offline Senior Member
    Join Date
    Jun 2010
    Location
    UK. near London
    Posts
    118
    Rep Power
    0

    Default creating dynamic objects?

    Hey im new to java and ive just made my self a GUI with a button.
    When i press the button i want to be able to create a new object, is this possible? (and i'd like to be able to press the button multiple times to create multiple objects)

    If this is possible, how would i be able to reference the object from a different function since the object is created locally in the cmdChangeActionPerformed button event and not globally?

    or am i going about this completely wrong!!!?

    thanks

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    You could define a global List and add your newly created Objects to it.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    alacn's Avatar
    alacn is offline Senior Member
    Join Date
    Jun 2010
    Location
    UK. near London
    Posts
    118
    Rep Power
    0

    Default

    thanks for fast reply and pointing me in right direction guys

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Creating an Array of Objects
    By int80 in forum New To Java
    Replies: 4
    Last Post: 08-09-2011, 12:40 PM
  2. Creating custom objects
    By coltragon in forum New To Java
    Replies: 11
    Last Post: 12-29-2009, 10:50 PM
  3. Creating Array of Objects
    By chathurajeewaka in forum New To Java
    Replies: 4
    Last Post: 12-03-2009, 03:23 PM
  4. Creating an array of objects
    By geowizard in forum New To Java
    Replies: 5
    Last Post: 11-16-2009, 01:25 AM
  5. Creating objects question
    By sergm in forum New To Java
    Replies: 2
    Last Post: 12-27-2007, 04:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •