The Java Tutorials' Weblog

pageicon Tuesday Jun 12, 2007

Layout Management: Use an IDE or Code by Hand?

Have you seen this cool video about the frustrations of coding a GridBag layout manager? We on the Swing tutorial team think this is a pretty accurate portrayal of how frustrating hand-coding a GUI can be, which is why in the latest update of the Swing trails we've decide to encourage the use of NetBeans as much as possible, especially where layout management is concerned. So, do you agree with this approach? Have you used NetBeans, or any other IDE, to create GUIs, and if so, what do you think? For any hand-coding purists out there, what arguments do you make for NOT using an IDE? Please let us know your thoughts!

-- Stuart Clements

Comments:

So, do you agree with this approach? Have you used NetBeans, or any other IDE, to create GUIs, and if so, what do you think?
Yes, definitely! Coming from C++ and just started with Java, the reason for choosing Netbeans and not Eclipse was that I like to develop desktop applications and therefor I need to do much GUI Design. And Netbeans was more intuitive to use and Matisse is a great feature!
For any hand-coding purists out there, what arguments do you make for NOT using an IDE?
I'm not hand-coding layouts, but there are indeed some points where it probably takes more time to use Matisse than doing it by hand. I recently submitted and issue (vote for it! :-) ) on using JSplitPane. It's a pain to layout two nested splitpanes (and even one splitpane alone!) with Netbeans, since you can't change the divider's position. And it's much more work to set an initial layout by using the property inspectors than doing this by hand. Another point is, that when you're new to Netbeans/Java, there might be problems where yo don't know how to solve them, but you probably would have known if you have learnt hand-coding layouts. Again, in my case, I wanted a JPanel function as statusbar with a fixed height, but when I resize my application's frame, the JPanel also vertically resizes, which it actually should <em>not</em>. But, overall, Matisse is absolutely cool, and I'm really looking forward to version 6, where the Swing Application Framework will be introduced. Finally, Java becomes a real great language for desktop applications - finally, although Java was intended to be a desktop-app's language (and not focussing to much on web) from the beginning, if I understood right? ;-)

Posted by Daniel on June 12, 2007 at 10:43 PM PDT #

Hand-coding a GUI is a time consuming task and using a GUI designer saves a lot of trouble. Not long ago I downloaded every GUI designer available and after lots of testing finally got settled with JFormDesigner. Unfortunately JFD is not free, leaving NetBeans/Mattise (IMO) as the best choice for most needs. As long as the tutorial is focused in the principles of creating GUIs helped by a given IDE and not in "using the XXX IDE to create GUIs" there should be nothing against it. However, the tutorial must encourage users to take a look a the generated code because no matter how good your IDE's features are you'll always find something you need to do by hand.

Posted by palmiche on June 13, 2007 at 12:48 AM PDT #

Well to be honest I can hardly believe that you're actually serious in asking the question. As long as there is no standard defined for GUI builders it's just way too much risk to depend upon a tool for your code. Tools come and go, there might be problems with it on your particular platform or you might be constrained by JDK versions or tools that you are allowed to use. There are probably tons of reasons more but for me if I can't code it manually (or if it's really difficult like with layouters) or if I can't properly edit it afterwards (which is basically how it is with GUIs generated by NetBeans) I'm not interested.

12 years ago I was already making reasonably functional GUIs with the few layouters provided by Tcl/Tk so personally I think the Swing team should be ashamed that after so much time they haven't been able to come up with something that's just simple to use and that will work most of the time.

Matisse is really nice, but it just plain sucks for dynamic GUIs where you need to add/remove/change things at runtime (which is also where most (all?) GUI builders fail miserably).

Posted by quintesse on June 13, 2007 at 11:13 AM PDT #

GUI builders can be nice, but I think it's best to learn about the layouts, how they work and how to use them first. It lays a nice foundation before going on to using helper tools.

Posted by anoweb on June 13, 2007 at 12:13 PM PDT #

Well, if you choose to do layout with NetBeans you are locked into that IDE forever and ever. This is because the resource files NetBeans creates are proprietary and the code that Matisse/NetBeans is creating for GroupLayout (the layout manager behind the scenes) is not understandable by a human. The GUI persistence in IDEs need to be standardized and a layout manager that can both be as powerful as GroupLayout and still easy to code for by hand needs to be added to the JDK. MiG Layout can of course be this layout manager (why not go and vote for the RFE to get it into the JDK? http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6530906) There are a lot of things that is still unsolved for Swing on the desktop to really take off.

