JButton – Container Layout & Icons

Slides:



Advertisements
Similar presentations
Graphical User Interfaces
Advertisements

Computer Science 209 Images and GUIs. Working with Java Colors The class java.awt.Color includes constants, such as Color.red, for some commonly used.
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Graphic User Interfaces Layout Managers Event Handling.
 Java GUI API  Layout Managers [Sample code] ShowFlowLayout.java 、 ShowGripLayout.java 、 ShowBorderLayout.java TestImageIcon.java.
Eric Stokes, Matt Behling. GridbagLayout CardLayout SpringLayout.
GUI Tutorial Day 3. Custom Dialog Create, display, hide, retrieve information.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java GUI Libraries Swing Programming. Swing Components Swing is a collection of libraries that contains primitive widgets or controls used for designing.
© L.Lúcio, An example GUI in Java n Two graphic libraries in Java u AWT u Swing n Swing is more recent than AWT: u Built on top of AWT classes;
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
LAB SESSION 10 *LAYOUT MANAGER *LISTENERS. Laying the components manually by using a null layout is tedious. Each container object has a layout manager.
20-Jun-15 GUI building with Swing. 2 How to build a GUI Create a window in which to display things—usually a JFrame (for an application), or a JApplet.
IEEM 110 Computing in Industrial Applications Basic User Interface in Java.
Layout Mangers CSC 171 FALL 2001 LECTURE 14. History: The Transistor William Shockley, John Bardeen, and Walter Brattain invent the transfer resistance.
23-Aug-15 GUI building with Swing. 2 How to build a GUI Create a window in which to display things—usually a JFrame (for an application), or a JApplet.
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
F27SB2 Software Development 2 Lecture 4: Java GUIs 3.
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.
SIGCSE’11 - Workshop #3Pedagogical Progressions for Teaching OOD Computer Science & Engineering Carl Alphonce A Progression of Events.
Java Event Handling CSIS 3701: Advanced Object Oriented Programming.
CS Lecture 01 Frames and Components and events Lynda Thomas
GUIs for Video Games. The Plan ● Layout suggestions ● Observer/Observable ● Steps to writing Observer/Observables ● Sample Code ● Practice.
Copyright © 2002, Systems and Computer Engineering, Carleton University c-Gui3.ppt * Object-Oriented Software Development Part 18-c Building.
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
University of Limerick1 Software Architecture Java Layout Managers.
Introduction to GUI in 1 Graphical User Interface 2 Nouf Almunyif.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
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.
Computer Science 209 GUIs Model/View/Controller Layouts.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 14 : Swing II King Fahd University of Petroleum & Minerals College of Computer Science.
Programming 2 LAB TA: Nouf Al-Harbi NoufNaief.net :::
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Lecture 33: More Graphical User Interface (GUI) Announcements & Review Read Ch GU1 & GU2 Cohoon & Davidson Ch 14 Reges & Stepp Lab 10 set game due 4/26.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Graphical User Interface (GUI)
Event Handling CS 21a: Introduction to Computing I First Semester,
Advanced Topics on Graphical User Interfaces CardLayout JTabbedPane JFrame.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
GUIs & Event-Driven Programming Chapter 11 Review.
GUI Programming in Java Hao Jiang Boston College April, 2009.
Dale Roberts GUI Programming using Java - Windowing Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Chapter 7 A First Look at GUI Applications Layout Managers.
Modular Event Handling
Swing JComponents.
GUIs Model/View/Controller Layouts
Java GUI.
Graphical User Interface (pronounced "gooey")
Graphical user interface with Swing by jose maria gonzalez pinto
GUI building with Swing
Event Handling CS 21a: Introduction to Computing I
GUI Programming III: Events
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Panels & Layout Managers
PC02 Consolidation %WITTY_QUOTE%. PC02 Consolidation %WITTY_QUOTE%
Project Title This is a sample slide layout
GUI building with Swing
Computer Science 209 Images and GUIs.
Project Title This is a sample poster layout -
CS Problem Solving and Object Oriented Programming Spring 2019
Graphical User Interface
Presentation transcript:

JButton – Container Layout & Icons Jack Tompkins Department of Computer Science tompkinsj@uncw.edu

JButton Constructor new ImageIcon(imagePath) JButton​(String text, Icon icon) Creates a button with initial text and an icon. But the Icon is an interface (not instantiable) Icon - All Known Implementing Classes: IconUIResource, ImageIcon,… new ImageIcon(imagePath) Say the component is using a 3x2 GridLayout  

JButton Container Instantiate the Container (say a JPanel) Set the Layout Manager Say the component is using a 3x2 GridLayout setLayout(new GridLayout(3,2)); add(new Button("1")); add(new Button("2")); add(new Button("3")); add(new Button("4")); add(new Button("5")); add(new Button("6")); Add the Container to a JFrame  

addButton(String text, Container container, String imagePath) { JButton button = null; if (imagePath != null) button = new JButton(text, new ImageIcon(imagePath)); else button = new JButton(text); button.addActionListener(new MyActionListener()); container.add(button); }