1 / 42

From BlueJ to NetBeans

From BlueJ to NetBeans. SWC 2.semester. Why change…?. BlueJ is great for introduction to programming Simple interface, few options Graphical interface to classes and objects Some tehnical details are hidden. Why change…?. NetBeans is great for professional programming

zihna
Download Presentation

From BlueJ to NetBeans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. From BlueJ to NetBeans SWC 2.semester

  2. Why change…? • BlueJ is great for introduction to programming • Simple interface, few options • Graphical interface to classes and objects • Some tehnical details are hidden

  3. Why change…? • NetBeans is great for professional programming • Much more functionality • Better editor, debugger,… • Integration to database systems • A full-blown, stand-alone system • …but also more complex!

  4. What is NetBeans? • NetBeans is an open-source project • Originates from SUN Microsystems • www.netbeans.org • Can - of course – be downloaded for free from the website • We use NetBeans 6.9.1 SE (+ Java JDK)

  5. What is NetBeans?

  6. How do I… • …create a new project? • …add a new class? • …edit a class definition? • …write text to the screen? • …get input from the user? • …run a project?

  7. Create a new project - BlueJ Choose Project | New Project…

  8. Create a new project - BlueJ Enter project name, press ”Create”

  9. Create a new project - NetBeans Choose File | New Project…

  10. Create a new project - NetBeans In Categories, choose ”Java” In Projects, choose ”Java Application”

  11. Create a new project - NetBeans Enter project name and location

  12. Create a new project - NetBeans

  13. Create a new project - NetBeans • Why is there a ”Main.java” class…? • All Java programs must contain a method with this signature: public static void main(String[] args) • This was hidden in BlueJ! • Think of Main as a ”System” class • When the program starts, the code in the main(…) method is executed

  14. Add a new class- BlueJ Press ”New Class…” Enter class name

  15. Add a new class- BlueJ

  16. Add a new class- NetBeans Highlight the bankaccount package! Choose New | Java Class

  17. Add a new class- NetBeans Enter class name

  18. Add a new class- NetBeans

  19. Edit a class definition - BlueJ Double-click on the class icon

  20. Edit a class definition - BlueJ

  21. Edit a class definition - NetBeans Double-click on the class icon

  22. Edit a class definition - NetBeans Note the file panes in NetBeans

  23. Edit a class definition - NetBeans • Why do red lines start to appear in the code, as soon as I start typing…? • The NetBeans editor continuously makes an analysis of the code, even before it is compiled • The editor highlights errors in the code by a waved red line, even before typing has been completed • Helpful…? Annoying…?

  24. Edit a class definition - NetBeans Yes, I know, but I am still typing!!

  25. Edit a class definition - NetBeans See hints by hovering mouse over (!)

  26. Edit a class definition - NetBeans • Why do lists with method names pop up when I type…? • The NetBeans editor supports ”auto-completion”, i.e. it tries to predict what you will type next • Typically when calling a method with ”.” • Helpful, when you get used to it…

  27. Edit a class definition - NetBeans Available methods on the specific object/class Documentation for each method

  28. Writing text to the screen - BlueJ

  29. Writing text to the screen - BlueJ

  30. Writing text to the screen - NetBeans

  31. Writing text to the screen - NetBeans Need this code for actually executing the method

  32. Writing text to the screen - NetBeans Output written to the ”Output window”

  33. Get input from the user - BlueJ

  34. Get input from the user - BlueJ Enter parameter value directly

  35. Get input from the user - NetBeans • Not quite as simple to get input from a user in NetBeans • Two options • Use the Scanner class • Use a input dialog class • See chapter 3.6 in Big Java for details

  36. Get input from the user - NetBeans import java.util.Scanner; … Scanner in = new Scanner(System.in); … String name = in.nextLine(); … int balance = in.nextInt(); … double area = in.nextDouble();

  37. Get input from the user - NetBeans import javax.swing.JOptionPane; … String value = JOptionPane.showInputDialog(”Limit”); … int limit = Int.parseInt(value);

  38. Running a project - BlueJ • We cannot as such ”run” a project in BlueJ – what should run..? • We usually create a ”system” class, that has a ”run”-like method • Create a System object • Right-click the object • Call the run method

  39. Running a project - NetBeans Choose Run | Run Main Project

  40. Running a project - NetBeans …or just click the green triangle (or press F6)

  41. Running a project - NetBeans • Running a project always executes the main method in the Main class! • A project is automatically compiled when you save it • No reason to run a project in order to fix syntax errors

  42. Other NetBeans features • A GUI Builder – build a GUI by drag-drop of controls. Code is auto-generated • A much more powerful debugger • More customisable • Easy integration to database systems • We will talk about additional features later on…

More Related