SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Java Software Development Paradigm Lecture # 12. Basics of GUI.
JAVA API (GUI) Subject:T0934 / Multimedia Programming Foundation Session:1 Tahun:2009 Versi:1/0.
User Interface Design CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Event Handling Events and Listeners Timers and Animation.
Introduction to GUI Programming
THE SWING UI TOOLKIT Mostly from “The Swing Connection”The Swing Connection.
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
Object-Oriented Analysis and Design
Graphical User Interface (GUI) Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
Written by Liron Blecher
GUI Programming in Java
Swing part-one Eriq Muhammad Adams J
Software Construction Lecture 10 Frameworks
Welcome to CIS 083 ! Events CIS 068.
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
SWING IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 35 MVC and Swing MVC.
CSE1030-HR GUI The Big Picture Building the View Building the Controller Separating the Concerns Going Further.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
Java Applet. Introductions Applet is java program that can be embedded into HTML pages Java applets runs on the java enables web browsers such as mozila.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
Graphics in Java Dr. Andrew Wallace PhD BEng(hons) EurIng
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite of libraries to assist programmers create enterprise.
The Swing GUI Components Chapter 29 An enhanced alternative to AWT The PC does not need an appletviewer or browser Swing overcomes some AWT drawbacks.
Review_6 AWT, Swing, ActionListener, and Graphics.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Java Swing, Events Readings: Just Java 2: Chap 19 & 21, or Eckel’s Thinking in Java: Chap 14 Slide credits to CMPUT 301, Department of Computing Science.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Java Swing What is swing? Swing is a ”Lightweight” GUI ToolKit for Java Different from AWT / SWT Toolkits for GUIs Few lines of code to produce GUI elements.
A Quick Java Swing Tutorial
Provision for GUIs in Java
Provision for GUIs in Java
Lecture 8 Object Oriented Programming Using Java
Lecture 27 Creating Custom GUIs
Lecture 28 Concurrent, Responsive GUIs
A Quick Java Swing Tutorial
Introduction to Graphical Interface Programming in Java
Event Driven Programming and Graphical User Interface
תכנות מכוון עצמים בשפת JAVA
Building Graphical User Interface with Swing a short introduction
Steps to Creating a GUI Interface
Week 8 Swing NetBeans GUI Builder
A Quick Java Swing Tutorial
Model, View, Controller design pattern
Presentation transcript:

SWING 101

IF YOU GET LOST - IMPORTANT LINKS  Swing articles:  Swing Architecture:  Visual Editor for Eclipse:  Oracle Swing tutorial:  Stack Overflow:  Basic Swing tutorial:

SWING - HISTORY  UI  Platform specific  AWT (Advanced Windows Toolkit) was platform specific  Delegated creation of UI components to the OS  Heavy  Not customizable  Swing - Part of the JFC (Java Foundation Classes)  Extends (some of) AWT  Draws its own components  Light weight  Very customizable  All classes start with ‘J’ (JPanel, JButton, etc.)

UI FRAMEWORKS CONCEPTS  Events  A way for components (in general) to communicate with each other asynchronously (meaning, without directly calling methods on each other or using polling)  In java, it simply means that you register an interface (usually called a Listener) to an event generator and when an event generator wants to notify all the registered listeners it iterates over them calls methods define in them The parameter passed to the interface methods is an called an Event object  MVC (Model – View – Controller)  A model that represents the data for the application  The view that is the visual representation of that data  A controller that takes user input on the view and translates that to changes in the model

UI FRAMEWORKS CONCEPTS  UI runs in another thread called the EDT (Event Dispatch Thread)  This is done in order to make the UI responsive  Separate UI code from Business Logic code  User code can run in the EDT, but for long loops and actions (like network operations, database operations, etc.) it is usually preferred to run the code in another thread  In order to run a code in the EDT (after a thread has finished its work) use: SwingUtilities.invokeLater()

(J)COMPONENT IN SWING  JComponents (extends Container)  JButton, JLabel, JTable, JTree, JCheckBox, etc.  Containers  Components that groups other components and other containers  Can be used with Layout Manager to automatically set the size and location of their child components  Top Level Containers  The root objects for swing application  At least one is mandatory for the application to start  JFrame, JDialog, JApplet, JWindow

(J)COMPONENT IN SWING  JComponents have the following capabilities:  Properties (such as color, preferred size)  Methods (for getting and setting data like setText(), etc.)  Events (a component might send more that one type of event)

(J)COMPONENT IN SWING  All the components (from AWT or from Swing) have properties that changes how the component looks and behaves  You can register different types of Event Listeners to a component in order to receive events from it (for example: MouseEvent on a JPanel, ChangeEvent on a JCheckBox, etc.)  Some components have several Models in them for different data: a JList component have a Selection Model that represents the current selected items in the component (and you can register a listener for that as well)  All components have a ‘paintComponent’ method that actually tell the JVM how to draw the component. Overwriting this method is done for advanced cases…

SWING COMPONENTS HIERARCHY  Tutorial   Components   Layout 