CS377A: A Programming Approach to HCI Jan Borchers Spring 20021 Swing Refresher David Merrill 5/14/2002

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Graphical User Interfaces (Part IV)
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
Events ● Anything that happens in a GUI is an event. For example: – User clicks a button, presses return when typing text, or chooses a menu item ( ActionEvent.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
More Swing (Chapter 14)‏ CS 180 Recitation - April 18, 2008 Department of Computer Science Purdue University.
Object-Oriented Software Engineering Java with added Swing.
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 L47 Advanced GUI Component (2). 2 OBJECTIVES  To create and manipulate pop-up menus and windows.  To change the look-and-feel of a GUI, using Swing's.
Advanced Java Class GUI, part 2. JComponent methods addXXXListener(XXXListener) repaint() – [optional arguments: delay and coordinates of sub-area to.
More on Creating GUIs in Java using Swing David Meredith Aalborg University.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Java Swing © Walter Milner 2005: Slide 1 Java Swing Walter Milner.
7-Oct-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic : User Interface Components with.
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Java Programming 1 Java Programming II Events, AWT, and Swing.
1CS 338: Graphical User Interfaces. Dario Salvucci, Drexel University. Lecture 15: Menus, Toolbars, and Text.
Copyright © 2002, Systems and Computer Engineering, Carleton University Gui1.ppt * Object-Oriented Software Development Part 18 Building.
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
GUI in Java. Graphical User Interface Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides users with basic level of.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
FEN IntroJava2006 AAU1 GUI: Graphical User Interface AWT/SWING: Components Drag and Drop in NetBeans Events Listeners.
GUI Clients 1 Enterprise Applications CE00465-M Clients with Graphical User Interfaces.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Java Programming: Advanced Topics 1 Components and Facilities for Rich Graphical User Interfaces Chapter 7.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
1 Java Swing - Lecture 2 Components and Containment Boriana Koleva
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
OOP (Java): GUI Intro/ OOP Objectives – –use an image viewer application to introduce Java's GUI features Semester 2,
Programming with Java’s Swing API February 4, 2003 CMPS Advanced Programming Graphical User Interfaces.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
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.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
Swing Components. Introduction Swing – A set of GUI classes – Part of the Java's standard library –Much better than the previous library: AWT Abstract.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
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 - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
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.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
Basics of GUI Programming Chapter 11 and Chapter 22.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
Java Swing One of the most important features of Java is its ability to draw graphics.
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.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the 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.
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. Note - this presentation.. often needs to refer to source code which is too big to put on a slide So the source code is in a separate Word.
Module 13: Swing API Object Oriented Programming(Java)
Welcome To java
Advanced User Interfaces
Java Look-and-Feel Design Guidelines
Introduction to Graphical Interface Programming in Java
1 Graphical User Interfaces
Presentation transcript:

CS377A: A Programming Approach to HCI Jan Borchers Spring Swing Refresher David Merrill 5/14/2002

CS377A: A Programming Approach to HCI Jan Borchers Spring What is Swing? The Java Foundation Classes (JFC) API extends the original Abstract Window Toolkit (AWT) by adding a comprehensive set of graphical user interface class libraries. JFC/Swing components include: Pluggable Look and Feel Accessibility API Java 2DTM API (Java 2 only) Drag and Drop (Java 2 only) AWT Internationalization

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Written in the Java programming language Customizable look-and-feel No reliance on the native windowing system Incorporated in the Java 2 platform

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Applet DialogFrame Top-Level Containers

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Scroll Pane Split Pane Tabbed Pane General-Purpose Containers Toolbar Panel

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Internal Frame Layered Pane Root Pane Special-Purpose Containers

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Buttons Combobox List Basic Controls Menu Slider Text Fields

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Label Progress Bar Tooltip Uneditable Information Displays

CS377A: A Programming Approach to HCI Jan Borchers Spring JFC/Swing GUI Components Table Text Tree Editable Displays of Formatted Information Color ChooserFile Chooser

CS377A: A Programming Approach to HCI Jan Borchers Spring JFrame public static void main(String s[]) { JFrame frame = new JFrame("FrameDemo"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); //...create a blank label, set its preferred size... frame.getContentPane().add(emptyLabel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }

CS377A: A Programming Approach to HCI Jan Borchers Spring JTabbedPane ImageIcon icon = new ImageIcon("images/middle.gif"); JTabbedPane tabbedPane = new JTabbedPane(); Component panel1 = makeTextPanel("Blah"); //(returns a JPanel ) tabbedPane.addTab("One", icon, panel1, "Does nothing"); tabbedPane.setSelectedIndex(0); Component panel2 = makeTextPanel("Blah blah"); tabbedPane.addTab("Two", icon, panel2, "Does twice as much nothing"); Component panel3 = makeTextPanel("Blah blah blah"); tabbedPane.addTab("Three", icon, panel3, "Still does nothing"); Component panel4 = makeTextPanel("Blah blah blah blah"); tabbedPane.addTab("Four", icon, panel4, "Does nothing at all");

CS377A: A Programming Approach to HCI Jan Borchers Spring JTabbedPane ImageIcon icon = new ImageIcon("images/middle.gif"); JTabbedPane tabbedPane = new JTabbedPane(); Component panel1 = makeTextPanel("Blah"); //(returns a JPanel ) tabbedPane.addTab("One", icon, panel1, "Does nothing"); tabbedPane.setSelectedIndex(0); Component panel2 = makeTextPanel("Blah blah"); tabbedPane.addTab("Two", icon, panel2, "Does twice as much nothing"); Component panel3 = makeTextPanel("Blah blah blah"); tabbedPane.addTab("Three", icon, panel3, "Still does nothing"); Component panel4 = makeTextPanel("Blah blah blah blah"); tabbedPane.addTab("Four", icon, panel4, "Does nothing at all");

CS377A: A Programming Approach to HCI Jan Borchers Spring JGlassPane private void redispatchMouseEvent(MouseEvent e, boolean repaint) { // get the point from the MouseEvent int eventID = e.getID(); if (containerPoint.y < 0) { inMenuBar = true; //...set container and containerPoint accordingly... testForDrag(eventID); } component = SwingUtilities.getDeepestComponentAt( container, containerPoint.x, containerPoint.y); if (component.equals(liveButton)) { inButton = true; testForDrag(eventID); } if (inMenuBar || inButton || inDrag) {...//Redispatch the event to component... } Etc…

CS377A: A Programming Approach to HCI Jan Borchers Spring JMenuBar //in the constructor for a JFrame subclass: JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem; JCheckBoxMenuItem cbMenuItem; JRadioButtonMenuItem rbMenuItem;... //Create the menu bar. menuBar = new JMenuBar(); setJMenuBar(menuBar); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item",KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription(“This doesn't really do anything"); menu.add(menuItem);

CS377A: A Programming Approach to HCI Jan Borchers Spring URL