Posted by Mikael Grev on June 13, 2007 at 12:25 PM PDT #

I have never used a Java IDE to create a GUI. I'm not sure it gives me a benefit over hand-coding, but I could see a new programmer or someone used to them getting benefits from them.

I think I have used GridBag maybe twice in 3+ years. Usually Border, Box, or Grid are enough.

Personally, I feel if you know all the layouts and their nuances then you can see how the layout will work prior to running your code. Eventually, something has to be hand coded, because no GUI creator can handle everything.

The only major problems I have had are with the selective auto-sizing of some layouts. Sometimes it seems that if you resize your window one time it expands one way and then you do the same thing and it does something else.

Posted by anon on June 13, 2007 at 12:26 PM PDT #

Maybe it should say "HTML Syntax Required" instead of "HTML Syntax Allowed" under the comments text box... :)

Posted by Mikael Grev on June 13, 2007 at 12:27 PM PDT #

I think the basic tutorial should show basic layout so that the student has some understanding of why to select an alternative. I have used simple layouts, but also JGoodies and most recently, JFormDesigner.

Developers should not be required to work with Netbeans to learn swing.

Posted by P.Campbell on June 13, 2007 at 01:18 PM PDT #

Regarding the quote "this is a pretty accurate portrayal of how frustrating hand-coding a GUI can be", it should really be:

This is a pretty accurate portrayal of how frustrating hand-coding a GUI can be when using the built-in layout managers, particularly GridBagLayout.

The deficiencies of GridBagLayout are well known: hard to learn, unnecessarily verbose, hard to update layouts, hard to understand layouts, etc. The other built-in layout managers are not advanced enough to create even moderately complex layouts with decent component sizing and re-sizing behavior.

The good news is that hand-coding layouts can be just as easy as using a GUI builder (without any of the drawbacks of GUI builders) provided that you have a decent layout manager. Back in the early days, I had good success using a modified version of TableLayout with Java 1.1 / AWT. I now use JGoodies Forms, which has excellent functionality and ease-of-use. Although I have not tried it, MiG Layout looks like it could be a worthy all-in-one successor to JGoodies Forms.

Posted by Daniel on June 13, 2007 at 02:08 PM PDT #

I'm currently the project lead on the Abeille Forms Designer open source project. It is based on Karsten's FromLayout and is a free alternative to the commercial JFormsDesigner product. Check it out athttps://abeille.dev.java.net/ After working with java for years and dealing with LayoutManagers and hand-coding layout related code I now exclusively do all UI related work using Abeille and other UI design tools. I've grown to prefer generating a layout in some artifact such as an .xml file which in turn can simply be loaded at runtime. Using Abeille for example, I can generate a complex UI and then simply load it within a simple "view" such as:
public class ContactViewPanel extends ViewPanel implements ContactViewConstants {
	public ContactViewPanel() {
		super(FORM_CONTACT_VIEW);
		new ContactController(this, new ContactModel());
	}
}
What would formerly could have been potentially several hundred lines of UI related layout code is reduced to a view consisting of ~5 lines of code. Benefits include:
  • Obviously eliminates the need to write layout management code when creating UIs. Consequently, depending on the complexity of a particular UI, the amount of code written can be reduced in some estimates by up to 30-40%. This translates to time "re-acquired" which can in turn be used more effectively to code business specific logic.
  • Since utilizing layout managers such as GridBagLayout can be extremely time consuming and error prone. This design approach eliminates this risk.
  • UI work related to the view becomes trivial and can be performed by someone with little or no background in Swing.
  • If later on screen layout requirements change and usability dictates a different component flow, only the view needs to be changed (using a WYSIWYG designer such as Abeille or JFormsDesigner). No application code need be modified.
Anyone interested in example code feel free to drop me an email. ~Todd

Posted by Todd Viegut on June 13, 2007 at 03:06 PM PDT #

Disagree. Here are some arguments from a hand-coding purist:

First of all, GridBagLayout is not a good example, because afaik it has also been designed with tool support in mind, but nobody was ever able to deliver such a tool.

Second, never tie your project to a particular IDE. Ironically, I thought that the NetBeans people had this lesson already learned, when they redesigned the whole build process around Ant (hobbyists may rely on an IDE to build their project, professionals prefer automated nightly builds, typically on headless machines ;-)

Next: At the time of EJB 1.0, everybody said: "Well, those XML-descriptor files are a pain, but hey, the IDE-guys will give you the tools you need!" We know what happened. JEE 5 is all about making coding simpler and more straightforward. Lesson learned: Improve your architecture to get rid of unnatural artifacts, instead of throwing tool support at the problem.

