• Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving code in netbeans  RSS feed

 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have several buttons placed in order, but my code has one higher up in the source than I want it. I want to move it BELOW the rest of my buttons:



How do I move code? Last time I tried to do this I deleted my whole frame. =(
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've said this before but I'll keep on saying it until I'm blue in the face: a visual designer is categorically NOT a beginner's tool. It's only worth investing the time and effort to learn how to do things correctly in a visual designer if you are aiming for a career in GUI design.

Lear to program a Swing GUI the easy way: Trail: Creating a GUI With JFC/Swing

That said, the order of methods in a class doesn't affect how the code executes. If you think it does, you have other gaps in your learning that you need to make good before progressing to GUIs.
 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, but I still have autogenerated snippets of code I need to get rid of/rearrange.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Summary of Darryl's post is:

don't autogenerate code
 
Nam Ha Minh
Ranch Hand
Posts: 515
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anthony Schmitt wrote:I have several buttons placed in order, but my code has one higher up in the source than I want it. I want to move it BELOW the rest of my buttons:



How do I move code? Last time I tried to do this I deleted my whole frame. =(


Quick and dirty way: open the .java file in a plain text editor, then you are freely to move the code
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:
Quick and dirty way: open the .java file in a plain text editor, then you are freely to move the code

...and the IDE will probably over write all the changes next time you compile/run. I have seen comments like "Do not edit, machine generated code" or something similar.
Best way is what Darryl said. Hand code.
 
Nam Ha Minh
Ranch Hand
Posts: 515
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:
Best way is what Darryl said. Hand code.


I don't totally agree with that. In my opinion, using both IDE and hand code for UI is preferred. We should understand Java Swing well enough before using IDE for GUI. So that we can solve problems quickly if they come.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more point...whenever 'hand code' is mentioned, many people think of Notepad and it scars them...that is not the intention...
You can still use NetBeans IDE to 'hand code' - write code in the editor from scratch and you will still get all the help with errors, imports, method popups and so on. Just avoid the 'designer' when you are starting to learn.
 
Nam Ha Minh
Ranch Hand
Posts: 515
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:One more point...whenever 'hand code' is mentioned, many people think of Notepad and it scars them...that is not the intention...
You can still use NetBeans IDE to 'hand code' - write code in the editor from scratch and you will still get all the help with errors, imports, method popups and so on. Just avoid the 'designer' when you are starting to learn.


Agree! If we understand how things are working, no matter IDE or hand coded.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:We should understand Java Swing well enough before using IDE for GUI.

That's what I meant when I said a visual designer isn't a beginner's tool.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!