-1

So I've made a game in Java, mostly for practice. It works in the command line now, but now I want to implement it in a GUI with Swing. I got some pictures etc. to implement, but that's not relevant now. I also want to implement a mouselistener.

My (basic) question is: how should I do the layout of the classes? I got my game main class, and some subclasses. Should I create a seperate class for the GUI, or should I just implement it in my game main class? Also, where does the mouse listener go?

Sorry for the newbie question, I'm a beginner with GUI's and I want to do it right.

seb
  • 105
  • 1
  • 6
  • Side note: Since this is a new GUI project consider JavaFX instead of Swing. Swing is currently in maintenance mode and Oracle plans JavaFX to be its successor. – Puce Mar 17 '15 at 16:53
  • 1
    Your question is very broad and can best be answered at this stage by referring you to the Swing tutorials, which you can find here: [Swing Info](http://stackoverflow.com/tags/swing/info). In particular, look up the layout manager tutorials and give them a go. Your best bet is to use this site after you've tried to create something. – Hovercraft Full Of Eels Mar 17 '15 at 16:53
  • You may get some ideas form the [_package-private_](http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html) classes in this simple [game](http://stackoverflow.com/a/3072979/230513). – trashgod Mar 17 '15 at 21:11

1 Answers1

-2

You might try to use a Model View Presenter pattern, as described here:

I've been taught not to place most methods in a general "System" class but where do they go instead?

Community
  • 1
  • 1
Emily Crutcher
  • 638
  • 5
  • 10
  • 1
    The OP specifically asks about Swing and you answer that he should use JavaFX. This kind of answers is good for the comments, not for an answer. – Olivier Grégoire Mar 17 '15 at 18:46