Last point: On the server-side, the JSF people have quickly realized, that tool support is not the holy grail, although there was plenty of effort (Studio Creator). Quote from the new JSR-314 (JSF 2.0): "The act of writing JSF applications and components by hand will be made much easier by this JSR."

Dear Swing folks, I think you're moving in the wrong direction...

Posted by Karl Peterbauer on June 13, 2007 at 04:46 PM PDT #

In my opinion an IDE like netbeans is essential for creating laying out components efficiently. Having said that though I think the biggest problem with developing a GUI in an IDE like netbeans is that when people come to use one.. they instantly forget all the important techniques for coding that they normally use... Reusability of panels? Nope! everything goes straight into the frame. Actions? Nope! everything goes straight into the frame. etc etc. I think that any tutorial on layout using an IDE should reiterate on key design points and show how they can be achieved through the IDE interface. For example reusability of panels in Netbeans can be achieved by adding your custom panels to the pallete manager and then dragging them onto forms like any other component.

Posted by Shanon on June 13, 2007 at 05:08 PM PDT #

Neither, I store the configuration in the database and generate the UI dynamically with no hand coding. JGoodies does the hard lifting.

Posted by Aron on June 13, 2007 at 05:37 PM PDT #

I always hand-code for 3 yeas. Sometimes i tried to use IDE,but at the end,I give up.Netbeans gui builder looks good,but the .form file is boring,and can not synornized with .java file.

Posted by nile black on June 13, 2007 at 06:39 PM PDT #

I think that Matisse is a nice "layout manager" in that I mean that it helps visualize what the ideal layout should be. But, in reality I don't use it that often due to the fact that using some of the feature is hard to figure out and if I don't like the generated code I can't edit it. I guess this is because I come from a C/C++ background and am use to hand coding the GUI. As far as Sun's stand is concerned, I think that this is a lousy stand to take! Its like they have become to lazy to help those that are new to the language.

Posted by Adam on June 13, 2007 at 06:41 PM PDT #

I've been coding Swing applications by hand all the way. It's not like I like doing it the hard way but the sad fact is that no GUI builder met my needs so far. They seem to generate too much useless code.

Posted by Chinh Nguyen on June 13, 2007 at 07:26 PM PDT #

I always use hand-written layouts. jgoodies is extreemely for most scenarios. Also, I'd like to suggest not tying up java tutorial with netbeans. Its one of the things I hate, in my most beloved tutorial.

Posted by Viswanath on June 13, 2007 at 07:39 PM PDT #

While I use and recommend NetBeans, I think the Swing tutorial shouldn't focus on a specific IDE. Moreover, I believe it's important that people who are just starting to create GUI's in Java should have a solid grasp of how layout managers work, and the best way to achieve that is by writing some GUI's by hand. So, my take is that it is OK for the tutorial to suggest using NetBeans, but the examples themselves shouldn't require NetBeans.

I've been doing desktop apps for the last 11 years, and I started coding in Java 2 years ago. I'm used to creating GUI's both by hand and with visual designers, but I much prefer the visual way. The NetBeans GUI Builder, Matisse, is awesome, and was the main reason for my switching to NetBeans. My first Java IDE was JBuilder, and the GUI builder was only passable. If you had a good idea of how you wanted your form to look like, and did everything right right from the start, it was OK. However, if you wanted to change something in the overall layout, you'd have a hard time putting everything in its proper place. Then I tried Eclipse, coding my GUI's by hand, but that was plain unproductive. Next I tried NetBeans, I've been using it for a year now, and it's been a great experience. I never needed to tweak the code it generates for my forms. (Later I found out that Eclipse users who'd like to try Matisse can use MyEclipse, it works just as fine.)

That said, one of the beautiful things about Java is the great ecosystem it has managed to build around itself, so you generally have several choices to get your work done. If you want to hand-code your GUI, that's OK. If you want to load your GUI from an XML file, that's OK too. If you want to build your GUI visually, using either NetBeans, JFormDesigner, RADi or something else, all of them work great. So, my point is, make it clear in the tutorials that there are several choices, and try not to overemphasize any specific tools. I'm sure people will be able to find out for themselves the solution that best suits them.

Posted by Roger Araújo on June 13, 2007 at 07:57 PM PDT #

