Human Computer Interaction JAVA APPLETS JAVA AWT ?e??ss? - PowerPoint PPT Presentation

About This Presentation
Title:

Human Computer Interaction JAVA APPLETS JAVA AWT ?e??ss?

Description:

Human Computer Interaction JAVA APPLETS JAVA AWT Owda Zaher applets ... – PowerPoint PPT presentation

Number of Views:393
Avg rating:3.0/5.0
Slides: 30
Provided by: supp73
Category:

less

Transcript and Presenter's Notes

Title: Human Computer Interaction JAVA APPLETS JAVA AWT ?e??ss?


1
Human Computer InteractionJAVA APPLETSJAVA
AWT?e??ss?ßa? ??µ?t???Owda Zaher
2
?e?????sµ?? asf??e?a??a applets de µp?????
  • ?a d?aß?s??? ap? t?? t?p??? d?s?? t?? client
  • ?p????? ?a pa???s??s??? se??de? d?a??s?µe? st?
    Web
  • ?a ??????? st?? t?p??? d?s?? t?? client
  • ? browser µp??e? ?a ap?fas?se? ???e? cache ??p??a
    a??e?a s?et???µe?a µe ta applets. ?e? e??a? st??
    d??a??d?s?a t?? applet ?a ap?fas?se? p??a.
  • ?a a??????? ???a connections, pe?a ap? ap? t??
    webserver
  • ?e??????e? ta applets ?a ß??p??? a??e?a p?s? ap?
    network firewalls

3
?e µp?????
  • ?a e?te??s??? p?????µµata st? µ?????µa t?? ???st?
  • ? Java ??e? t? d??at?t?ta ?a e?te??se? t?p???
    e??atest?µ??a p?????µµata.
  • ??t? de? ep?t??peta? sta applets ??a ??????
    asfa?e?a?
  • ?a a?a?a?????? p??s?p??? ded?µ??a t?? ???st?
  • ?a e?a?s??ta st???e?a t?? ???st?, ?p?? t?
    username ? st???e?a ??a t? s?st?µa (p? filesystem
    ktlp)
  • ?p????? ?st?s? ?a µ????? t? ???µa t?? host ap? t?
    ?p??? t?????? (a?t? t? ???e? ?d? ? HTTP server)

4
Applet Template
  • Import java.applet.Applet
  • Import java.awt.
  • Public class AppletTemplate extends Applet
  • // Variable declarations
  • Public void init()
  • // Variable initialisations, image loading, etc.
  • Public void paint(Graphics g)
  • // Drawing operations

5
HTML Template
  • ltHTMLgt
  • ltHEADgt
  • ltTITLEgt A Template for Loading Appletslt/TITLEgt
  • lt/HEADgt
  • ltBODYgt
  • ltH1gtHello World!lt/H1gt
  • ltPgt
  • ltAPPLET CODEApplectTemplate.class WIDTH120
    HEIGHT60gt
  • ltBgtError!lt/Bgt
  • lt/APPLETgt
  • lt/BODYgt
  • lt/HTMLgt

6
?a??de??µa Applet
  • Import java.applet.Applet
  • Import java.awt.
  • Public class MyTest extends Applet
  • private Image My_Image
  • Public void init() // constructor
  • setBackground(Color.white)
  • setFont(new Font(Arial, Font.BOLD, 14))
  • My_Image getImage(getDoccumentBase(),
    pictures/test.gif)
  • add(new Label(Test!))
  • Public void paint(Graphics g) //drawing
  • g.drawImage(My_Image, 0, 50, this)

7
???esµa
  • ltHTMLgt
  • ltHEADgt
  • ltTITLEgt My Test!lt/TITLEgt
  • lt/HEADgt
  • ltBODYgt
  • ltH1gtMy Imagelt/H1gt
  • ltPgt
  • ltAPPLET CODEMyTest.class WIDTH120 HEIGHT60gt
  • ltBgtError!lt/Bgt
  • lt/APPLETgt
  • lt/BODYgt
  • lt/HTMLgt

