Sorry in the assignment I doing I was given the following criteria
"The user interface for this assignment must satisfy the following criteria:
It must be composed exclusively with components from the Java Foundation Classes (Swing components)"
Is it still possible to use the java.awt.* packages or can 1 only use the javax.swing.*; packages
Maybe confused by terminology here.
Cheers, thanks for the responses. Just wished to get better understanding of terminology, that's great.!
Mark O' Sullivan
Joined: Aug 17, 2009
Sorry would appreciate people's opinion upon the following. Based upon question I posed, would one be expected to use the GroupLayout manager instead of the GridBagLayout manager, if they wished to use these types of layouts?
Is it still possible to use the GridbagLayout based upon my initial question seeing as it appears in the awt package? The reason I would prefer to use it is that it seems relatively simple to use if coding by hand compared to other layout managers.
There is a big difference between generating some methods to implement and generating a complete GUI through some editor plug-in. And when I see a NullLayout, I know you didn't develop it yourself, because that's a layout manager a developer would hardly use (but which is frequently used by a gui building tool/plugin).
You have to develop a simple gui, nothing fancy, so I won't taking the risk of failure, but that's just my opinion.
Roberto Perillo wrote:Champion, is "generated code" "your own work"?
Depends on which definition of work you are using. If you you use scientific definition:
wikipedia wrote:work is the amount of energy transferred by a force acting through a distance.
Then I would say it is my muscles who moved mouse and tapped the keyboard, so I did the work. Yes, generated code is my work when I handled the generator.
There may be other definitions, legal, copyright, empoyment etc. pp.
Roberto Perillo wrote:No generated code is allowed.
Code Re-factor? Introduce Variable, Constant, Method? Heck, "New class" won't open an empty file! Especially the "New class" in Eclipse is pretty powerful. It will generate constructors, main, implementations for all abstract methods.
This too is generated code. Hands up who did not use any of those features.
Roberto Perillo wrote:If the assessor notice this, the candidate is automatically failed.
Are you an assessor with inside knowledge? Because from the instructions I can't deduct this. For me my work is independed of the tool I use. And a GUI builder is just a tool. A speclialzed editor for specific types of code. Until I came here I interpreted the sentece in the way that I can't bundle org.desktop.GroupLayout with my work but which editor I use and how advanced or powerfull that editor might be is up to me. Including editors which use a graphical representation of my code. I also use UML round trip engeneering. Until I came here that is.
And I am not the only one. I read quite a few postings on the matter and all threads seem to start with a candidate coming to the forum with the same opinion that I had. And beeing freighted off.
Of course I too are freighted and won't take the risk on a highly ambiguous instruction. Just don't sell that sentence as absolute truth. It isn't. If it is true what you say then it is a trick question designed to make otherwise suitable candidates fail. Why else not just say “Code generators and GUI builder are not allowed!”.
Especially since both the SCJP and SCJD preparation courses use the netbeans GUI builder the as well and one of the SCJP questions stess the point that “writing GUI code by hand is cumbersome in production environments”.
Martin Krischik wrote:Code Re-factor? Introduce Variable, Constant, Method? Heck, "New class" won't open an empty file! Especially the "New class" in Eclipse is pretty powerful. It will generate constructors, main, implementations for all abstract methods.
This too is generated code. Hands up who did not use any of those features.
While this is true, I think there's a sensible and easy distinction to make. Most of these features generate code exactly as a human would write it. They're just a short-cut. If I get Netbeans to create a bunch of accessors for me, there is absolutely no difference between what they generate and what I would generate if I type it all out by hand. And, importantly, they're unlikely to be doing anything I don't understand.
But your average GUI builder doesn't produce code in the style that a human would. It's usually very easy to tell if someone hand-coded it or not. And a GUI builder allows someone who doesn't understand Swing to produce a graphical interface. And that's what I think the rule is there for.
[If I really wanted to be awkward, I'd point out that technically using rmic to generate RMI stubs and skeletons breaks that particular rule, despite being a requirement if you're using RMI! ]
Matthew Brown wrote:If I get Netbeans to create a bunch of accessors for me, there is absolutely no difference between what they generate and what I would generate if I type it all out by hand.
I am a great fan of property change events so a generated accessors won't do for me ;-).
Matthew Brown wrote:It's usually very easy to tell if someone hand-coded it or not.
Funny that you say. Being dissatisfied with GridBagLayout I went out to see how GroupLayout works. And I found the Sun tutorial which uses advocates same wacky chained method calls that NetBeans generates. If I follow that tutorial to the letter then there will be only two lines which distinguish my code from code being generated with Netbeans:
Makes me wonder. Should I not follow the lead of that tutorial - just in case? I don't want to auto-fail on blimey technicality.
Martin Krischik wrote:Just don't sell that sentence as absolute truth. It isn't. If it is true what you say then it is a trick question designed to make otherwise suitable candidates fail. Why else not just say “Code generators and GUI builder are not allowed!”.
I give my own opinion (and I'm quiet certain Roberto just does the same). And we are not an assessor, certainly not one with inside knowledge. I don't sell anything for the absolute truth. It's nothing more than my interpretation of the instructions. So you don't have to agree at all.
And the reason why there is no rule like "GUI builder are not allowed" could be quiet easy: the instructions could simply be outdated and at the time it was created there were no gui builder tools/plugins. Just like the issue with the stubs who must be generated (according to the instructions), although since JDK 1.5 that's not necessary anymore. Many people passed already without generating these stubs (which I tell every time when someone asks about this must requirement).
Maybe you could use a generator for your GUI code and then we'll know if it is allowed or not. But at this moment it is my opinion you'll fail using a gui builder, so I advice against it.
Roberto Perillo wrote:It isn't necessary to be an assessor to notice something that is obvious.
Could you elaborate on that? I am not an native English speaker an I quite honestly fail to see obvious part. Remember the original wording is:
instructions.html wrote:You are permitted to use any IDE tool you choose, but you must not submit any code that is not your own work. The final program must have no dependencies on any libraries other than those of the Java 2 Platform.
In my understanding of the English language “any IDE tool you choose” would include any tool the IDE of my choice provides. As long as it does not introduce additional dependencies. And for me “not your own work” is not automaticly imply that I have to type the code one character at a time. But then I am not an native English speaker and if I missed s subtlety of the English language I am grateful to learn something new.
Until then I consider the instructions ambiguous and I appreciate the warning that using a GUI builder might get me into trouble and one should be better save the sorry.
PS: Did nobody ever try email@example.com to get an official stand? I guess we (including myself) are all cowards and far to afraid to fail to take any risks.
Martin Krischik wrote:Could you elaborate on that?
instructions.html wrote:You are permitted to use any IDE tool you choose, but you must not submit any code that is not your own work.
For me that's obvious and quiet easy (and I'm also not a native speaker): code generated by a gui builder is not my own, so I can't submit that. And my GUI code uses FlowLayout, GridBagLayout, BorderLayout,... I'm quiet sure a GUI builder will produce code that's completely different to mine.
First of all I guess this email address is not valid any more (since the acquisition by Oracle). Secondly they gave very little information and certainly not an official stand. I sent them an email asking if I could change Sun's interface just to add some javadoc to the methods. I didn't get any clear answer about that, so I didn't take any risk and kept Sun's interface as-is.
Roel De Nijs wrote:For me that's obvious and quiet easy (and I'm also not a native speaker): code generated by a gui builder is not my own, so I can't submit that.
I already challenged that opinion and stated that I do not accept that stand as absolute and universal truth.
Of course I am well aware that neiter your nor my but only Suns opinion is important here. I will head the advice given here and I am thankfull.
Roel De Nijs wrote:I'm quiet sure a GUI builder will produce code that's completely different to mine.
Different to your code yes, but I already stated that the Netbeans generates code which looks exactly like the code suggested in the Sun tutorial for for use of GroupLayout in hand coded GUIs. GroupLayout is part of Java 6 so I am free to use it.
Roel De Nijs wrote:Secondly they gave very little information and certainly not an official stand. I sent them an email asking if I could change Sun's interface just to add some javadoc to the methods.
Thank you for shareing your experince with firstname.lastname@example.org - no point wasting ones time here then.
I have views in my application that are JDialogs and JFrames. I have helper classes that work on both (simple things like setting up titles, frame icons, etc) - the only common is that they are both java.awt.Window classes.
So is it bad to have a helper method like doSomething(java.awt.Window window)?
I interpret the "no awt" rule is that you shouldn't use awt widgets.
One possible, common-sensical interpretation of the rule is that generating non-trivial code automatically is a no-no. There's a difference between code-completion of a line you've chosen to type and concept-completion that decides what line should be typed.