[nbusers] Re: editing generated code

  • From: Edson Richter < >
  • To:
  • Subject: [nbusers] Re: editing generated code
  • Date: Fri, 26 Oct 2012 00:07:09 -0200
  • Organization: Simkorp Informática Ltda

I felt your pain in the past, when I wrote very very big Swing application for TMS.
Please, read my humble notes inside...

Em 25/10/2012 20:26, trhouse escreveu:
Hey Javier.

I am under the possibly mistaken impression that the GUI editor screwed up somehow, trashing my GUI. It's not a big deal, it's easily recreated, but when I went to fix it I suddenly understood that I couldn't, as in, it was not permitted. I wondered why. It's gotta be because while NB can produce a legal interface by writing code that's not the same thing as being able to read arbitrary but legal code and produce an interface from it. So part of it was just that- I can't edit it and if it goes south I have to start over.

You can use an external editor. Nevertheless, NetBeans generate the code based in a .form file (XML actually), so you can dig around it.
Few years ago there was a plugin you can use to reverse engieneer .class into .form + .java to recover dialogs and stuff alike.

But really there's more to it than that. First, the GUI builder enforces a style of programming which is orthogonal to what I want to do. Specifically around passing state through the GUI objects themselves. You can argue that you shouldn't pass state through GUI widgets ever MVC and all that, but nevertheless it forces a certain style of modeling and message passing. not everything I write needs a dedicated EventDispatcher pattern t rationalize the propagation of events.

Yes. I used the same. At that time, I was coming from Visual Basic, that encourages bad (but very fast and productive) programming style.

Then there are the weird things, errors it gives me I just can't fathom, such as "(extension of swing widget) X is not a bean". Well, yeah actually, it is a bean, complete with a no arg constructor. Huge Gaps appear out of nowhere and refuse to be moved, resized or deleted and they don't appear in the form hierarchy of the Navigator so i can't get at them there. . Generally, I am finding a disconnect between what is on the screen and how I am permitted to manipulate it, to say nothing of change or fix the code which is not permitted.

This usually happens when your bean throws errors. Since NetBeans "load your class" to put in the GUI designer, all sort of runtime errors would prevent your to use it. Let's say a database you can't access during design time (or you need a JNDI datasource available) and so on.

I would say the GUI tool does work but is also brittle in the sense of if I start with a Frame or Dialog and add components and move them around and then finish I have a series of properly laid out components, but if *something* happens - and who knows why stuff happens- it seems unsalvagable and I find myself have to start over from scratch. That's not so bad, all GUIs are pretty simple if they're any good (arguably) but redoing the message and state passing is No Fun.

Well, what I did: I've configured NetBeans to generate all components as "protected", and then I usually create a Implementation class that extends the panel/dialog. And in the implementation I code the behavior and state. So, if I need to redesign the panel/window, and I can do it without changing the implementation (more or less - if I delete, add or modify components, I need to change the behavior accordingly).

People bash GroupLayout as being overly verbose and hard to read but honestly my experience with it is just the opposite. I feel like it's not only the best and most versatile of all the layouts and also the most rational, most predictable, most amenable to both planning and post-hoc analysis. It has by far the fewest moving parts, none of them are ambiguous in their effects is clearly the most deterministic of all of the grown-up layout managers.

It is a matter of preference. I love GridBagLayout. Works great creating GUI that is fully compatible with Linux and Windows.

I never GUI builders before. This one is the best one I think, but the feeling that I am going to be redoing a lot of work on serious projects if I use it is now haunting me at every step. Better to be able to fix things that go wrong than have to start over, never mind how fast I can prototype stuff .

IMHO, it's at same level as Visual Studio tools, and also as good as Qt Designer.

It's interesting, it is. I would strive to make it 2-way unless that's some kind of known to be impossible achievement. If I were going to change it, I would do that and include more features that make it more of a GroupLayout learning tool, dedicated not just to creating GUIs but also helping the programmer to understand how all that wordy code relates to the GUI. It's really pretty simple. That's for GroupLayout, now for GridbagLayout, it's hopeless because as far as anyone can tell, GridbagLayout is, if not strictly indeterminate, then too complex to predict. It's totally a trial an error process that I for one am glad to be rid of and I was good at it ;)

Well, give a try using the "Extends" aprroach I've described above. Then you can change your layout as you wish.
Since your real code will be in the descending class, you will have no impact regarding the layout manager you want to use.

That's my 2c,

Edson Richter

On 10/25/2012 11:12 AM, Javier Ortiz wrote:
If you want to do stuff not supported from the GUI editor you can't use it. Is there anything in particular that want to do the editor doesn't seem to allow you?

Javier A. Ortiz Bultrón
Senior Software Quality Engineer
ArthroCare Corporation
Office 512.358.5996
7000 West William Cannon Drive
Building One
Austin, Texas 78735

-----Original Message-----
From: trhouse 
[mailto: ]
Sent: Thursday, October 25, 2012 3:25 PM

Subject: [nbusers] editing generated code

Is there some way to edit the generated layout code, some special box to check somewhere which permits it? I can't find anything like this in the menus or help system.

If not, I am curious, what's the rationale for this? I am guessing it's because the GUI editor cannot process arbitrary-yet-legal layouts but rather operates within the confines it's own sort of sub-dialect of the language of GroupLayout. Is that about right or is it an HCI decision somehow.. what's the force driving that decision?

Many thanks!

The information contained in this e-mail message, together with any
attachments thereto, is intended only for the personal and confidential
use of the addressee named above. The message and the attachments
are or may be privileged or protected communication. If you are not the
intended recipient of this message, or authorized to receive it for the
intended recipient, you have received this message in error, and you
are not to review, use, disseminate, distribute or copy this message,
any attachments thereto, or their contents. If you have received this
message in error, please immediately notify us by return e-mail
message, and delete the original message.

Pursuant to Circular 230 issued by the United States Treasury
Department and relating to practice before the Internal Revenue
Services, any comment or opinion in this communication relating to a
federal tax issue is not intended to be used, and cannot be used, by a
taxpayer for the purpose of avoiding tax-related penalties that may be
imposed on the taxpayer.

[nbusers] editing generated code

trhouse 10/25/2012

[nbusers] Re: editing generated code

Javier Ortiz 10/25/2012

[nbusers] Re: editing generated code

trhouse 10/25/2012

[nbusers] Re: editing generated code

Edson Richter 10/26/2012

[nbusers] Re: editing generated code

trhouse 10/26/2012

[nbusers] Re: editing generated code

Edson Richter 10/26/2012

[nbusers] Re: editing generated code

Chuck Davis 10/25/2012

[nbusers] Re: editing generated code

Glenn Holmer 10/26/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 25 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150226.965aeb8). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm