SlideShare una empresa de Scribd logo
1 de 17
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

Más contenido relacionado

La actualidad más candente

Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVAKUNAL GADHIA
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java TutorialJava2Blog
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming Saravanakumar R
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruNithin Kumar,VVCE, Mysuru
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)Sujit Majety
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Java Lover
 
Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaAjay Sharma
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART IOXUS 20
 
Java introduction
Java introductionJava introduction
Java introductionSagar Verma
 
Advanced programming ch1
Advanced programming ch1Advanced programming ch1
Advanced programming ch1Gera Paulos
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryOXUS 20
 

La actualidad más candente (20)

04b swing tutorial
04b swing tutorial04b swing tutorial
04b swing tutorial
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Learn Java Part 1
Learn Java Part 1Learn Java Part 1
Learn Java Part 1
 
Introduction to Java Programming
Introduction to Java Programming Introduction to Java Programming
Introduction to Java Programming
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java. converted (2)
Java. converted (2)Java. converted (2)
Java. converted (2)
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java introduction
Java introductionJava introduction
Java introduction
 
Advanced programming ch1
Advanced programming ch1Advanced programming ch1
Advanced programming ch1
 
Java basic introduction
Java basic introductionJava basic introduction
Java basic introduction
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – Theory
 

Similar a java swing

basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operatorkamal kotecha
 
How to start developing apps for Firefox OS
How to start developing apps for Firefox OSHow to start developing apps for Firefox OS
How to start developing apps for Firefox OSbenko
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)jeresig
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsFabian Jakobs
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
 
ITFT - Java Coding
ITFT - Java CodingITFT - Java Coding
ITFT - Java CodingBlossom Sood
 
MozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: TaipeiMozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: Taipeilittlebtc
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaattiqrocket
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentationjuliasceasor
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
 
MozTW Jetpack Workshop: Taichung
MozTW Jetpack Workshop: TaichungMozTW Jetpack Workshop: Taichung
MozTW Jetpack Workshop: Taichunglittlebtc
 

Similar a java swing (20)

Java goes wild, lesson 1
Java goes wild, lesson 1Java goes wild, lesson 1
Java goes wild, lesson 1
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
How to start developing apps for Firefox OS
How to start developing apps for Firefox OSHow to start developing apps for Firefox OS
How to start developing apps for Firefox OS
 
Java1
Java1Java1
Java1
 
Java1
Java1Java1
Java1
 
01 java intro
01 java intro01 java intro
01 java intro
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Hands on Gradle
Hands on GradleHands on Gradle
Hands on Gradle
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
ITFT - Java Coding
ITFT - Java CodingITFT - Java Coding
ITFT - Java Coding
 
MozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: TaipeiMozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: Taipei
 
Lesson1 intro
Lesson1 introLesson1 intro
Lesson1 intro
 
Lesson1 intro
Lesson1 introLesson1 intro
Lesson1 intro
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
 
MozTW Jetpack Workshop: Taichung
MozTW Jetpack Workshop: TaichungMozTW Jetpack Workshop: Taichung
MozTW Jetpack Workshop: Taichung
 

Último

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Último (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

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