I handcode my gui because of readability, reusability and dynamic gui building. I've never seen a gui builder which allows to dynamicaly add a Component. IMHO a gui builder shoud be like the qt-designer. Making an xml-file(which may be can interpreted by other gui builders) then i use a compiler to compile this xml-file to a gui class (there could be more then one compiler may be for c++ and so on, so you design a gui only once and compile it for many languages -yes this is triky because of the Components used but it would be possible) and inherit this gui class in a class where i put all my listener and action stuff in it by extending the gui class. This can be useful when the gui is created another time so nothing happens to my code!

Posted by René Dolezal on June 13, 2007 at 09:02 PM PDT #

I can't believe the bad press that GridBagLayout gets. By following one simple rule, i've obtained excellent results from hand-coding it every time. The rule is this: draw the grid *by hand* first!! By going into it well-prepared, i think hand-coding actually *saves* time for me. Maybe it's because every GUI builder i've ever tried has frustrated the hell out of me. Maybe i just didn't try hard enough. But for me, hand-coding is the most efficient way to get a result that is satisfactory. For the record, i use Eclipse, not NetBeans (i tried it - it felt sluggish even on a Core 2 Duo with 4 GB RAM and a 64-bit Linux server JVM), and i'd rather the Java Tutorial didn't depend upon it.

Posted by Paul Gear on June 13, 2007 at 10:16 PM PDT #

Personally, I am not to keen on the idea of adding IDE specific techniques to the Java tutorial. But yes, GriBag is not much fun to use. If I were going to update the GUI code in the tutorials, I would probably cover some of the much easier to work with third party layout managers out there, for example, JGoodies Forms, and MiGLayout. As far as my personal reasons for still coding GUIs by hand, have a few reasons. I think I actually find it faster to code by hand using a good layout manager, than I do working in a GUI visual designer where I have to drag and drop components using the mouse, size them, edit property text fields, etc. The visual designer breaks my flow I think, where as just writing code maintains my flow. Second, I generally find hand written code easier to maintain, since I am much more familiar with the code than if it is magically written by a GUI visual designer. It's also easier to debug IMHO. Since although Matisse for example, scores great on rapidly mocking up a GUI. It doesn't score nearly so well on the human readability scale. And finally, yes, I'm sure some of it is just because hand coding is what I know and am familiar with. Until relatively recently most GUI visual designers seemed to be quite buggy. Combine that with the fact that you still had to coerce components into layout managers anyway, it was just easier to do it by hand. Yes, Matisse changes that. But again, at the expense of human readability of code.

Posted by Mike Urban on June 14, 2007 at 01:24 AM PDT #

Definitely don't focus on UI tools, let UI tool developers and their tutorials do that for you.

Instead focus on creating a powerful yet simple to use layout! Current layout managers are powerful but often way too complex to code. Focus on how a UI designer wants to create a UI and try to hide implementation details to deal with platform independency as much as possible. When creating a UI you don't think in grids, flows, let alone in springs as in springlayout, nor indents, nor gaps):
1) You simply want to place components on a certain position (just as you do in a RAD tool wit DnD);
2) For components you want to specify stretch: horizontal and/or vertical
3) Provide an advanced option to place components "aligntop", "alignbottom", for instance for a toolbar or statusbar.

When a component resizes components to the right or bottom should move accordingly (to some most-logical rule, if you want something different use the powerful yet complex existing layouts).

And while we are at it, it would really be nice if we could just specify a "taborder" property for components to determine the order in which components are tabbed instead of having it dependent on add order or writing a ContainerOrderFocusTraversalPolicy

kind regards,
Christiaan

Posted by Christiaan on June 14, 2007 at 02:18 AM PDT #

I'm not touching IDE layout until it can produce readable and maintanable code. There are layout managers that can satify our needs for different situations. IDE solves just one or few concerns, so why would I constrain my self on using it ? I use gridbag layout but with a little bit extended GridbagContraint class to make code shorter an readable. As said prevoiusly in another post: Start by drawing the grid and a lot of frustration just dissapears...
Understandig the code you write is the best way to less frustration, IDE layout is only avoiding one problem just to step on another right after it.

Posted by Davor Hrg on June 14, 2007 at 03:00 AM PDT #

In my opinion code by hand is always the best choice (you have the complete control for your code !). But the theory is now applicable with ArithmeticLayoutManager.

Posted by Davide Raccagni on June 14, 2007 at 04:13 AM PDT #

