NetBeans GUI Creating Tool

im doing my HIGCSE comp sci project that has to be handed in in september. now i was wondering if the examiners would frown on me using the GUI creating tool that NetBeans has? or dont they really mind?

oh and do any of you know how i can edit the blue generated code?

thnx a million :)

[305 byte] By [Alex1989a] at [2007-11-27 1:36:54]
# 1
And what will be the pupose of editing the auto-generated code when you can do anything you want with the visual components?
J@A@V@Aa at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 2

> And what will be the pupose of editing the

> auto-generated code when you can do anything you want

> with the visual components?

can you do anything you want with visual components, though? I don't believe so, far from it. it's perfectly acceptable to want to edit that code, this isn't visual basic you know. I - and many others - avoid using visual editors precisely because the code they generate is usually a pile of cr@p that needs so much refactoring you may as well have written it by hand in the first place

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 3

"can you do anything you want with visual components, though? I don't believe so, far from it. it's perfectly acceptable to want to edit that code, this isn't visual basic you know. I - and many others - avoid using visual editors precisely because the code they generate is usually a pile of cr@p that needs so much refactoring you may as well have written it by hand in the first place"

It's everybody's choice to use a Visual Editor or not.

The Visual Editor has his limitation, but in a Desktop Application si enought.

Give me an example about someting you cannot do in Visual Editor,and you need to modify the autogenerated code to do that. (In a Desktop Application).

J@A@V@Aa at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 4

> "can you do anything you want with visual components,

> though? I don't believe so, far from it. it's

> perfectly acceptable to want to edit that code, this

> isn't visual basic you know. I - and many others -

> avoid using visual editors precisely because the code

> they generate is usually a pile of cr@p that needs so

> much refactoring you may as well have written it by

> hand in the first place"

>

> It's everybody's choice to use a Visual Editor or

> not.

> The Visual Editor has his limitation, but in a

> Desktop Application si enought.

> Give me an example about someting you cannot do in

> Visual Editor,and you need to modify the

> autogenerated code to do that. (In a Desktop

> Application).

there are millions of examples. what if I want a combo box to populate itself via web service calls? how would you do that with just a visual editor. what if I wanted to describe my UI in XML, that was editable at runtime? how would you do that with just a visual editor?

that you haven't yet found something you need to edit code for simply means you haven't written much useful code yet, or that you know very little about good code structure. if you think the generated code should just be left as-is, you're in cloud cuckoo land

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 5

I think you do not use the full power of an visual editor.

The autogenerated code is used only for "initComponents()" like the name itself suggest that.

You can than populate tables, combo boxes, call webServices.

You spend less time for positioning the components, and you have more time to do the esential work.

J@A@V@Aa at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 6

> I think you do not use the full power of an visual

> editor.

> The autogenerated code is used only for

> "initComponents()" like the name itself suggest

> that.

> ou can than populate tables, combo boxes, call

> webServices.

> You spend less time for positioning the components,

> and you have more time to do the esential work.

that's as maybe, but your assertion that the generated code does not need editing is a fallacy. that is my point. are you going to argue the toss every single time someone makes a comment?

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 7

I'm not argueing.

I'm just saying that a Visual Editor is very useful.

That doesn't mean that i don't use my own code even for adding visual components.

So the solution for editing the auto-generated code is: after the initComponent() method is called form the contructor, you can call your own reInit() method thad does eveerithyng you want: resizing, repositioning, adding new components, etc.

J@A@V@Aa at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 8

> I'm not argueing.

> I'm just saying that a Visual Editor is very useful.

> That doesn't mean that i don't use my own code even

> for adding visual components.

> So the solution for editing the auto-generated code

> is: after the initComponent() method is called form

> the contructor, you can call your own reInit() method

> thad does eveerithyng you want: resizing,

> repositioning, adding new components, etc.

so you let tools dictate how you write code? see, I don't like that. up to you, though. but to say the generated code doesn't ever need editing is plain wrong

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 9

>so you let tools dictate how you write code? see, I don't like that. up to you, >though. but to say the generated code doesn't ever need editing is plain wrong

No. I make the tools act as i want. I never had a problem that i could not resolve... Give an example when you had to RE-EDIT the code...

J@A@V@Aa at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 10

> >so you let tools dictate how you write code? see, I

> don't like that. up to you, >though. but to say the

> generated code doesn't ever need editing is plain

> wrong

>

> No. I make the tools act as i want. I never had a

