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.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Graphical User Interfaces (Part IV)
Introduction to JFC Swing Written by Adam Carmi. Agenda About JFC and Swing Pluggable Look and Feel Swing Components Borders Layout Management Events.
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.
 Pearson Education, Inc. All rights reserved GUI Components: Part 2.
Event Handling Events and Listeners Timers and Animation.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
Swinging Into Swing Leo S. Primero III. Understanding what Swing Is Swing is a package that lets you create applications that use a flashy Graphical User.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
GUI and Event-Driven Programming Part 2. Event Handling An action involving a GUI object, such as clicking a button, is called an event. The mechanism.
1 L46 Advanced GUI Component (1). 2 OBJECTIVES  To create and manipulate sliders, and menus,
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
More on Creating GUIs in Java using Swing David Meredith Aalborg University.
By: Mr. Baha Hanene Chapter 05. LEARNING OUTCOMES This chapter will cover the learning outcome L02, L03 Partially & L05 Completely. Design presentations.
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.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
CS377A: A Programming Approach to HCI Jan Borchers Spring Swing Refresher David Merrill 5/14/2002
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
Dale Roberts GUI Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
– 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.
1 Unit 5 GUI Aum Amriteshwaryai Namah. 2 Overview Shall learn how to reuse the graphics classes provided by Java for constructing Graphical User Interface.
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.
Introduction to Windows Created by Mrs. Leverette.
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
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.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Field Trip #22 Creating an Excel Spreadsheet with Java By Keith Lynn.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Chapter Eleven The X Window System. 2 Lesson A Starting and Navigating an X Window System.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
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.
Creating User Interfaces Chapter 13 CSCI CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 14: Introduction to Swing Components. Objectives Understand Swing components Use the JFrame class Use the JLabel class Use a layout manager Extend.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
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.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
Menus Pull-downs and popups. Tooltips –a ToolTip is a context-sensitive text string that is displayed in a popup window when the mouse rests over a particular.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Module 13: Swing API Object Oriented Programming(Java)
Advanced User Interfaces
Java Swing.
Chap 7. Building Java Graphical User Interfaces
Advanced Programming in Java
Constructors, GUI’s(Using Swing) and ActionListner
Presentation transcript:

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 pluggable look-and-feel.  To create a multiple-document interface with JDesktopPane and JInternalFrame.

JPopupMenu Context-sensitive pop-up menus – Provide options that are specific to the component for which the pop-up trigger event was generated On most systems, the pop-up trigger event occurs when the user presses and releases the right mouse button – Created with class JPopupMenu

4 Outline PopupFrame.java (1 of 4) An instance of class ItemHandler will process the item events from the menu items

5 Outline PopupFrame.java (2 of 4) Create a JPopupMenu object Create and add JRadioButtonMenuItem and register ActionListener s Register a MouseListener to handle the mouse events of the application window

6 Outline PopupFrame.java (3 of 4) If the pop-up trigger event occurred, JPopupMenu method show displays the JPopupMenu Origin component and coordinates arguments determine where the JPopupMenu will appear

7 Outline PopupFrame.java (4 of 4) Determine which JRadioButtonMenuItem the user selected and set the background color

8 Outline PopupTest.java

Pluggable Look-and-Feel Java applications’ appearances – A program that uses Java’s Abstract Window Toolkit GUI components takes on the look-and-feel of the platform Allows users of the application on each platform to use GUI components with which they are already familiar Also introduces interesting portability issues – Swing’s lightweight GUI components provide uniform functionality Define a uniform cross-platform look-and-feel (known as the metal look-and-feel) Also can customize the look-and-feel to appear as a Microsoft Windows-style, Motif-style (UNIX) or Macintosh look-and- feel

10 Outline LookAndFeelFrame.java (1 of 4)

11 Outline LookAndFeelFrame.java (2 of 4)

12 Outline LookAndFeelFrame.java (3 of 4) Get the array of UIManager.LookAndFeelInfo objects that describe each look-and-feel available on your system Invoke static method setLookAndFeel to change the look-and-feel Invoke static method updateComponentTreeUI to change the look-and-feel of every GUI component attached to the application

13 Outline LookAndFeelFrame.java (4 of 4) Call utility method changeTheLookAndFeel

14 Outline LookAndFeelDemo.java (1 of 2)

15 Outline LookAndFeelDemo.java (2 of 2)

JDesktopPane and JInternalFrame Multiple-document interface – A main window (called the parent window) contains other windows (called child windows) – Manages several open documents that are being processed in parallel – Implemented by Swing’s JDesktopPane and JInternalFrame

17 Outline DeskTopFrame.java (1 of 4) Create a JMenuBar, a JMenu and a JMenuItem

18 Outline DeskTopFrame.java (2 of 4) Add the JMenuItem to the JMenu and the JMenu to the JMenuBar and set the JMenuBar for the application window The JDesktopPane will be used to manage the JInternalFrame child windows Create a JInternalFrame object Constructor arguments specify title bar string and whether or not the user can resize, close, maximize and minimize the internal frame Set the size of the child window

19 Outline DeskTopFrame.java (3 of 4) Add the JInternalFrame to theDesktop and display the JInternalFrame

20 Outline DeskTopFrame.java (4 of 4) Specify the panel’s preferred size for use by the pack method

21 Outline DeskTopTest.java (1 of 3)

22 Outline DeskTopTest.java (2 of 3) Internal Frames Minimize Maximize Close Minimized internal frames Position the mouse over any corner of a child window to resize the window (if resizing is allowed).

23 Outline DeskTopTest.java (3 of 3) Maximized internal frame

JTabbedPane JTabbedPane – Arranges GUI components into layers in which only one layer is visible at a time When the user clicks a tab, the appropriate layer is displayed – The tabs can be positioned at top (default), left, right or bottom – Any component can be placed on a tab – If the tabs do not fit on one line, they will wrap to form additional lines of tabs

25 Outline JTabbedPaneFrame.java (1 of 2) Create an empty JTabbedPane with default settings Call JTabbedPane method addTab with arguments that specify the tab’s string title, an Icon reference to display on the tab, the COMPONENT to display when the user clicks on the tab and the tab’s tooltip string

26 Outline JTabbedPaneFrame.java (2 of 2) Add panel2 to tabbedPane Add panel3 to tabbedPane

27 Outline JTabbedPaneDemo.java