开发者

Write gui programatically, or using an advanced gui editor (Java Swing)?

开发者 https://www.devze.com 2022-12-22 20:24 出处:网络
I am planning to write a Swing-based application (using Netbeans 6.8). It seems that Netbeans has a very advanced GUI Editor... Still I have my doubts regarding the code generated by it. Additionally

I am planning to write a Swing-based application (using Netbeans 6.8).

It seems that Netbeans has a very advanced GUI Editor... Still I have my doubts regarding the code generated by it. Additionally I don't like the fact the part of the code is locked (still I understand the need).

Has anybody used Netbeans GUI Editor with success ?开发者_运维百科 Does it "scale" ?


Yes, the NetBeans GUI builder is one of the finest around. I was particularly impressed with how well it handles the infamous GridBagLayout.

Borland JBuilder was in my experience the very best round-trip GUI editor; if I remember correctly, it produced code without "locked areas" and would usually continue to work gracefully with GUI code that you had manually tweaked.

Still, I have yet to find a Java Swing GUI editor that doesn't occasionally choke on a complex layout, i.e. enter a state where further editing is no longer feasible and/or requires some backing up or fixing.

Thus, I prefer to hand-code all my GUIs. Heinz Kabutz of JavaSpecialists tells me his GUI editor is vim. However, I admit that most of my other friends and colleagues consider me crazy for doing this.


With the newest versions of Netbeans, you can share projects between Eclipse and Netbeans. So, if you don't like coding in it much, you can use it just for the GUI features and then edit the code in Eclipse. Make sure you create your project in Eclipse first, and then use the importer. They will share the same directory.

http://netbeans.org/kb/docs/java/import-eclipse.html


I have always prefered to write my Swing UIs by hand. I've tried Netbeans but I just didn't trust it to do the right thing for a complex UI (although it was quite awesome for a small simple UI).

I think a lot of us fear writing Swing Layouts by hand because of GridBagLayout. Its not that hard once you've used it a few times. I used to swear by it. However, recently I've moved to a new job and their existing code uses TableLayout instead. Its much simpler and seems just as powerful to me. I've grown to prefer it to GBL. I think you should consider it if you're new to writing Swing.

I'm sorry but I'm not sure about your question of scale.

Best of luck!

Funny side story about JBuilder. My friend who taught me swing taught me to code it by hand, and he always had me put the layout code in a jbinit() method. For several weeks I assumed this was just some code style he used. It was only later I learned that it was an auto-generated method of JBuilder at the time. I didn't need to be using it at all. I was such a n00b :)


I recently (4 weeks ago) switched from eclipse/SWT to Netbeans 6.8/Swing (after being fed up with some plugin licensing issues in Eclipse). I came in cold not being familiar with either Netbeans or Swing and was quickly impressed. I managed to convert 4 years of SWT experience into Swing experience very quickly and now consider Netbeans the best Java GUI editor. Whilst some parts of autogenerated code are read only - this is a good thing. Eclipse allows you to edit the autogenerated code and this can cause major headaches with layouts, alignment and so on if you make a mistake. Netbeans allows you can create custom 'event handling methods' (my terminology only) which gets the autogenerated block to invoke your methodd at particular points in the lifecycle so you can access the 'read only' code whenever you need to.

So stick with NetBeans, its the best Java Swing environment there is.

You do NOT want to code by hand, for any reasonably sized app. Let the GUI do most of the plumbing for you (especially when using the the different layouts - this alone will make you tear your hair out), so you can focus on the service/business logic.


I've used netbeans, WindowsBuilder plugin in eclipse, and resorted to just writing Swing code by hand. I definitely appreciate the fact that netbeans and windows builder write the swing code for you, but I like knowing every inch of the code in my project and know where to go when I want more complex and add details. Having said that I think netbeans is worth a try too but I was a bit nervous of going through the generated java code, whereas if I had written them from scratch, I don't have this worry.

WindowsBuilder plugin for eclipse totally screwed up my eclipse, the content assist became permanently slow, even after removing it. While the Swing Data Binding framework has some learning curve (at least for me because I didn't know it was the same as JFace Data Binding Framework), I had trouble finding documentation for it, and was referred to the JFace wiki....

Overall, you are right, I think you do get to think more about your application logic than writing plumbing code spent on the gui, but if you write them yourself it just gets faster and faster. I also don't like the fact that I need to be dependent on a gui editor to create my application.

0

精彩评论

暂无评论...
验证码 换一张
取 消