Hello,

To get right to the point i would like to ask for some suggestions regarding writing Java
GUI applications.

I have so far only done small GUI or Console applications that consisted of max 2 classes aka. 2 files. But now while back i decided to take on a larger project. I find it difficult to separate Logic and GUI part of the application. I wish to keep my GUI and my Logic separate so i can have some sort of organization. Unless the application is really small in scale i don't like to keep my event listeners all in a same file or class.

Can anyone point out some guides on "how-to" coding Java GUI or give tips on how to keep it all clean.

ehm ...
keep your logic in one package
your gui parts (frames, panels, ...) in another
and your dataobjects in yet another..

what are you having trouble with?

The poster above ^ dont seem to understand you. Well, i used to stick with this method:
1. Create the GUI classes with no program designs.
2. Create the EventHandlers classes and attach it to the GUI classes.
3. Create the Program Designs that contains objects of GUI and EventHandlers, thru there, manipulate your GUI. Done?

Thank you for your contribution autorunman, but I'm quite sure from previous experience and from the actual post that Stultuske understood it perfectly well. His advice is excellent for someone who is looking at a larger project. Starting a larger project with "GUI classes with no program designs" may be your way of doing things, but not one that an experienced large-scale developer would ever suggest.

I have never undertaken a larger project at most for the sake of good looking code i had 3 maybe 4 classes.

Yes, as you said in your first post. But now you are looking for some guidelines for larger projects - and some variant on MVC is a very good guideline. Starting by painting screens then trying to fit the logic (model) to them is the wrong way round. The model represents some part of the real world, and has to be right (match reality and conform to all relevant rules and legislation). The GUI can be anything you (or the user) wants it to be, and you can modify or scrap & replace GUI parts freely. You may also implement more than 1 completely different GUIs (eg desktop Swing vs HTML web server), but the model remains the same.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.