> problem that i could not resolve... Give an example

> when you had to RE-EDIT the code...

I don't use visual editors. we've got our own layer of adapters over the top of swing, and a visual editor wouldn't be aware of them, so they're no use to us

how do you add event listeners to your components in your visual editor? I'm not saying you can't, but how would you add anonymous inner classes, containing arbitrary code, using just the visual editor?

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 11

> >so you let tools dictate how you write code? see, I

> don't like that. up to you, >though. but to say the

> generated code doesn't ever need editing is plain

> wrong

>

> No. I make the tools act as i want. I never had a

> problem that i could not resolve... Give an example

> when you had to RE-EDIT the code...

georgemc already gave you a valid one...

What if you want a dynamic GUI that is determined by XML descriptor files? I am maintaining such an application right now.

I ran into the same problem trying to use the NetBeans GUI tool but was thoroughly pi$$ed to find how extensively they tried to prevent me from editing the code. I find the tool is good for my JUnit test classes but not my production code. It is the worst case of spaghetti code drivel that I have ever seen auto-generated.

To answer the OP's original question, to edit the blue highlighted code you will have to use a third-party editor of any kind to modify the code.

maple_shafta at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 12

> > >so you let tools dictate how you write code? see,

> I

> > don't like that. up to you, >though. but to say

> the

> > generated code doesn't ever need editing is plain

> > wrong

> >

> > No. I make the tools act as i want. I never had a

> > problem that i could not resolve... Give an

> example

> > when you had to RE-EDIT the code...

>

> georgemc already gave you a valid one...

>

> What if you want a dynamic GUI that is determined by

> XML descriptor files? I am maintaining such an

> application right now.

>

> I ran into the same problem trying to use the

> NetBeans GUI tool but was thoroughly pi$$ed to find

> how extensively they tried to prevent me from editing

> the code. I find the tool is good for my JUnit test

> classes but not my production code. It is the worst

> case of spaghetti code drivel that I have ever seen

> auto-generated.

>

>

>

> To answer the OP's original question, to edit the

> blue highlighted code you will have to use a

> third-party editor of any kind to modify the code.

netbeans makes it awkward to edit it's generated code? that's rather arrogant, really. "I am The Great NetBeans. I generate perfect code. you mere mortals are not worthy to change it". no thanks, netbeans

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 13

>how do you add event listeners to your components in your visual editor? I'm >not saying you can't, but how would you add anonymous inner classes to your >code using just the visual editor?

Too add event listeners:

Right click on a components->Events->Mouse(for ecample)->mousePressed.

It autogenerate an inner class for that listener.

In the place i work we don't use either visual components.

I use it only in my spare time when i make desktop aplications for my own use.

J@A@V@Aa at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 14

> >how do you add event listeners to your components in

> your visual editor? I'm >not saying you can't, but

> how would you add anonymous inner classes to your

> >code using just the visual editor?

>

> Too add event listeners:

> Right click on a components->Events->Mouse(for

> ecample)->mousePressed.

> It autogenerate an inner class for that listener.

and then what? you have an empty inner class. how do you then get your application-specific code into it, without editing the source?

> In the place i work we don't use either visual

> components.

> I use it only in my spare time when i make desktop

> aplications for my own use.

good for you. but that doesn't mean that just because you can get by using the visual editor as-is, everyone else will have the same experience

georgemca at 2007-7-12 0:46:54 > top of Java-index,Java Essentials,Java Programming...
# 15

>and then what? you have an empty inner class. how do you then get your >application-specific code into it, without editing the source?

In the autogenerated code you have something like this:

jTable1.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jTable1MouseClicked(evt);

}

});

andjTable1MouseClicked() is a method that you can edit.

I'm not sqying that everyone should now i'm just saying that some things arre possible.

J@A@V@Aa at 2007-7-21 20:10:17 > top of Java-index,Java Essentials,Java Programming...
# 16
It is pretty neat to play with and I will say that it is by the far the easiest to use visual GUI editor that I have ever used for Swing.However I can't get over how hard it is to read and maintain the auto-generated code.
maple_shafta at 2007-7-21 20:10:17 > top of Java-index,Java Essentials,Java Programming...
# 17
k i found out how to edit it. thnx for ur "help" guys hahaha :P. anyway enjoy arguing, chrz
Alex1989a at 2007-7-21 20:10:17 > top of Java-index,Java Essentials,Java Programming...