SlideShare a Scribd company logo
Developing User Interfaces
         (DUI)

         Chris North
        cs3724: HCI
GUI Development: Goals
1. Learn general GUI programming concepts
      •    GUI components
      •    Layout
      •    Event-based programming
      •    Graphics
      •    Animation
2. Learn Java
      •    Swing
      •    Layout managers
      •    Listerners
      •    2D graphics
      •    Threads


Then: can learn other languages quickly
      •    VB, C#, Xwin, Java 49
Intro to Java
Why Java?
Java materials
• Java 2 = sdk 1.2 or better
     • http://java.sun.com/j2se/
• Documentation:
     • http://java.sun.com/docs/
     • Tutorials, reference, API


• Borland JBuilder 6
     • http://www.borland.com/jbuilder/personal/
     • Free! Cross between VB and VC++
Java differences
•   Basic statements identical to C++
•   Object-oriented only!
•   No .h files
•   main() is inside a class
•   No global variables
•   No pointers (object references only)
•   No delete: automatic garbage collection
•   Single inheritance only, “interfaces”
•   Applet/application
•   GUI: AWT, Swing
•   Packaging
•   Error Handling, exceptions (try, catch)
        • E.g. Array bounds checking
• Security
• Components: beans
Java compiling
• Code:
     • hello.java   (text file)
• Compile:
     • javac hello.java
     • Creates: hello.class (byte code)
• Run:
     • java hello
     • Java virtual machine, interpets/compiles (machine code)
• Packaging: jar
• Or use JBuilder, like VC++
Java Applications
• Run from command line
• hello.java:
class hello {
  public static void main(String[] args){
     System.out.println(“Hello World!”);
  }
}


• javac hello.java
• java hello
Hello World!
Typically create objects
• hello.java:
class hello {
  public static void main(String[] args){
     // Create and use objects
     hello h = new hello();
     …
  }
  public hello(){ // Constructor
     …
  }
  …
}
Many Classes
• Compile each separately
• Can be main( ) in any/all classes
• hello.java:
class hello {
  goodbye g;
  public static void main(String[] args){
  …
}
• goodbye.java:
class goodbye {
  public static void main(String[] args){
  …
}
Hmmm…
• dir
hello.class
goodbye.class
blah.class
foo.class
bar.class
areyouawakein.class
• Java ???
• RunMe.bat:
java hello
JBuilder
Java Applets
• Run in a web browser
• hello.java:
import javax.swing.*;
class hello extends JApplet {
  public void init(){
     getContentPane().add(
          new JLabel(“Hello World!”) );
  }
}
• javac hello.java
                                     Hello World!
• appletviewer hello
Java Applets in HTML
• hello.html:
<html><body>
<applet code=“hello.class”
  height=100 width=200>
Need java.
</applet>
</body></html>
                                hello.html



• Put hello.html and
  hello.class on website
                             Hello World!
• Java plug-in
Applet Methods
•   init( ) - initialization
•   start( ) - resume processing (e.g. animations)
•   stop( ) - pause
•   destroy( )     - cleanup
•   paint( ) - redraw stuff (‘expose’ event)
Applet Security
•   No read/write on client machine
•   Can’t execute programs on client machine
•   Communicate only with server
•   “Java applet window” Warning

• Certificates
Upcoming Java Topics
•   GUIs: Swing, AWT, MVC
•   Event handling, listeners
•   Graphics
•   Animation, threads
•   Components, JavaBeans
•   Databases, JDBC

More Related Content

What's hot (20)

PDF
04b swing tutorial
Prakash Sweet
 
PPT
Fundamentals of JAVA
KUNAL GADHIA
 
PDF
Introduction to Java
Professional Guru
 
PDF
Introduction to java technology
Indika Munaweera Kankanamge
 
PDF
Core Java Tutorial
Java2Blog
 
PDF
Learn Java Part 1
Gurpreet singh
 
PPTX
Introduction to Java Programming
Saravanakumar R
 
PDF
Java programming material for beginners by Nithin, VVCE, Mysuru
Nithin Kumar,VVCE, Mysuru
 
PDF
Introduction to java (revised)
Sujit Majety
 
PPTX
Introduction to java
Java Lover
 
PDF
Java basics notes
poonguzhali1826
 
PPT
Java Presentation
pm2214
 
PPSX
Introduction to java
Ajay Sharma
 
PPTX
Java. converted (2)
AVINASHMEHRA6
 
PDF
JAVA GUI PART I
OXUS 20
 
PPT
Java introduction
logeswarisaravanan
 
PPT
Java introduction
Sagar Verma
 
PDF
Advanced programming ch1
Gera Paulos
 
PPT
Java basic introduction
Ideal Eyes Business College
 
PPTX
Structure programming – Java Programming – Theory
OXUS 20
 
04b swing tutorial
Prakash Sweet
 
Fundamentals of JAVA
KUNAL GADHIA
 
Introduction to Java
Professional Guru
 
Introduction to java technology
Indika Munaweera Kankanamge
 
Core Java Tutorial
Java2Blog
 
Learn Java Part 1
Gurpreet singh
 
Introduction to Java Programming
Saravanakumar R
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Nithin Kumar,VVCE, Mysuru
 
Introduction to java (revised)
Sujit Majety
 
Introduction to java
Java Lover
 
Java basics notes
poonguzhali1826
 
Java Presentation
pm2214
 
Introduction to java
Ajay Sharma
 
Java. converted (2)
AVINASHMEHRA6
 
JAVA GUI PART I
OXUS 20
 
Java introduction
logeswarisaravanan
 
Java introduction
Sagar Verma
 
Advanced programming ch1
Gera Paulos
 
Java basic introduction
Ideal Eyes Business College
 
Structure programming – Java Programming – Theory
OXUS 20
 

Similar to java swing (20)

PDF
Java goes wild, lesson 1
Thierry Wasylczenko
 
PPTX
basic core java up to operator
kamal kotecha
 
PPTX
Introduction_to_Java_Programming_2025.pptx
Yahya NOUALI
 
PDF
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
PDF
How to start developing apps for Firefox OS
benko
 
PPT
Java1
Lovepreet Kaur
 
PPT
Java1
denis diigula
 
PPT
01 java intro
Deepal Shah
 
PPTX
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
 
PPT
this_is_how_to_start_coding_in_java_lang.ppt
AhmedHamzaJandoubi
 
PDF
JavaScript Library Overview (Ajax Exp West 2007)
jeresig
 
PDF
Masterin Large Scale Java Script Applications
Fabian Jakobs
 
PPTX
1 java programming- introduction
jyoti_lakhani
 
PPTX
Hands on Gradle
Mushfekur Rahman
 
PPTX
Introduction to JAVA
Md. Tanvir Hossain
 
PDF
ITFT - Java Coding
Blossom Sood
 
KEY
MozTW Jetpack Workshop: Taipei
littlebtc
 
PPTX
Lesson1 intro
attiqrocket
 
PPTX
Lesson1 intro
attiqrocket
 
PPTX
Introduction to java
attiqrocket
 
Java goes wild, lesson 1
Thierry Wasylczenko
 
basic core java up to operator
kamal kotecha
 
Introduction_to_Java_Programming_2025.pptx
Yahya NOUALI
 
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
How to start developing apps for Firefox OS
benko
 
01 java intro
Deepal Shah
 
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
 
this_is_how_to_start_coding_in_java_lang.ppt
AhmedHamzaJandoubi
 
JavaScript Library Overview (Ajax Exp West 2007)
jeresig
 
Masterin Large Scale Java Script Applications
Fabian Jakobs
 
1 java programming- introduction
jyoti_lakhani
 
Hands on Gradle
Mushfekur Rahman
 
Introduction to JAVA
Md. Tanvir Hossain
 
ITFT - Java Coding
Blossom Sood
 
MozTW Jetpack Workshop: Taipei
littlebtc
 
Lesson1 intro
attiqrocket
 
Lesson1 intro
attiqrocket
 
Introduction to java
attiqrocket
 
Ad

Recently uploaded (20)

PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Ad

java swing