8
? ?????? ???? e??? Applet
  • Public void init()
  • ?a?e?ta? µ????a t?? p??t? f??? p?? f??t??eta? t?
    applet st?? browser
  • ??? ???e f??? p?? e?te?e?ta? a?t?
  • Public void start()
  • ?a?e?ta? a????? aµ?s?? µet? t?? init()
  • ?a?a?a?e?ta? ???e f??? p?? ? ???st?? ep?st??fe?
    st?? se??da
  • ???s?µ?p??e?ta? ??a ?a e????e? animations
  • Public void paint(Graphics g)
  • ?a?e?ta? aµ?s?? µet? ap? t?? start()
  • ?a?a?a?e?ta? ?ta? ? browser ?a?as?ed???e? t??
    e????a. S?????? ?ta? ?a??pteta? ??a µ???? µ????
    ?a? epa?eµfa???eta?

9
? ?????? ???? e??? Applet (S????e?a)
  • Public void stop()
  • ???e f??? p?? ? user fe??e? ap? t?? se??da
  • ???s?µ? ??a ?a staµat?e? ta animations
  • Public void destroy()
  • ?ta? ??e??e? t? applet

10
???s?µe? s??a?t?se??
  • getCodeBase, getDocumentBase
  • ?p?st??f??? ta URL t??
  • Applet file getCodeBase()
  • HTML file getDocumentBase()
  • getSize
  • ?p?st??fe? t?? d?ast?se?? t?? applet (width,
    length)
  • getGraphics
  • ?p?st??fe? t? Graphics object ??a t? applet
  • ?? Graphics d?a???feta? µeta?? d?ad?????? paint()

11
???s?µe? s??a?t?se?? (S????e?a)
  • showDocument (ApplectContext method)
  • getAppletContext().showDocument()
  • ??t?e? ap? t?? browser ?a pa???s??se? µ?a Web
    page
  • ?p??e? ?a e??a? ?a? FRAME
  • showStatus
  • ?µfa???e? ??a string st? status line t?? browser
  • getCursor, setCursor
  • ????e? t?? t?p? t?? ???s??a ??a t? p??t???. ??
  • CROSSHAIR_CURSOR, HAND_CURSOR, WAIT_CURSOR

12
???s?µe? s??a?t?se?? (S????e?a) !
  • getAudioClip, play
  • ?a??e? ??a a??e?? ????, ap? µ?a ap?µa???sµ???
    t?p??es?a
  • getBackground, setBackground
  • ???µ??e? t? ???µa t?? background ??a t? applet
  • getForeground, setForeground
  • ???µ??e? t? t????? ???µa t?? s?ed?as??

13
Embedding se HTML
  • ltAPPLET CODE WIDTHxxx HEIGHTxxx gt
  • lt/APPLETgt
  • ?pa?a?t?ta ded?µ??a
  • CODE
  • ???µ??e? t? filename t?? a??e??? Java class, ?ste
    a?t? ?a f??t??e?
  • S?et??? path, µe ß?s? t? t????? HTML file, e?t??
    ?µa ???ste? ? pa??µet??? CODEBASE ?at?????a
  • WIDTH ?a? HEIGHT
  • ????e? t?? d?ast?se?? t?? applet
  • ?? t?µ?? µp??e? ?a ???st??? t?s? se pixels ?s?
    ?a? se p?s?st? t?? browser window

14
Embedding se HTML (S????e?a)
  • ????? pa??µet???
  • ALIGN HSPACE ?a? VSPACE
  • ?????e? t?? t?p???t?s? ?a? ta borders. ?a??µ???
    µe t? IMG t?? HTML
  • ARCHIVE
  • ????e? JAR file (zip file µe .jar extention) t?
    ?p??? pe????e? ??e? t?? ???se?? ?a? e????e? p??
    ???s?µ?p?????ta? ap? ta applets
  • ? s?µp?es? e???????µe? p??a p??? ?????,
    e?d???te?a se pe??pt?s? a??et?? a??e???
  • ????
  • ???e? ???µa st? applet

15
?a????sµ?? pa?aµ?t???
  • ltH1gt Customizable ello World appletlt/H1gt
  • ltAPPLET CODEHello.class WIDTH400 HEIGHT40gt
  • ltPARAM NAMEBACKGROUND VALUELIGHTgt
  • ltBgt Error! lt/Bgt
  • lt/APPLETgt
  • ltAPPLET CODEHello.class WIDTH400 HEIGHT40gt
  • ltPARAM NAMEBACKGROUND VALUEDARKgt
  • ltBgt Error! lt/Bgt
  • lt/APPLETgt
  • ltAPPLET CODEHello.class WIDTH400 HEIGHT40gt
  • ltBgt Error! lt/Bgt
  • lt/APPLETgt

