I've written a series of classes to interperet data from a serial port. This data needs to be displayed on the screen. I am trying to go for straight up eye candy with a refined look.
Swing UI- Easy to program, yields mediocre results
Open GL- Hard to program, yields good results.
Are there any other options?
Give SWT a go, the API is a lot simpler than Swing. Here is a recent question outlining the differences between SWT and Swing.
I'm not aware of any alternatives, but in my opinion it is possible to write beautiful GUI with Swing. Just changing the ugly default look and feel goes a long way. Visual appeal just doesn't seem to be a top priority for most Java coders and therefore you have to make an effort to make anything pretty.
JavaFX maybe? Didn't tried it yet, it obviously offers some eye candy.
You can use NetBeans combined with JOGL (Java bindings for OpenGL) or simply with Java2D.
NetBeans has an easy GUI Builder for Swing applications -- you can make beautiful interfaces (if you get into it), easily change the Look&Feel, etc etc.., and you can use Java2D or JOGL for visualizing your data and embed it in the GUI to display it.
There's a plugin for JOGL for NetBeans so getting started is hassle free.
use html, css, javascript. Much easier to get wizz-bang UI than using Swing or related technologies.
For my projects at work, we have purchased a licence of JFormDesigner.
This is really a great tool that saved us a lot of time.
Writing Swing application by hand can be a real pain and is awful to maintain.
This tool choose the right approach : The model-view-controller.
The GUI builder creates XML files for you that represent the interface. These XML files are loaded at runtime and transformed into Swing objects. The builder also generates Java stubs that you can fill with event handlers.
It also handles Localization and nice layout goodies.
Give it a try.
Related
Are there any advantages to hand-coding your Java Swing GUI rather than using the Netbeans Drag n Drop editor? Maybe such as run-time? It seems to me that the Editor auto-creates quite a bit of extra code but I don't know if that has much impact on the runtime of loading the views. The only reason I'm currently using the editor is because it makes the GUI building quick and simple. But are there things you can do only by hand-coding that isn't possible through the editor?
Also is there a better GUI Framework? I've peeked at Java FX, but I really want the kind of effect that the Github desktop software has. It looks so slick and clean, almost like a webapp. Although I'm sure they did that in C++. It just seems to me like there isn't much for Java when it comes to graphics. One of my friends commented that all Java programs look the same and so far it seems true.
I know there are similar posts, but quite frankly they aren't very recent, such as Write gui programatically, or using an advanced gui editor (Java Swing)? which was posted in 2010 or Learning Java Swing (GUI builder or not?) which was also in 2010. If there's nothing new, sorry to bother you.
Are there any advantages to hand-coding your Java Swing GUI rather than using the Netbeans Drag n Drop editor?
There are lots, but lets start with the obvious...
Doesn't lock you into a single development environment. This means your code is sharable to others who may not be using Netbeans. This is of particular importantance when you are using things like Maven based projects
Encourages you to learn the API. You get a good understanding of how the API actually works and learn plenty of tricks to make fluent and flexible interfaces.
Encourages greater separation of respobsibilty. It's all to easy to simply keep dragging components onto a form, which does nothing for encapsulation or management. By dividing your UI into areas of responsibility it makes it easier to mange the distinct states and relations between your components. It also makes the code generally easier to read, as you don't need to keep discarding content which is not relevant to what you are trying to figure out.
Better extendability. Extending components is not easy at the best of times, but is made next to near impossible with form based components (or at least an order of magnitude more difficult)
Netbeans form editor code is...a mess...
Don't get me wrong, I use the form editor, but I've been hand coding Swing GUI's for ten years before I picked up the form editor. I like the form editor for laying out final screens and tend to use hand coded UIs for every step up to that point, putting the pegs in the hole so to speak.
The short answer is - until you can make a multi-level GUI by hand, stay away from the form designers - IMHO.
I know some people think they make great learning tools, I think the opposite, I think they allow you to develope lazy and bad habits which will affect everything you do into the future.
While the development enviroment shouldn't make a difference, not everyone will want to use Netbeans, best to learn to do without
Also is there a better GUI Framework?
That's rather a matter of opinion. Swing brings a concept of skinning through the use of the look and feel architecture, which provides you with the ability to change the way that components look and feel.
JavaFX provides similar functionality through the use of CSS
Swing is also highly customisable, it's very easy to get into the "paint" level of the components and even generate your own should you want to.
The ability to make a "slick" UI isn't about the toolkit but down to the developer. It's easy to just drop fields and other components onto a container, but it will take a developer with a good understanding of the underlying API and some talent for what actually looks good to make it look "slick".
Pretty doesn't always equal functional. The best UI's are ones you don't have to think about, that don't get in your way and just work. When you've been working with a program for hours, days, weeks, you're not going to be looking at how pretty the UI looks but how well it lets you get what you want done - IMHO
The #1 thing that hand-coding accomplishes that the GUI Builder cannot is: dynamically changing interfaces.
For example:
If you wanted to build a form that involves several JTextFields, but you aren't sure how many there will be when you build your GUI. The program will need to populate the JTextFields dynamically. This is impossible with a GUI Builder.
Also, when you have complex interfaces, the resizing behavior of GroupLayout can be cumbersome and confusing. On the flip side, hand-coded layouts are a lot of work when you are writing a complex interface (but, at least their resize behavior is predictable).
A classic GUI builder should be used for prototyping your GUI. Once you know exactly what you want, you should get rid of it and clean the code (factorize it, document it, ... in short make it simple & readable).
One of my friends commented that all Java programs look the same and so far it seems true.
Not absolutely true: JavaFX look is customizable through css. Swing is also fully customizable through the LAF system or by overriding the paint* methods (more time-consuming I admit).
If you look for something easy without the drawbacks of generated code I recommend you have a look at ReflectionUI: easy appearance customization (and that's not the only benefit):.
I am doing UI design for a group of programmers who are working on building music-related software. I have created .psd files for all of the mockups, graphics, etc.
I was assuming they just needed the (many) images to put into the code, but they want me to use a GUI to spit out the necessary code. (I looked at Antetype, but it just seems so basic compared to my Photoshop mockups.)
My question: Is there a GUI tool that can build VERY UNIQUE designs, and can export the mockups in code using MatLab or Java? -- Or should I just say no and give them the images to use in the code. (we are talking guitar-pedal knobs, EQ sliders, etc.)
Netbeans has a decent swing WYSIWYG editor for Java GUIs that's certainly worth looking into. There's going to be some significant back-end work getting your graphics to look just right if you have particular/complex designs in mind, but that said customizing Java GUI's is much easier than MATLAB. . . I believe eclipse also has plug ins available for this same sort of thing.
Anyways, that is probably the closest you'll get to a nice drag-n-drop interface in Java for GUI design.
JFace is also a pretty spectacular framework that sits atop SWT for building Java GUI's. I would say that it's power lies in how it handles different windows/components, but of course the trade off is that it's more complicated to put together (no WYSIWYG that I know of)
Also consider the Microsoft route, Visual Studio is designed to take the pain out of layout designs in writing Visual Basic/C#/.net applications. If you're a student your university probably has a deal to get you a free copy (mine did) otherwise visual studio express should be free (I think? ...citation needed?)
To create a UI you can use some tools, Netbeans in first .. but i think that is better to create a consistent code using simple layout and component, so doing it by hand (Oracle interesting tutorials). If you aren't a java programmer i suggest you can simply give them your image.
I want to know that what would help me in the long run like what the industry's trend is?
Does everyone uses GUI builder, or is it like that java isnt popularly used for GUI and acts mostly as a background operations language?
please guide me..
IDE may not be enough for designing everything (but it helps lot in development), its always better to learn API and IDE both together.
I would learn Swing, because it is useful to know the general ideas of how it works. As for actually generating GUIs, I would use and IDE builder because it's faster. You may find that it's useful to know how to manually fix up the generated code, so knowing Swing would be useful. Often you want to customize how part of the GUI works, and you would have to use the language directly to do that. The IDE builder can be a useful tool for quickly building most of the GUI.
This is just a comment, I am no expert.
My Recommendation for Java is to learn how to do in swing manually.
However I am recently using the Windows Builder Pro that is included in the latest Eclipse Juno. And it creates the code, so you can go back to direct coding without compromise.
There must be better out there, but for my small and simple apps saves me time.
https://developers.google.com/java-dev-tools/wbpro/userinterface/
It is included in Juno just right click a JFrame type class and select Edit with Windows Builder.
You may use the IDE tool, create the code then see it and enhance or add as you like. But for a starter you can add a Full menu, buttons and several controls in no time while maintaining a single .java file.
I suggest you learn swing because GUI builders functionality is limited. But it is ok to use GUI builder if you are developing simple apps. I prefer coding my own UI
You should definitely go for Swing. Using an IDE may seem easy in the beginning but you have to remember that it is way too restrictive. And if you do end up learning swing you can take the thing to the next level, if you know what I mean. It also depends on whether you like to write code or not because if you don't then naturally swing will not interest you. Here's a tutorial. Hope it helps. :)
If you want to be a professional you'll need to master Swing along with all its nuances such as the LookAndFeel and Layouts. NullLayout was my favorite layout of choice while getting started, but you'll definitely need to learn GridLayout and GridBagLayout as well. Mastering the behavior and listener models will require work, but are a must for any mid-level and beyond GUI programmer.
The IDE builders are good for getting it started, but I would be leery of trusting the code that they generate, especially if you have to be personally accountable for it. Even if you must use an IDE WSIWYG you'd better make sure you know what its doing.
They have this very cool drag and drop thing that creates GUI on the fly. But I don't get to learn anything out from this method and I feel guilty about it. Do most of the Java programmers use this method? Because realizing the code it generates, it's quite impractical coding the GUI by hand IMO.
There's nothing wrong with using a GUI builder, as long as you understand what the tool is doing and the implications of using the tool of choice.
The first thing you need to know is what the tool is doing. In this case, you should understand Java Swing and topics such as layout managers, components, concurrency issues that arise when using Swing (this will be handy even when using a tool), event listeners and handlers. Really, you should be able to walk through a simple tutorial, such as this one on Creating a GUI with JFC/Swing. You don't need to be an expert, but you do need to be at least comfortable with reading the generated code and understanding what it does.
The second thing you need to be aware of is the implications of using whatever GUI building tool that you are using. A big implication is that if someone goes to edit the GUI code, they will have to either use your tool or edit the code by hand. If you work in an environment where people are using multiple IDEs and code editors, then someone who uses a different tool then you won't be able to work with your generated code without breaking your ability to use the tool. Most generators lay out their code in a specific manner so that it can be read and processed by the tool - different GUI builders generate different code and won't be able to easily work with each other's code. Also, because of this, editing the code by hand might break the ability of a GUI builder to work with the generated code.
If you understand the tool, what it does, and are willing to accept the risks, go for it. I'm a firm believer in using whatever tools are appropriate to get the job done and that includes GUI builders.
Coding Swing by hand isn't bad at all once you get a grip on layout managers, so it all depends on whether you want to learn Swing. Knowing Swing is far from necessary but it is a pretty well designed bit of code.
I've been told that creating GUI's using drag and drop generates unnecesary code and is frowned upon by most Java developers.
I'm used to dragging and dropping things using Windows Forms **but ** I'm also very comfortable creating things using XAML for WPF applications.
I'm a bit lost however on how to create a basic GUI in Java using only code.
What I'm using: Netbeans 6.8
What I want to do: Create a simple Window that will act as the main one
that opens up when the application
launches.
How can I create a simple Window with the standard window buttons (close, minimize, maximize) and have a little button on the middle of it. Using only code.
Also, what type of project do I create using NetBeans?
Thanks for the help.
I feel like this kind of question is best answered with a link to a tutorial, so here you go:
From java.sun.com, Trail: Creating a GUI With JFC/Swing
The link provided by danben is really helpful. If you really want to lay out everything from scratch, then you have to be able to answer such questions as
What is container? Which components are containers?
How components are positisioned within a container (layout manager)?
The link provided will give you the answer.
I heard that one before. I don't know what is with java developers and always insisting that you have to write the gui by code and can't use drag and drop tools. For me I don't care if it generates unnecessary code. I personally don't think it will make that much of a difference.
The only thing I would never recommend is using a designer for websites since they usually never look the way you designed it when you actually test it on a browser but for windows GUI just use a designer.
I look at it this way. There might be a bit more of unnecessary code but your bosses won't care about that. They will be more concerned why your taking so much longer on something and costing the company so much more money on little to no effect to the final product.
To answer your question you probably can pick up any book from java and they will have tutorials on how to make GUI's by code.
To do it programatically, you have to be able to understand code in general. As far as I know Java does not have a simple XML based layout language for GUI-s. So first you have to learn how to program. (But you can try JavaFX's script language, might be easier to master first.) You can easily learn your way in the simple cases from the generated code, then continue using swing javadoc and google.
GUI builders are handful, nevertheless. It is a plausible that once you are required to mock up a GUI layout as a prototype, tracer bullet, presentation material etc. Generated code might be even completely irrelevant.