SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2006
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Graphical user interface

    Just looking for a few hints really...

    1.We've been asked to code a visual representation of the solar system - which i've done.

    2.We've been asked to code a gui which ive done the visual part for.

    3. I now need to make the GUI actually add items to my list of planets which will, in real-time, appear on the solar-system.

    The planets are stored as ListElements(a class i've written) and added to a LinkedList(another class i've written). The classes have all the functionality to add, remove, find etc elements and i've tested this fact using a driver file such as

    Code:
    //create the solar system
    SolarSystem mySystem = new SolarSystem(600,600);
    
    //create the list to contain the planets
    LinkedList planetList = new LinkedList();
    
    //create planets
    Planet mercury = new Planet("Mercury", 5, "red", 30, 10, 5);
    ...
    ..
    .
    
    //add the planets to the list
    planetList.add(mercury);
    ...
    ..
    .
    
    //display the system
    while(run)
            {     
                 Planet currentPlanet = (Planet)planetList.returnFirst();
                              
                 while(currentPlanet!=null)
                 {
                     currentPlanet.drawOn(mySystem);
                     currentPlanet = (Planet)currentPlanet.next;
                 }
    
                 mySystem.finishedDrawing();     
            }

    this displays and runs perfectly well.... however I need somehow to use a GUI to insert into this list.


    Hope this is clear.

    Thanks in advance.

  2. #2
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you can add a listener to your Container and then have a dialog popup with a combobox??? Best I can come up with.

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some more detail and clarifications would be helpful.

  4. #4
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use JPanel to paint your model. You need to override paintComponent() method and draw anythig you want inside it.
    Welcome to HighProg.com -- Freelancer's world-wide portal


Bookmarks

Posting Permissions

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