0

For my Comp Sci assignment, I have to make a world that has Village objects connected via Roads in a graph data structure.Gnomes, each running their own thread traverse this world from one village to another using the shortest path. This whole thing needs to have a GUI, however.

Basically I need to have a grid with the villages on the intersections. Something like this ( without the numbers):

grid with points
(source: kwiznet.com)

The villages have to be interconnected with roads. If it is not too difficult, roads should be deletable if they are not the only road connecting the village to the rest of the graph. This would be done via clicking.

There must also be an option to add villages by clicking on the graph, and select current villages, deleting them.

Basically:

  • Graph data structure is translated to GUI grid
  • Roads and Villages can be selected
  • Selected items can be deleted
  • Could you please just point me to what I need to research as I am new to GUIs? Such as the best layout manager, in what way to handle action events, how to draw a grid, etc. I just need a brief outline.

    Glorfindel
    • 21,988
    • 13
    • 81
    • 109
    jeanluc
    • 1,608
    • 1
    • 14
    • 28
    • My suggestion is to code your domain model first. Pretend there is no GUI at all and ensure all the basic data structures, use cases and functions are there and unit tested before even attempting to add a GUI on top of it. That way you will ensure your domain logic and GUI programming concerns are well separated. – jewelsea Jul 31 '14 at 21:36

    1 Answers1

    2

    This is a HUGE question, although that's not really your fault. Here goes:

    Read through the Java Swing Tutorial.

    Learn a bit about MVC. Link1 Link2

    Understand that Swing is not thread safe.

    Then:

    The best layout manager for your graph is likely the grid layout.

    Probably you should add a JButton to each node so you can just click on it. JButtons can be made to look like anything so don't be put off by how they look by default.

    Then MOST IMPORTANT: probably you should use a GUI Builder tool of some sort. I recommend NetBeans Matisse if you are new.

    Now you should try all of that, and ask a SPECIFIC QUESTION when you get stuck. Good luck!

    markspace
    • 10,621
    • 3
    • 25
    • 39