The video about GridBagLayout simply show the guy who does not know how to use this great layout manager. I'm coding GUI for 2 years and I do it by hands. This approach allows to make very complex GUI (with dozens of components per window) which changes dynamically and is customizable by end user. Hand-coding allows code reuse also. Using GUI builder to create the GUI seams to save you some time. But when this GUI needs to be modified you have a real nightmare. Also it is a bad idea to tie the tutorial to particular IDE.

Posted by Andriy Tsykholyas on June 14, 2007 at 05:38 AM PDT #

When I go to the tutorials (or I send someone I am helping to the tutorials) I expect to find information on using the libraries, interfaces, and language features. I definitely do not expect to see "...and then use [insert GUI builder name here] to lay out the UI components." It seems to me that the Java Tutorial should be just that--a Java tutorial. If a portion of the Java language or libraries is difficult for some to use (e.g., GridBagLayout), then it is incumbent on the Java Tutorial to do the best job it can to demystify the subject, not "punt" and point to an IDE tool to cover up the shortcoming. I agree wholeheartedly with the comment above that GUI builder tutorials should be left to the tutorial sections of the documentation sites for those IDEs that provide them. That being said, providing a comment such as "...and if you are not interested in the details, then a GUI designer might be a better choice for you," and then providing one or more references and/or links to those tools is aceptable.

Posted by Robert Burkhead on June 14, 2007 at 06:15 AM PDT #

Yeah we had this argument at my company a few years back. The decision at that time was to use an IDE, namly JBuilder. We totally got screwed though because JBulder2007 is based on Eclipse. And while I really like Eclipse, JBuilder 2007 does not support GUI's made with any prior version. So now we have to support by hand the terrible code that JBuilder generated. When I look at GroupLayout and what Netbeans spits out it just reminds me that this could happen again.

TOOLS ARE DISPOSABLE, CODE IS FOREVER

We need a new layout manager that is easy to code and read, end of story.

Posted by aberrant on June 14, 2007 at 06:36 AM PDT #

not quite understand! i'm just a beginner

Posted by china li on June 14, 2007 at 06:48 AM PDT #

@Andriy:

sure, GridBagLayout is a great layout manager, but it also has its problems. You can see one problem in the Totally GridBag video when he resizes the final version of the dialog and the two text fields become very very small. This is because if there is not enough space to give the text fields the preferred size, then GridBagLayout uses the minimum size (instead of using the available space as JGoodies FormLayout do).

Another weakness is that GridBagLayout does not support gaps between columns and rows. Sure, you can use insets (or empty columns/rows with minimum width/height), but this is IMHO a nightmare.

... Using GUI builder to create the GUI seams to save you some time. ...

Definitely ;)

... But when this GUI needs to be modified you have a real nightmare ...

I don't think so. IMO it may become a nightmare to modify hand-coded GUIs. Particular if it was coded by other people or if it is several years old. You have to read and understand the code before trying to change something. When using a GUI builder, just open the form in the GUI builder and make the necessary change. Takes only minutes ;)

Posted by Karl Tauber on June 14, 2007 at 07:03 AM PDT #

Matisse is a quite good tool but we need change the code like Eclipse Vep or other commercial product (windows builder).I would like switch between design and source view and when I change one I get the update on the other. At moment is an issue that I can't change layout on source view.

Posted by Lorenzo Sicilia on June 14, 2007 at 07:32 AM PDT #

I either hand-code my UI's or use JFormDesigner, which is really an awesome product and worth the fee for the productivity it gives you. And frankly, it's a lot of fun to use as well. Plus it works for me whether I use IntelliJ, or just TextPad, or half the team is using Eclipse and the other half IntelliJ.

