Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing - separation between GUI and coding?

I've always worked with web application and that's what I like to do. For my OOP course my professor decided to "impose" me the use of Java. I've always used java to make console application so that's not a problem.

What is the problem? The problem is I've never developed a GUI for desktop application so I was looking for tutorials. I've found some very interesting tutorial but there is something that I can't find there.

Ok, let me explain. As a support framework to write my thesis I've used the Flex 3 version of PureMVC. Flex 3 has something really cool: you can separate your interface structure from your interface "coding". You write the structure in mxml which is an HTML-like language and you can even add style using a CSS-like language. When you add events, you write in a separate class (in AS3) the coding for that event.

Is there something similar for Swing? Or if not Swing is there for Java a GUI library that allows it?

EDIT: Thanks for your answers, I'm still evaluating your solutions.

like image 644
dierre Avatar asked Feb 25 '23 21:02

dierre


2 Answers

You could try something like Swing JavaBuilder. It lets you define your GUI's components and layout in YAML, separating the layout definition from the "code" parts. Have a flick through the docs to see if it sounds like what you're looking for.

(Disclaimer: I've heard of this library and thought it sounds like a good idea, but haven't used it yet since I've always coded Swing "by hand").

like image 153
Ash Avatar answered Mar 07 '23 02:03

Ash


There's nothing exactly like that for Swing that I know of. Java is code, not markup, so it's going to be different from your HTML/CSS/Flex experience.

Swing was conceived in the late 90s; it's unrealistic to expect it to conform with a 2010 notion of the way UIs are to be built.

You can have L&F that can be swapped out, but it's not like CSS.

The closest thing you'll find to Flex in the Java world is JavaFX. I don't think it's setting the world on fire. The adoption rate isn't what its creators would like.

I'd recommend sucking it up for this course and getting through it.

like image 24
duffymo Avatar answered Mar 07 '23 03:03

duffymo