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.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

User Interfaces II GUI – Awt, Swing, Web
Things to mention public static void main(String [] args) –The starting point for a free-standing Java application (i.e. one not run from the DrJava interactions.
User Interface Design CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
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.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
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.
Scott Grissom, copyright 2006Ch 11: GUI Slide 1 Graphical User Interfaces (Ch 11) Careful design of a graphical user interface is key to a viable software.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
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 
GUI Programming in Java
Java Programming Chapter 10 Graphical User Interfaces.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
Software Construction Lecture 10 Frameworks
GUIs for Applets Introduction Applets and Swing/JFC Alternatives to Swing Look-and-Feel issues Example applet graphical user interfaces.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
Java GUI building with Swing. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Introduction to Swing Components Chapter 14.  Part of the Java Foundation Classes (JFC)  Provides a rich set of GUI components  Used to create a Java.
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.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
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
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
Programming with Java’s Swing API February 4, 2003 CMPS Advanced Programming Graphical User Interfaces.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Swing / Session1 / 1 of 30 Module Introduction Distributed Computing in Java.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
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.
1 Chapter 16: Creating Windows. 2 Basics of GUI Programming How to create a Window. TryWindow.java You always need a JFrame component before creating.
Java GUI COMP 401 Fall 2014 Lecture 16 10/20/2014.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
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.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Chapter 6 Building Java GUIs. MVC Model View Controller The model passes its data to the view for rendering The view determines which events are passed.
GUI 1: JFC and Swing Basics OOP tirgul No
A Quick Java Swing Tutorial
Graphical User Interfaces
Provision for GUIs in Java
A First Look at GUI Applications
Advanced GUI Programming
Graphical User Interface (pronounced "gooey")
Lecture 27 Creating Custom GUIs
University of Central Florida COP 3330 Object Oriented Programming
Ellen Walker Hiram College
Event Driven Programming and Graphical User Interface
GUIS: Graphical User Interfaces
תכנות מכוון עצמים בשפת JAVA
Basic Elements of The GUI
Week 8 Swing NetBeans GUI Builder
Graphical User Interface
Presentation transcript:

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 (IOC) AWT/SWT AWT/SWT ”Heavyweight” Layer of abstraction over native GUI calls Looks like native applications Swing Uses Graphics2D to 'draw' components on the screen Uses the 'Look and Feel' manager to determine the appearance of the GUI. System invariant

Class Structure Every class in swing is a Component. Each class follows the following structure (except for top level containers) java.lang.Object java.awt.Component java.awt.Container java.awt.JComponent javax.swing.* This structure allows for Nesting containers within containers Each component can implement its own look

Division of Components Containers, Displays, Input Top Level Containers JApplet, JDialog, JFrame

Division of Components General Purpose Containers JPanel, JScrollPane, JToolBar...

Division of Components Basic Controls (Input) JButton, JCheckBox, JTextField, JMenu...

Division of Components Interactive Display JTable, JFileChooser, JTextArea, JTree...

Division of Components Uneditable Information Displays JLabel, JProgressBar, JSeparator

Look and Feel Swing does not rely on native GUI calls Draws all GUI components with own libraries Look and Feel choice defines presentation

Layout Manager Programming vs. Layout Design Built in Layouts help provide solutions for various simple GUI scenarios I need to display some buttons in a row I need to display elements in a grid I need elements to expand if they get bigger I need there to be a constant spacing I have many components which need to be placed in arbitrary locations I want my components to move as the window is resized

Layout Manager Examples

Event Handlers How does Swing handle input events? Components require Listeners and Handlers to execute code when an input has been received Examples: MouseListener, KeyListener Event objects contain information about the event such as (x,y) loc, Button Pressed, Keyboard key pressed A function is defined which is to be performed upon the event happening (ActionEvent)

Graphics & Animation Graphics can be drawn in real time Graphics2D has many built in draw functions DrawLine, Primitives, Fill, SetPaint Implemented as a Component which can be added like any other element of Swing Animation can be achieved by implementing the component as a thread, and redrawing with updated parameters