Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans.

Similar presentations


Presentation on theme: "Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans."— Presentation transcript:

1 Java With NetBeans First Project

2 Java Are language for this semester is Java The Development Environment is Netbeans

3 Graphics We will create a program to demonstrate graphics

4 Lets Try this together Sorry I could not be there so please help each other out with this Lets build a Java Program that will display some graphics to a panel on the screen

5 Start NetBeans It should be on the Desktop

6 Project Select File and the New Project

7 Category is Java Project is Java Application

8 Change 3 things

9 Create the window We have just created an empty project Select New File from the File menu

10 Category is “Swing GUI Forms” File Type is “JFrame Form”

11 Class name is Main Package is your initials

12 Locate the Palette

13 Add Two components Drag and Drop a Button from the palette(toolbox) to your JFrame(window) Drag and Drop a JPanel from your palette to your JFrame

14 Position items Stretch the Panel Move the button  Like this

15 Name the Panel Right click on Panel Select “Change Variable Name”  pnlDraw

16 Button Properties Right Click on Button  Set Variable name to btnDraw Right Click on Button again  Edit Text to Draw

17 Lets Code Right Click on the button Events-> Action -> actionPerformed

18 Add Code Put code in btnDrawActionPerformed  Graphics g = pnlDraw.getGraphics()  Ignore the error till the next slide

19 Fix Error Click on Error Light bulb Add import for java.awt.Graphics

20 Draw a Rectangle Set the color to your choice Draw a Rectangle Numbers are x, y, width, height

21 Fix another error Click on Light Bulb  Add import for java.awt.Color

22 Run Program Click the green play button  Hot key is F6

23 Select Window Just say OK Here

24 Press Draw Button Ok, what a very exciting program It draws a rectangle, ooooh!

25 Your turn… Draw an filled rectangle  g.fillRect Draw an oval of another color  g.drawOval  g.fillOval


Download ppt "Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans."

Similar presentations


Ads by Google