  • 1. Developing User Interfaces (DUI) Chris North cs3724: HCI
  • 2. GUI Development: Goals 1. Learn general GUI programming concepts • GUI components • Layout • Event-based programming • Graphics • Animation 2. Learn Java • Swing • Layout managers • Listerners • 2D graphics • Threads Then: can learn other languages quickly • VB, C#, Xwin, Java 49
  • 5. Java materials • Java 2 = sdk 1.2 or better • http://java.sun.com/j2se/ • Documentation: • http://java.sun.com/docs/ • Tutorials, reference, API • Borland JBuilder 6 • http://www.borland.com/jbuilder/personal/ • Free! Cross between VB and VC++
  • 6. Java differences • Basic statements identical to C++ • Object-oriented only! • No .h files • main() is inside a class • No global variables • No pointers (object references only) • No delete: automatic garbage collection • Single inheritance only, “interfaces” • Applet/application • GUI: AWT, Swing • Packaging • Error Handling, exceptions (try, catch) • E.g. Array bounds checking • Security • Components: beans
  • 7. Java compiling • Code: • hello.java (text file) • Compile: • javac hello.java • Creates: hello.class (byte code) • Run: • java hello • Java virtual machine, interpets/compiles (machine code) • Packaging: jar • Or use JBuilder, like VC++
  • 8. Java Applications • Run from command line • hello.java: class hello { public static void main(String[] args){ System.out.println(“Hello World!”); } } • javac hello.java • java hello Hello World!
  • 9. Typically create objects • hello.java: class hello { public static void main(String[] args){ // Create and use objects hello h = new hello(); … } public hello(){ // Constructor … } … }
  • 10. Many Classes • Compile each separately • Can be main( ) in any/all classes • hello.java: class hello { goodbye g; public static void main(String[] args){ … } • goodbye.java: class goodbye { public static void main(String[] args){ … }
  • 13. Java Applets • Run in a web browser • hello.java: import javax.swing.*; class hello extends JApplet { public void init(){ getContentPane().add( new JLabel(“Hello World!”) ); } } • javac hello.java Hello World! • appletviewer hello
  • 14. Java Applets in HTML • hello.html: <html><body> <applet code=“hello.class” height=100 width=200> Need java. </applet> </body></html> hello.html • Put hello.html and hello.class on website Hello World! • Java plug-in
  • 15. Applet Methods • init( ) - initialization • start( ) - resume processing (e.g. animations) • stop( ) - pause • destroy( ) - cleanup • paint( ) - redraw stuff (‘expose’ event)
  • 16. Applet Security • No read/write on client machine • Can’t execute programs on client machine • Communicate only with server • “Java applet window” Warning • Certificates
  • 17. Upcoming Java Topics • GUIs: Swing, AWT, MVC • Event handling, listeners • Graphics • Animation, threads • Components, JavaBeans • Databases, JDBC