Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet.

Similar presentations


Presentation on theme: "Java On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet."— Presentation transcript:

1 Java On The Web Session 15

2 Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet

3 Applets An applet is a program that runs embedded in HTML code They must be viewed either in  Web Browser  Appletviewer

4 GUI Elements Applets can display GUI elements  Graphical User Interface Colors Fonts Text-Fields, Button, Labels, etc. Button

5 Skeleton import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){ } public void paint(Graphics g){ //instructions go here } }

6 Skeleton import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){ } public void paint(Graphics g){ //instructions go here }

7 Colors Colors are made out of 3 values Each value goes from 0 to 255  RED  GREEN  BLUE

8 Colors BlackColor.black0,0,0 BlueColor.blue0,0,255 CyanColor.cyan0,255,255 GrayColor.gray128,128,128 GreenColor.green0,255,0 MagentaColor.magenta255,0,255 OrangeColor.orange255,200,0 PinkColor.pink255,175,175 RedColor.red255,0,0 WhiteColor.white255,255,255 YellowColor.yellow255,255,0

9 Colors import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){ } public void paint(Graphics g){ //Your Own Color MyColor = new Color(50, 200,150); g.setColor(MyColor); } }

10 .setColor(Color) g.setColor(Color.yellow); g.setColor(Color.red); g.setColor(MyColor);

11 Fonts The constructor Font f = new Font(Type, Style, Size); import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){a } public void paint(Graphics g){ Font f=new Font(“Tahoma”,Font.PLAIN, 10); g.setFont(f); } }

12 Methods void drawLine(int x1, int y1, int x1, int y2) void drawRect(int x, int y, int w, int h) void fillRect((int x, int y, int w, int h) void drawOval(int x, int y, int w, int h) void fillOval(int x, int y, int w, int h) void drawString(String, int x, int y) void drawArc(int x, int y, int w, int h, int start angle, int arcAngle) void fillArc(int x, int y, int w, int h, int start angle, int arcAngle)

13 The coordinates 0,0 x y

14 drawLine g.drawLine(10,10,18,24); 10 24 18

15 0,0 drawRect 8 10 g.setColor(Color.green); g.drawRect(10,10,8,10);

16 0,0 8 10 fillRect g.setColor(Color.green); g.fillRect(10,10,8,10);

17 0,0 8 10 drawOval g.setColor(Color.red); g.drawOval(10,10,8,10);

18 0,0 8 10 fillOval g.setColor(Color.red); g.fillOval(10,10,8,10);

19 0,0 8 10 drawArc g.setColor(Color.blue); g.drawArc(10,10,8,10,0,45);

20 0,0 8 10 fillArc g.setColor(Color.blue); g.fillArc(10,10,8,10,0,45);

21 0,0 drawString g.setColor(Color.Magenta); g.setFont(“Arial”,Font.PLAIN, 30); g.drawString(“Blanca”,10,10); 10 Blanca

22 Posting Your Applet Write your JAVA code Compile your code Make it available

23 The Applet Tag <applet CODE="YourClass.class" WIDTH=www HEIGHT=hhh IGNORE=""> Substitute www and hhh for your own width and height. Substitute YourClass.class with the name of your own class. The Applet tag should be regarded as any other html tag inside your HTML page.

24 Time to Try it Out Applets on the Web

25 Drawing Applet Skeleton Drawing Methods Colors Fonts Posting Applets in the Web E-mail any questions to blanca@hawaii.edu Memory Defragmenter

26 Task Manager Post the sample applet from webct on the web, in your website. Read your e-mail Visit WebCT, webct.hawaii.edu

27 Task Manager Post the sample applet from webct on the web, in your website. Read your e-mail Visit WebCT, webct.hawaii.edu


Download ppt "Java On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet."

Similar presentations


Ads by Google