GUI Elements Session 17. Memory Upload Layout Components Button TextField TextArea Label Choice Containers Panels The applet itself.

Slides:



Advertisements
Similar presentations
1 Graphical User Interface (GUI) Applications Abstract Windowing Toolkit (AWT) Events Handling Applets.
Advertisements

Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Objectives The objectives of this chapter are: To discuss the classes present in the java.awt package To understand the inheritance hierarchy of the AWT.
Unit 121 A layout manager is an object that determines the manner in which components are arranged in a container. Each layout manager implements one of.
Windowsun Grafik Kullanıcı Arabirimi GUI. Graphical User Interfaces.
CE203 - Application Programming Autumn 2013CE203 Part 71 Part 7.
Graphical User Interfaces
TCU CoSc Programming with Java Visual Design (Chapter 5)
Java Software Development Paradigm Lecture # 12. Basics of GUI.
AWT Components. 2 Using AWT Components 4 Component –Canvas –Scrollbar –Button –Checkbox –Label –List –Choice –TextComponent –TextArea –TextField 4 Component.
Graphic User Interfaces Layout Managers Event Handling.
F27SB2 Programming Languages
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.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 20, 2005.
More Advanced AWT Last week, you learned about Applets, Lists, and Buttons AWT provides several other “widgets” and tools: –Labels –Choice boxes –Check.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 9 Object Oriented Programming in Java Advanced Topics Abstract Windowing.
1 Simple Phone Applet Lab Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
LAB SESSION 10 *LAYOUT MANAGER *LISTENERS. Laying the components manually by using a null layout is tedious. Each container object has a layout manager.
Jan Containers Yangjun Chen Dept. Business Computing University of Winnipeg.
COMP 14 Introduction to Programming Miguel A. Otaduy June 7, 2004.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Java GUI building with the AWT. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many.
Applets, AWTS CompSci 230 Software Construction.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
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 On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
JAPPLET.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Graphical User Interface CSI 1101 N. El Kadri. Plan - agenda Graphical components Model-View-Controller Observer/Observable.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 12.
Java GUI building with Swing. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Adding Graphics to a Frame Application Applets: Can generate drawings by overriding paint Frame: Do not draw directly on a frame. Draw graphics on a JPanel.
Timer in Java javax.swing.Timer – (getDelay, setDelay, setRepeats, isRepeats, start, stop, isRunning; ActionListner: actionPerformed) JProgressBar – (getMinimum,
Layout Managers Arranges and lays out the GUI components on a container.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
Java Programming Applets. Topics Write an HTML document to host an applet Understand simple applets Use Labels with simple AWT applets Write a simple.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
Csc Basic Graphical User Interface (GUI) Components.
AWT Layout Managers (Chapter 10) Java Certification Study Group January 21, 1999 Mark Roth.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 3 Designing the Interface with Layout Managers.
Graphical User Interfaces (GUI). PART ONE About GUI’s.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
CSI 3125, Preliminaries, page 1 Layout Managers. CSI 3125, Preliminaries, page 2 Layout Managers The LayoutManagers are used to arrange components in.
Java Layouts CSIS 3701: Advanced Object Oriented Programming.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Event Handler Methods Text field Object Responder JAVA AWT Environment: Messages are sent between JAVA Objects Screen Event Notification Press Button.
Applets. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L12: Applets Slide 2 Applets Usually.
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
AWT Vs SWING. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses.
Chapter 7 A First Look at GUI Applications Layout Managers.
Modern Programming Language Java
Tim McKenna Layout Mangers in Java Tim McKenna
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Containers and Components
Tim McKenna Layout Mangers in Java Tim McKenna
Creating Graphical User Interfaces
GUI building with the AWT
GUI Layouts By: Leonard & Saif.
GUI building with the AWT
Advanced GUIs and Graphics
Presentation transcript:

GUI Elements Session 17

Memory Upload Layout Components Button TextField TextArea Label Choice Containers Panels The applet itself

Applet Methods init start end destroy

Components / Containers container Component

Layout The basic setup for any container FlowLayout BorderLayout GridLayout

FlowLayout Elements Added From left to right From top to bottom Alignment Center

FlowLayout Create a FlowLayout object. The constructor Set the Layout FlowLayout fl = new FlowLayout( ); setLayout(fl); //or Container.setLayout(fl); this

Button The constructor The parameter a String –the button caption Button b1 = new Button(OK); Button b2 = new Button( OK );

Button import java.applet.*; import java.awt.*; public class FlowButtons extends Applet{ public void init( ) { FlowLayout fl = new FlowLayout( ); setLayout(fl); Button b1 = new Button("OK"); add(b1); } }

Button import java.applet.*; import java.awt.*; public class FlowButtons extends Applet{ public void init( ) { Button b1 = new Button("OK"); add(b1); } }

FlowLayout with Button OK

BorderLayout Elements Added In the assigned area Areas North South East West Center

BorderLayout One Component/Container per spot

Buttons BorderLayout BorderLayout bl = new BorderLayout( ); this.setLayout(bl); Button bN = new Button(north"); Button bS = new Button(south"); Button bC = new Button(center); Button bE = new Button(east"); Button bW = new Button(west"); this.add(Center, bC); this.add(North, bN); this.add(South, bS); this.add(East, bE); this.add(West, bW);

Buttons BorderLayout One Component/Container per spot north south west east center

GridLayout Elements Added From left to right From top to bottom Parameters Row Column

Buttons GridLayout setLayout(new GridLayout(2,2)); Button b1 = new Button("1"); Button b2 = new Button("2"); Button b3 = new Button("3"); Button b4 = new Button("4"); add(b1); add(b2); add(b3); add(b4); this.

Buttons GridLayout 12 34

TextField For user data entry or program information display Two constructors: They are placed just as any other component/container TextField tf = new TextField(String); TextField tf = new TextField(int);

TextArea For user data entry or program information display Two constructors: They are placed just as any other component/container TextArea ta= new TextArea(String); TextArea ta = new TextArea(int, int);

Label To label GUI elements One constructor: They are placed like any other component/ container Label lab = new Label(String);

Choice Give users controlled choices One constructor: After creating the Choice, items must be added. Choice ch = new Choice( ); ch.add(String);

Choice Java is zero based Items are added in order They are placed like any other component / container Choice ch = new Choice( ); ch.add(zero); ch.add(one); ch.add(two); zero

Choice Java is zero based Items are added in order They are placed like any other component / container Choice ch = new Choice( ); ch.add(zero); ch.add(one); ch.add(two); zero one two

Panel The Panel is a container The constructor Each Panel can have its own Layout Panel p = new Panel( ); BorderLayout bl = new BorderLayout( ); p.setLayout(bl);

Panel There can be many Panels inside an applet Panels can be nested Follow the rule: One Component/Container per spot

Panel The applet BorderLayout bl = new BorderLayout( ); this.setLayout(bl);

Panel Panel pTop = new Panel( ); GridLayout gl = new GridLayout(5,1); pTop.setLayout(gl); this.add(North, pTop);

Panel OKNO ICS111 Button b1 = new Button (OK); Label num = new Label (111); Label area = new Label(ICS); Label blank = new Label( ); Button b2 = new Button(NO); pTop.add(blank); pTop.add(area); pTop.add(num); pTop.add(b1); pTop.add(b2);

Panel OKNO ICS111 Panel pCenter = new Panel( ); BorderLayout blCtr = new BorderLayout( ); this.add(Center, pCenter);

Panel You can have as many panels as you want inside one another You can have a different layout on each panel

GUI Plan the looks before you code

Applet posting review Steps Plan your GUI Write your java code in the public_html directory Compile your code Change the class mode to 644

Applet posting review Steps Write your html page Change the html page mode to 644 Visit your applet on the web Use the java console for immediate feedback!

Time to Try it Out Applets And GUI

Components / Containers Different Components Panels Nesting Panels Posting and Viewing Applets any questions to Memory Defragmenter

Task Manager Answer 4 questions on WebCT Read your Visit WebCT, webct.hawaii.edu

Task Manager Answer 4 questions on WebCT Read your Visit WebCT, webct.hawaii.edu