I am irritated by the repeated attempts by Sun to shove NetBeans in my face. The first example for every technology should be code. Just show me the code. It's icing if you want to show how to do that in an IDE that I don't use (actually, that's marketing -- and I'll treat it as such by ignoring it unless I'm shopping).

I think there is a misperception about tooling, that partly is from looking "over the fence" at Visual Studio marketing materials. Window's author Charles Petzold sums up the truth fantastically in his article Does Visual Studio Rot the Mind?.

Posted by Jason Sando on June 14, 2007 at 07:51 AM PDT #

I always hand-code my GUIs. I never use GridBagLayout. I haven't looked at java GUI-Builders in a couple of years, so my info may be out-of-date, but in the past, they created dialogs that wouldn't resize well. I also have to deal with internationalization which makes the controls bigger. I can't use hard-coded sizes for controls. The GUI-Builders I've looked at require you to still understand the complexities of Swing layout managers if you want it to resize according to what you have in mind. By resize I mean things like: this field can grow in width, but not height, this field should take up as much space as it can after all other controls are at their preferred size (something you'd see in a dialog with a list control and some buttons - you want the list to take as much room as possible). With those restrictions in mind, the GUI-builders are nice, but I still have to know how layout managers work. At that point, I'd rather not tie myself to a specific architecture. In addition, the thing I like most about Swing vs, say, MFC, is that I can see exactly what is going on. Nothing is happening behind my back. This makes it very easy to debug problems . My biggest concern is the layout managers follow rules that are not intuitive and poorly documented. Also, there needs to be a few more basic layout managers for doing common tasks (like a column of controls that makes them all the width of the widest control but uses each control's preferred height).

Posted by Mike on June 14, 2007 at 09:08 AM PDT #

[Trackback] The debate of hand coding your GUI screens versus using a tool has come up again. I suspect that Stuart wasn't expecting quite the volume response that he got. For some of you this is old hat and I suspect...

Posted by Joshua Marinacci's Blog on June 14, 2007 at 10:53 AM PDT #

I vote for a tutorial that is useful independent of the IDE you are using.

Hand-coding a GUI can be frustrating and can be a joy. It depends on many factors: What do you want to achieve? Who designs and who implements? What layout manager do you use? Do you use a layout system on top of the layout managers? Do you want to comply with style guides? With one or many style guides? Do you want a consistent UI? Etc.

You seem to mix two different roles during the UI production: finding a design, and implementing it. I've found when working with teams, that many developers face problems in finding the design. Once they know how a screen shall look like, they can construct it efficiently with a decent layout system by hand, or with a decent visual builder tool.

I personally use builders to be able to benefit from Meta Designs - something you don't find in the available visual builder tools. Think about how you'd design and implement your local bus schedule. Do you use a tool to build every page individually - without any relation to the other bus lines? Likely not. Likely you start with a Meta Design that specifies the abstract layout, the fonts, positions, and some rules for the content. Then you just build the many pages by applying content to your meta design. This way you get well designed and consistent pages at affordable costs.

- Karsten Lentzsch

Posted by Karsten Lentzsch on June 14, 2007 at 11:10 AM PDT #

Knowing the basics enormously helps even if you later use a tool exclusively. Knowing the basics means you can do and fix things the tool-only guy in the next cubicle can't.

There are many other things where knowing the basics in programming really helps. For example how floating point numbers work, or being able to do assembler, being able to use a debugger (instead of brain-dead println). You won't use the knowledge every time, but when push comes to shove and deadline looms, you are glad you have one more trick in the bag instead of having to give a blank stare when the boss comes to your desk.

A note to Mr. Marinacci. Don't you have to fix one of the many age old Swing bugs heroes like you added to Swing? If yes, why are you hanging out here instead of running the debugger?

Posted by Sam on June 14, 2007 at 11:29 AM PDT #

The Java Tutorials should not be IDE specific.

Posted by Neil Weber on June 14, 2007 at 11:35 AM PDT #

The Swing tutorials MUST not be IDE tutorials. Keep it about Swing... you need to know the basics as it is the foundation that the IDE GUI builders will building on anyway.

The comment about the IDE GUI builders falling apart for dynamic GUIs is valid. At that point I usually need to do some rough layout by hand to establish the places where my IDE-designed panels will be dynamically placed.

Posted by SWPalmer on June 14, 2007 at 01:19 PM PDT #

Matisse rocks my lame world. :D

Posted by Rick on June 14, 2007 at 06:24 PM PDT #

We use Resource Bundles to insert all labels etc into our UIs. I haven't seen a GUI builder yet that deals with this for me, but then the last GUI builder I used was in JBuilder 9 or thereabouts. I always hand code now cause it's quicker for me, and I'm big fan of the pencil and paper mock up technique.

Posted by Raj Nagappan on June 14, 2007 at 08:15 PM PDT #

I've coded by hand for many years, and many times couldn't get the right behavior to happen. I've tried all Gui builders at some point, from Visual Cafe to JBuilder, and many have just made things worse. But when using Mattise, and rating it on a scale from one to ten it is in my opinion a 8 or 8.5. Window Builder is is a 8.5 to a 9. Most applications should not be coded by hand anymore. With a great high level framework to bind and build validation, there is no reason to code by hand anymore. demo: http://www.netbeans.org/download/flash/netbeans_6_gui_builder/netbeans_6_gui_builder.html I still don't know why Netbeans needs the .form files though, how come Window Builder can do it without injecting code that you can't touch. Actually the code you can't touch is no big deal when you use a high level framework. But it still kinda of weird.

Posted by Carl on June 14, 2007 at 10:09 PM PDT #

I always hand code GUIs, so far it hasn't been painful. I mainly use BorderLayout and only tried GridBag once without gaining any understanding. I think it is good to see more LayoutManagers emerging, they are the whole point of Swing design.

Posted by Tobega on June 14, 2007 at 11:07 PM PDT #

Obviously I use an IDE, just not a graphic GUI designer, there are still too many drawbacks.

Posted by Tobega on June 14, 2007 at 11:09 PM PDT #

I've never used an IDE to create UI's, and that is my job most of the time. Considering this, I'm not best placed to say which is better having no experience of the other side. I just have one question: How can you create object-orientated UI's with usuable parts in an IDE? I can't see how it is possible, and therefore I don't see any reason to use them other than maybe for prototyping (I use GIMP or PaintShopPro for that atm).

Posted by Kieron Wilkinson on June 14, 2007 at 11:40 PM PDT #

Why don't you just admit that the reason to change the tutorial to use Netbeans rather than leaving the choice to the developer is to push Netbeans rather than to teach the student to code (because that teaching just went out the window when you exchanged writing code for pushing buttons...)?

Posted by JT Wenting on June 14, 2007 at 11:55 PM PDT #

As a novice I was fascinated by the visual builder in VisualAge for Java years ago. I will never go this way again.

As pointed out above you are hooked into a toolkit, spend effort in an area not giving major productivity gains and directs the focus into the wrong direction. For me tabular layouting (Karsten's FormLayout) and a relative layout (RelativeLayout) addresses almost all situations and are reasonable readable.

Not to blame here but I'm eagerly awaiting more productivity gains for my team in having better framework support on top of Swing. JSR-296 or things similar to Eclipse JFace would be very helpful. Having the 80% useful stuff working right out of the box but not hiding the power of Swing below.

Posted by Wolfgang Rostek on June 15, 2007 at 12:33 AM PDT #

As long as you still explain how to do it by hand, it is ok. I know that hand-coding a GUI sucks, but even if you use a GUI editor it is important to know what happens behind the scenes.

Posted by asc on June 15, 2007 at 12:49 AM PDT #

I've developed some complicated GUIs with Swing and with SWT. It is much easier coding by hand. On rare occasions I've used an IDE to provide the initial layout, and get the resizing behaviour etc. correct. I have then tidied up the generated code and continued hand-coding. IDE code is really poor. I've also created incredibly complex and dynamically generated web GUIs in JSF/MyFaces and Facelets, with custom components I developed (such as collapsible panels, master detail views, popups, sets, toolbars etc). There will never be an IDE that allows you to do that!

Posted by Peter Cameron on June 15, 2007 at 01:44 AM PDT #

Check out Qt's Designer for an easy GUI builder. It's logical, much easier (IMO) in my opinion to use than Matisse, and more RAD than not.

Posted by 207.236.24.133 on June 15, 2007 at 07:13 AM PDT #

People who use my software gets chicks !

Just kidding. Build the component in a UI builder or by hand and then remix it like this.

Posted by Jan Erik Paulsen on June 15, 2007 at 09:30 AM PDT #

Try GOLA (GUI Objects Layout Asistant) which is a happy medium between handcoding and visual editing in that the generated code is standalone, editable, and eminently readable and therefore easily maintainable. It can be downloaded for free. It works in conjunction with the open source Pagelayout layout manager.

Posted by varan on June 15, 2007 at 09:54 AM PDT #

Re. the prior comment, the correct link for PageLayout layout manager on Sourceforge is here.

Posted by varan on June 15, 2007 at 11:43 AM PDT #

I just use NetBeans' GUI Builder as an assistant tool, only for a "preview", and finally I'll code by hand. Using a GUI builder speeds up layout, but at the same time you've lost a lot of controls. By the way, Matisse, or rather, GroupLayout has some serious problems. I've been sucked by components with a very very long side for many times.

Posted by Zhao Yi on June 15, 2007 at 11:48 AM PDT #

The video is more a reflection of the producer's ignorance than anything else. A large number of layout managers currently exist outside of the standard Swing distribution that will enable him to handcode the GUI that he wanted to build in a few lines. It's a shame that the video has spawned so much useless discussion rather than examples of using other managers for this problem. Sun distributes its JDK with no dictatorial proclamation that the other better libraries not be used.

Posted by guru on June 16, 2007 at 09:11 AM PDT #

I prefer to teach the code directly before moving to any type of GUI helper. You can't go wrong by knowing what's going on at the level of the code.

Posted by Hanrui on June 17, 2007 at 04:39 AM PDT #

If you are not going to have to maintain the code yourself, you should be hand coding it to the coding standard being applied to the project. There is nothing worse than having to maintain generated code, with the random tags that mean nothing to a developer not familiar with what ever ide was used. I also hate the way they generate the anonymous classes all over the place for each action on every component. To me, an IDE designer is a short cut into GUI development for people who haven't taken the time to fully understand the API behind it. Anyone can drag and drop. We have an interview test for GUI developers where they have to hand code a screen using notepad, the JRE and the API, that's it. It certainly catches out the drag n drop brigade who claim to be GUI developers.

Posted by Locky on June 19, 2007 at 01:17 AM PDT #

As usual, Karsten's post is right on the money:

The tutorial should be useful independent of the IDE you are using.

This means it should provide you with the bits you need to know to be successful in laying out guis. This would include a basic understanding of core layout concepts and layout managers (hey, I still use BorderLayout and Box an amazing amount of the time), an awareness/pointers to the better 3rd party layout managers and tools, as well as optional trails on how to use netbeans/matisse. Ideally it should give the reader an inkling on how to choose the best approach for a given project.

Amy Fowler
recovering GridBagLayout addict :)

Posted by Amy Fowler on June 19, 2007 at 10:47 AM PDT #

I'm still a newbie in Java programming, and have been using NetBeans from the beginning. Anyway, I see no reason not to use an IDE to build a GUI if you manage to understand the fundamentals. Best wishes. Marco Alan

Posted by Marco Alan Rotta on June 19, 2007 at 12:40 PM PDT #

netbeans is cool, but grows a dirt code...... the screen to add personal code dont show the errors in real time, its necessary to compile the class to see errors.....

Posted by maxwell on June 21, 2007 at 11:58 AM PDT #

I think it cruel that you'd even consider forcing newbies to learn the often frustrating process of fighting tools to learn a language. Teach the language independent of NetBeans please. Once they get going, then they can begin the insanity of tool fighting, but at least by then they will understand the architecture of the language well enough it won't burn them out. And here's the obligatory K.I.S.S reminder. K.I.S.S

Posted by korey on June 27, 2007 at 04:51 PM PDT #

I am using FormLayout by handcraft and this works fairly easy as well. Most of the time with combination of Boxlayout. Frankly said, do not have an idea why to use other Layouts, especially when they require some other tools like builders. Reg. tutorials this is a good idea, BUT as long as they are only relying on only one Layout, this makes not much sense. In a tutorial I would expect to have an idea, what could be realized more simply in the one or the other Layout. But as an addict to Formlayout, this wouldn't make much sense - like for any additiction ;)

Posted by LeO on July 03, 2007 at 02:41 PM PDT #

I nth the motion that it's a horrible idea to saddle learners with an IDE in the tutorial. I think you are suffering from the illusion that the IDE itself isn't a significant thing to learn. IDE's always do things behind the scenes that obscure what is actually going on to newbies. If you must include the IDE in a tutorial, please provide a fork... a trail with the IDE, a trail without the IDE.

I also want to nth the sentiment that your statement "We on the Swing tutorial team think this is a pretty accurate portrayal of how frustrating hand-coding a GUI can be" should be a source of shame for the Swing team. The frustration of hand-coding a GUI comes mainly from the terrible layout managers that come with Swing. Even a brief encounter with jGoodies or Mig or XMFormLayout (for AWT unfortunately, based on the ancient Motif XmForm widget... so the Swing team can't say there were no good examples to look at) should embarass you guys back to the drawing board.

Posted by bayesianinitiate on July 07, 2007 at 12:22 PM PDT #

bayesianinitiate: You should try pagelayout. During the current year 2007, among all the layout managers on sourceforge, pagelayout is the one which has been downloaded the most.

Posted by varan on July 08, 2007 at 08:54 PM PDT #

I will learni jbuilder 2007

Posted by kani on March 09, 2008 at 06:53 PM PDT #

Hi Todd,
Can you send me a an example to use forms(jfrm or xml)designed by Abeille Forms Designer in eclipse or netbeans.

Please mail to:kpraok@rediffmail.com

Thanks in advance.

Posted by Rao on April 06, 2009 at 12:10 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« February 2010
SunMonTueWedThuFriSat
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
      
       
Today

Feeds

Search this blog

Links

Weblog menu

Today's referrers

Today's Page Hits: 167