CS1371 Prologue to Figuring for Designers.

Uploaded on:
CS1371 Prologue to Processing for Designers Fundamental Illustrations Essential Representation Design Standards Holders Parts Formats Occasions Learning Destinations Nuts and bolts of Java Representation Objective (demo Graphic4) Foundation
Slide 1

CS1371 Introduction to Computing for Engineers Basic Graphics

Slide 2

Basic Graphics Principles Containers Components Layouts Events Learning Objectives Basics of Java Graphics

Slide 3

Objective (demo Graphic4)

Slide 4

Background As we have as of now seen, printing to, and perusing from, a content window is really revolting. Java is not planned for content I/O This module is about what Java was intended for: graphical window communication So this ought to be truly simple, isn\'t that so? All things considered, everything is relative. Java representation are much simpler than, for instance, C++. In addition, they are totally compact between PCs. In the event that your system keeps running on you\'re PC, it will keep running on anything with the same or later arrival of the Java Virtual Machine (JVM)

Slide 5

Agenda Graphical User Interfaces - - diagram - - vital components Containers - - review - - organization versus legacy Components - - cases Layout Managers - - illustrations Our Roadmap

Slide 6

Agenda Graphical User Interfaces - - outline - - fundamental components Containers - - review - - organization versus legacy Components - - cases Layout Managers - - samples Our Roadmap

Slide 7

Downloading libcrypt ... Enter Edit File 40% Cancel Open Save As... Stopped Graphical User Interface A Graphical User Interface (GUI) is one mixed bag of client interface. . Client cooperates with items on the screen (symbols, catches, parchment bars, and so forth.) by means of mouse snaps or console activities. Alright

Slide 8

GUI Popularity Popularized in 1980s by the Macintosh. Presently condition of the practice, and not last word in UI Intended to supplant content based "command line" and "function key" interfaces. Regardless of similitudes, GUIs are normally stage particular (Windows 95/98/NT/1900, MacOS, X Windows look-and-feel models). Some graphical toolboxs now give cross-stage APIs. E.g. wxWindows, GTK+, Java.

Slide 9

1. 2. Java’s GUI Capabilities Java gives basically two related toolboxs to making GUIs: The Abstract Windowing Toolkit ("AWT"), and The Java Foundation Classes ("Swing") Swing is only an extended form of the AWT, and gives more noteworthy control and comfort.

Slide 10

Why Two Toolkits in Java? MFC AWT, then JFC or "Swing" Well, it’s a long story. To put it plainly, JFC (swing) is Sun’s answer to Microsoft’s MFC- - an itemized toolbox library.

Slide 11

Button JButton Cautionary Note Java has two kinds of toolboxs: Swing and AWT. It is not insightful to blend AWT and Swing Components. For your first projects, stay with one toolbox or the other. We’ll begin off with AWT, and the change to Swing Components. How would you let them know separated? By and large, yet not continually, Swing Components will have a "J" before the class name: AWT Swing

Slide 12

Keep in Mind We will program graphical components in source code (content). There are move and customize frameworks yet more often than not there is a basic content based framework Eventually you have to get down to the content level Java is intended to work crosswise over diverse stages. This postures extraordinary difficulties As does the very way of WIMP GUI’s ( w indows, i cons, m enus, and p ointing gadget g raphic u ser i nterface)

Slide 13

Steps to GUI Construction We will learn GUI creation in two stages: the "view", and afterward the "controls" or occasion taking care of. 1. In Java, to make a GUI, you (1): Specify a Container , utilizing . . . a Layout Manager to . . . place Components and/or Containers of Components . . . on the screen as wanted. I.e. UI frame and appearance FIRST LATER 2. In Java, to make a GUI go about as the interface for a system, you (2) Design human/PC dialog , utilizing Listeners and segment produced occasions I.e. UI cooperation and conduct

Slide 14

Agenda Graphical User Interfaces - - review - - key components Containers - - outline - - organization versus legacy Components - - illustrations Layout Managers - - cases Our Roadmap

Slide 15

File Edit Help CLICK ME GUI Design & Creation There are three crucial develops in any GUI: Containers - used to hold things (e.g., the edge) Components - the gadgets or interactors (e.g., catches) LayoutManagers - the shrouded calculation used to arrange the gadgets inside the holder counterbalance balance

Slide 16

1. Compartments File Edit Help balance 2. Segments CLICK ME 3. LayoutManagers counterbalance Pop Quiz (insight) What are the three essential develops utilized as a part of each GUI?

