Lecture 16: GUI programming JFrame windows (p.247) Containers and layout managers (p.290) Inheriting GUI components (p.330) Chapter 12: GUI programming.

Slides:



Advertisements
Similar presentations
GridLayout, n*m grid. Column width/row height adjusted to fith the widest/highest Component.
Advertisements

Graphical User Interfaces
Java Software Development Paradigm Lecture # 12. Basics of GUI.
F27SB2 Programming Languages
Problem Solving 6 GUIs and Event Handling ICS-201 Introduction to Computing II Semester 071.
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.
Graphical User Interfaces CS 2110 Spring Ivan Sutherland: “Sketchpad”,
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
Corresponds with Chapter 12
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
GUI programming AWT(Abstract Windows Toolkit)-GUI components library when Java was introduced AWT was replaced by Swing components import javax.swing.*;
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Swing Components III Chapter 12 - Student JFrame, Component Methods.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L03 (Chapter 15) Creating.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
CSE 219 Computer Science III Graphical User Interface.
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Standard Graphics in Java.
GUI Chapter 10 Graphics context and objects Creating a window based application JFrame, JTextField, JButton Containers and Controls Graphics commands Layout.
10/24/20151 Java GUI Programming. 10/24/20152 What is a GUI? Java has standard packages for creating custom Graphical User Interfaces Some of the fundamental.
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.
CompSci 100E 35.1 Graphical User Interfaces: GUIs  Components  Flat Layouts  Hierarchical Layouts  Designing a GUI  Coding a GUI.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
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.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
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.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
University of Limerick1 Software Architecture Java Layout Managers.
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.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
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.
Basics of GUI Programming Chapter 11 and Chapter 22.
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.
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.
Programming 2 LAB TA: Nouf Al-Harbi NoufNaief.net :::
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
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.
Graphical User Interface (GUI)
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
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.
GUI.1 Graphical User Interfaces GUIs. GUI.2 The Plan Components Flat Layouts Hierarchical Layouts Designing a GUI Coding a GUI.
Graphical User Interfaces
Java GUI.
Graphical User Interface (pronounced "gooey")
Graphical user interface with Swing by jose maria gonzalez pinto
Chapter 13: Advanced GUIs and Graphics
תכנות מכוון עצמים בשפת JAVA
Steps to Creating a GUI Interface
Week 8 Swing NetBeans GUI Builder
Advanced Programming in Java
Chapter 12 GUI Basics.
Advanced GUIs and Graphics
Graphical User Interface
Presentation transcript:

Lecture 16: GUI programming JFrame windows (p.247) Containers and layout managers (p.290) Inheriting GUI components (p.330) Chapter 12: GUI programming Skip Chapters 10 and 11 for now but will return to them soon

JFrame Windows (p.247) All JXxxx classes are part of swing JFrame extends Frame (in awt) Frame extends Window Window extends Container Container extends Component Component extends Object

JFrame methods JFrame frame1 = new JFrame(); frame1.setTitle(“Window 1”); frame1.setSize(200,150); frame1.setLocation(200,100); frame1.setDefaultCloseOperation(JFram e.EXIT_ON_CLOSE);

Containers and Layout Managers (p.290) We can add various components to a frame window, such as buttons JButton yesButton = new JButton(“yes”); frame1.add(yesButton); frame1.setVisible; JButton noButton = new JButton(“no”); frame1.add(noButton); frame1.setVisible() The “no” button overwrote the “yes” button. To avoid that we use FlowLayout

FlowLayout FlowLayout layout = new FlowLayout(); frame1.setLayout(layout) these lines go before you start adding components after adding components, need to call setVisible

Inheriting GUI components (p.330) Suppose we want to design a frame window and then construct multiple instances of it public class OurFrame extends JFrame{ –public OurFrame() { –…–… –}–} Then we can construct multiple instances of OurFrame

Chapter 12: more details Container classes (JFrame, JPanel, JApplet, etc) Component classes (JButton, JLabel, JTextField, JCheckBox, JRadioButton, JComboBox, JMenu, etc) Helper classes (FlowLayout, GridLayout, Color, Font, Graphics, etc

GridLayout and Color Gridlayout layout = new GridLayout(5,3); –specifies horizontal and vertical grid Color color = new Color(128,128,128) –specifies red, green, blue –button.setBackground(color); –button.setForeground(color); –random colors