עקרונות תכנות מונחה עצמים תרגול 5 - GUI. בשיעור הקודם :  Introduction to GUI  Swing  Basic components  Event handling.

Slides:



Advertisements
Similar presentations
G5BUID - Java Swing Laying out components Manage realized components Determine size and position Each container has a layout manager (usually)
Advertisements

Java Software Development Paradigm Lecture # 12. Basics of GUI.
Graphic User Interfaces Layout Managers Event Handling.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
 What are the basic GUI components we’ve learned so far? › JFrame › JPanel › JButton › JLabel › JTextArea › JTextField › JCheckBox › JRadioButton › Paint.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 28 Containers, Layout.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Swing Toolkit Graphics The key to effectively using graphics in Java is understanding: –the basic components of the graphics library –the patterns.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
Swing CS-328 Dick Steflik John Margulies. Swing vs AWT AWT is Java’s original set of classes for building GUIs Uses peer components of the OS; heavyweight.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
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.
Java Swing © Walter Milner 2005: Slide 1 Java Swing Walter Milner.
Using Inheritance to Customize Frames Use inheritance for complex frames to make programs easier to understand Design a subclass of JFrame Store the components.
Layout Managers A layout manager is an object that determines the way that components are arranged in a container There are several predefined layout managers.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
CSE 219 Computer Science III Graphical User Interface.
CS377A: A Programming Approach to HCI Jan Borchers Spring Swing Refresher David Merrill 5/14/2002
Java GUIs and Graphics CNS Outline  Introduction  Events  Components  Layout managers  Drawing  Introduction  Events  Components  Layout.
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
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: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
עקרונות תכנות מונחה עצמים תרגול 6 - GUI. סיכום ביניים GUI:  Swing  Basic components  Event handling  Containers  Layouts.
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:
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.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Layout Manager Summary
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
University of Limerick1 Software Architecture Java Layout Managers.
IM103 week 11 Part 2 P532 Case Study part 2: the Airport GUI Learning objectives By the end of this lecture you should be able to:  use the JTabbedPane.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
עקרונות תכנות מונחה עצמים תרגול 6 - GUI. Outline  Game of Life  Painting.
Review_6 AWT, Swing, ActionListener, and Graphics.
JSplitPane & JTabbedPane
Graphical User Interfaces are Trees CS1316: Representing Structure and Behavior.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
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.
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
GUI I IS Outline  Quiz  Quiz solution  GUI components  Layout.
Java Swing - Lecture 3 Layout Management
1CS480: Graphical User Interfaces. Dario Salvucci, Drexel University. Lecture 3: Layout Basics.
XP IT INSTRUCTOR :AHMAD HIRZALLAH 1 Microsoft Office FrontPage 2003 Creating Tables and Frames.
1 CSE 331 Composite Layouts; Decorators slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Graphical User Interface (GUI)
Developing GUIs With the Eclipse Visual Editor, Swing/AWT Edition David Gallardo.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
Frame Windows Application program, not applet Construct and show frame JFrame frame = new JFrame(); *** frame.show(); *** Set default close operation..
Advanced Topics on Graphical User Interfaces CardLayout JTabbedPane JFrame.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Notes for Assignment #2 Assn2: GUI Database Interface Corresponds with Chapters 28, 29, 31.
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.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 5 1 Microsoft Office FrontPage 2003 Tutorial 5 – Creating Tables and Frames.
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Chapter 2 – Introduction to the Visual Studio .NET IDE
Graphical user interface with Swing by jose maria gonzalez pinto
Chap 7. Building Java Graphical User Interfaces
עקרונות תכנות מונחה עצמים
Layout Managers A layout manager is an object that determines the way that components are arranged in a container There are several predefined layout managers.
Graphical User Interfaces -- Introduction
עקרנות תכנות מונחה עצמים
תכנות מכוון עצמים בשפת JAVA
Creating Graphical User Interfaces
Presentation transcript:

עקרונות תכנות מונחה עצמים תרגול 5 - GUI

בשיעור הקודם :  Introduction to GUI  Swing  Basic components  Event handling

Outline  Containers  Layouts  Advanced examples

Top-Level Containers  Swing uses tree top-level contauners:

Top-Level Containers

General-Purpose Containers JPanel  Contains other components (JButton,JLabel,…)  Can be contained by Top-Level Containers  We can set its own features such as Background Color, Layout, size,etc... JPanel buttonPanel = new JPanel( new FlowLayout()); buttonPanel.setBackground(Color.magenta); buttonPanel.add(convertButton); buttonPanel.add(resetButton); buttonPanel.add(changeButton); getContentPane().add(buttonPanel);

General-Purpose Containers Scroll Pane  Takes another component(the ViewportView) and displays it with scrollers (if necessary) textArea = new JTextArea(10,30); JScrollPane sp = new JScrollPane(textArea); …

General-Purpose Containers Split Pane  Takes two component and displays them with a moveable splitter in the middle splitPane = new JSplitPane(Jsplitpane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setDividerLocation(150);

General-Purpose Containers Tabbed Pane  Can be given any number of components as tabs by using addTab JTabbedPane tp = new JTabbedPane(); Tp.addTab(“Tab 1”, icon, panel1);

General-Purpose Containers Toolbar  Lays out buttons conveniently

Layouts

Simple Layouts

Example 1 PIZZA PANEL

Example 1: Pizza panel

The Pizza Class

Recalculating

Making Spinners

Making Checkboxes

Making the Frame

Toppings Panel

Cost Panels

Wrapping Up the Frame

Advanced Layouts Spring Layout  Allows specifying distances between pairs of components (“springs”)

Spring Layout

Advanced Layouts GridBag Layout  Like grid, but inner components can span over several cells and respond differently to re-sizing.

GridBag Constraints

Desigging GridBag Layouts

Example 2 Personal Details Panel

Reminder: Gridbag Constaints

Personal Details Panel

Personal Details Panel Constructor

Prototype Constraints

Name and Surname

Gender Panel

Age Spinner

Address

Comments Panel

Putting in all together

Layout Considerations What to consider when planning a layout?  Not distorted by resize  Aligned, visually attractive  Put important data in the center, auxiliaries on the sides  Flexible, user-controlled  Usable