Slide 17

Agenda Graphical User Interfaces - - outline - - crucial components Containers - - diagram - - structure versus legacy Components - - cases Layout Managers - - samples Our Roadmap

Slide 18

Examples of Containers : Swing AWT JPanel JFrame JApplet JWindow Panel Frame Applet Window Containers STEP 1 Containers are extraordinary parts that may contain different segments. Note: Containment is not the same as legacy augmentation. A Frame may contain catches, but catches are not subclasses of Frame.

Slide 19

Containers A Container is a class that stretches out from java.awt.Container for reasons unknown, the class "Container" is itself a Component. Holders can have: Layouts set on them Other parts or compartments added to them. Object Component Container

Slide 20

Example Let’s make a basic Frame. At the point when working with GUIs, you frequently need to counsel the API. Note the legacy structure of your classes.

Slide 21

Example So far, we’ve utilized the API to figure out how to make a Frame. We discovered constructors for: open JFrame (); open JFrame (String strTitle); Now, by what method would we be able to set the Frame\'s measure? We again come back to the API.

Slide 22

Example The class java.awt.Frame does not contain a system to set its size. In any case, such a system was acquired from java.awt.Component:

Slide 23

Example Likewise, there’s no strategy in java.awt.Frame to make the Frame obvious. Rather, we discover the technique "show()" was acquired from java.awt.Window

Slide 24

Hello GUI import java.awt.*; open class HelloGUI { open static void principle ( String [ ] arg) { System .out.println ("About to make GUI"); Frame f = new Frame ("Hello GUI"); f.setSize( 200, 200 ); f.show(); System .out.println ("Finished making GUI"); }/fundamental }/class HelloGUI

Slide 25


Slide 26

Notice anything odd? When we achieve the end of primary (as our print proclamation demonstrates) why doesn’t the project end?

Slide 27

import javax.swing.*; open class HelloGUI { open static void fundamental ( String [ ] arg) { System .out.println ("About to make GUI"); JFrame f = new JFrame ("Hello GUI"); f.setSize( 200, 200 ); f.show(); System .out.println ("Finished making GUI"); }/principle }/class HelloGUI Explanation When the Java VM made our JFrame, it went into a sort of ‘infinite loop’, sitting tight for info and occasions. (This is basic of graphical toolboxs.) while(true){/get client data/handle occasion }

Slide 28

Agenda Graphical User Interfaces - - review - - fundamental components Containers - - outline - - arrangement versus legacy Components - - samples Layout Managers - - illustrations Our Roadmap

Slide 29

1. Legacy - our class augments a compartment 2. Organization - our class holds a holder Design Idea We truly have two decisions when working with top-level compartments: java.awt.Frame MyGUI We will execute compartments utilizing arrangement MyGUI java.awt.Frame

Slide 30

Check the API Will call constructor so the appear() strategy gets called Example import java.awt.*; open class HelloComposition { Frame f; open HelloComposition (){ f = new Frame("Composition Test"); f.setSize(200,200); f.setBackground(Color.red); f.show(); } open static void primary (String[] arg) { HelloComposition h = new HelloComposition(); }

Slide 31

myFrame.setBackground(Color.red); An acquired system A class, likewise in the API Container Summary Creating compartments obliges watchful investigation of the API. Watch the legacy structure of the classes. A top-level holder, similar to a Frame, obliges occasion handlers (secured later). There are numerous helpful techniques for altering compartments. Simply find them in the API. E.g.:

Slide 32

Agenda Graphical User Interfaces - - review - - crucial components Containers - - diagram - - organization versus legacy Components - - samples Layout Managers - - illustrations Our Roadmap

Slide 33

Components STEP 2 Most cooperations in a Java GUI are with Components . Another nonexclusive term for Component in different GUIs (e.g. X Windows) is "widget". Diverse sorts of parts for distinctive sorts of interaction (e.g. catches, and so on.) User cooperations with segments make occasions (along these lines, permit occasion driven programming) when in doubt, a Component can\'t have different segments inside Exceptions to lead: pop up menus may have menu things added to them. Also, Containers are themselves segments because of legacy.

Slide 34

Component Examples

Slide 35

Recall: A Container "is a" Component Examples Component - non specific gadget that you can associate with Button - a gadget that you can squeeze Canvas - a gadget that you can draw on Checkbox - a gadget that is checked or not checked Choice - a choice menu that drops down Container - a non specific class that contains Components Panel - a Con

View more...