16
???ßasµa pa?aµ?t???
  • ???s? t?? getParameter(name)
  • name case sensitive
  • Public void init()
  • Color backgrround Color.gray
  • Color foreground Color.darkGray
  • String backgroundType getParameter(BACKGROUND)
  • If (backgroundType ! null)
  • If (backgroundType.equalsIgnoreCase(LIGHT))
  • Background Color.white
  • Foreground Color.black
  • else if (backgroundType.equalsIgnoreCase(DARK)
    )
  • background Color.black
  • foreground Color.white

17
???ßasµa pa?aµ?t??? (?p?t??esµa)
18
????d?? Graphics
  • drawString(string, left, bottom)
  • ????af??e? t? string, st?? t?p??es?a left, bottom
  • drawRect(left, top, width, height)
  • ?de?? ?????????
  • fillRect(left, top, width, height)
  • Geµ?t? ?????????
  • drawLine(x1, y1, y2, y2)
  • G?aµµ?

19
????d?? Graphics
  • drawOval, fillOval
  • S?ed???e? ??a ?ß?? s??µa. ?a arguments ?a????????
    ta ????????a borders
  • drawPolygon, fillPolygon
  • ?a points ap????e???ta? se array ? st?? Polygon
    class.
  • By default ??e?st? p????????? ??aµµ?. ??a?a?t???
    drawPolyline
  • drawImage
  • F??t??e? µ?a e????a
  • ?p?st????e? JPG ? GIF format

20
Drawing Color
  • setColor, getColor
  • ?a?????e? t? foreground color (???µa s?ed?as??)
  • Default t? foreground color t?? pa?a?????
  • ?p?????? p???a????sµ??a ???µata (Color.red,
    Color.yellow ?t?p), ? new Color(r, g, b)

21
Graphics Font
  • setFont, getFont
  • ?a????sµ?? t?? font ??a strings

22
???a modes
  • setXORMode
  • ???s?µ? ??a selections
  • setPaintMode
  • ?p?st??f? st? ?a?????? mode

23
?a?????a
  • Containers
  • ?a pe??ss?te?a pa?????a ?e?????ta? Containers.
    ?p????? ?a ??at??e a??a pa?????a ? GUI
    components. ?e? ?s??e? ??a Canvas
  • Layout Managers
  • G?a ?a ???µ????? µe???? ?a? ??se?? components
    p??? sta pa?????a
  • Events
  • G?a input (mouse, keyboard etc)

24
?a?????a (S????e?a)
  • S?ed?asµ??
  • Subclass µe d???? t?? paint method
  • Popup Windows
  • (Frame ?a? Dialog) ????? d???? t??? µp??a
  • (Canvas ?a? Panel) p??pe? ?a ?????? embed

25
Components
  • ???s?µe? s??a?t?se??
  • getBackground/setBackground ..
  • Paint
  • setVisible (true, false)
  • List
  • getParent

26
?a??de??µa
  • Import java.applets.Applet
  • Import java.awt.
  • Public class ButtonTest extends Applet
  • public void init() String labelPrefixes
    Start, Stop, Pause, Resume
  • For (int 0 I lt 4 i)
  • add(new Button(labelPrefixesi Thread 1))

27
?a??de??µa 2 (Confirmation Dialog)
  • Class Confirm extends Dialog implements
    ActionListener
  • Private Button yes, no
  • Public Confirm(Frame parent)
  • super(parent, Confirmation, true)
  • setLayout(new FlowLayout())
  • add(new Label(Really quit?))
  • yes new Button(Yes)
  • yes.addActionListener(this)
  • no new Button(No)
  • no.addActionListener(this)
  • add(yes)
  • add(no)
  • pack()
  • setVisible(true)

28
S????e?a
  • Public void actionPerformed(ActionEvent event)
  • if (event.getSource() yes)
  • System.exit(0)
  • else
  • dispose()

29
???s?µ?p???s? t?? Dialog
  • Public class ConfirmTest extends Frame
  • public static void main(String args)
  • new ConfirmTest()
  • public ConfirmTest()
  • super(Confirming QUIT)
  • setSize(200, 200)
  • addWindowListener(new ConfirmListener())
  • setVisible(true)
  • public ConfirmTest(String title)
  • super(title)
  • private class ConfirmListener extends
    WindowAdapter
  • public void windowClosing(WindowEvent event)
  • new Confirm(ConfirmText.this)
Write a Comment
User Comments (0)
About PowerShow.com