AWT WINDOW CLASS. The class Window is a top level window with no border and no menubar. It uses BorderLayout as default layout manager.

Similar documents
AWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user.

AWT CHOICE CLASS. Choice control is used to show pop up menu of choices. Selected choice is shown on the top of the menu.

AWT CHECKBOX CLASS. Creates a check box with the specified label and sets the specified state.

AWT SCROLLBAR CLASS. Scrollbar control represents a scroll bar component in order to enable user to select from range of values.

AWT TEXTFIELD CLASS. Constructs a new empty text field with the specified number of columns.

AWT LIST CLASS. The List represents a list of text items. The list can be configured to that user can choose either one item or multiple items.

AWT MENUBAR CLASS. Introduction. Class declaration. Class constructors. Class methods

SWING - GROUPLAYOUT CLASS

AWT GRAPHICS CLASS. Introduction. Class declaration. Class constructors. Class methods

Laborator 2 Aplicatii Java

AWT QUADCURVE2D CLASS

AWT COLOR CLASS. Introduction. Class declaration. Field

Introduction to the JAVA UI classes Advanced HCI IAT351

CS 251 Intermediate Programming GUIs: Components and Layout

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

10/11/18. Introduction Panel Class Window Class Dialog class FileDialog class Menu, MenuItem class

Graphical Interfaces

Window Interfaces Using Swing Objects

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

G51PRG: Introduction to Programming Second semester Applets and graphics

Chapter 1 GUI Applications

Swing from A to Z Some Simple Components. Preface

The AWT Package, Placing Components in Containers, CardLayout. Preface. Introduction

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

(Incomplete) History of GUIs

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Lecture 5: Java Graphics

Window Interfaces Using Swing Objects

The AWT Package, An Overview

Swing from A to Z Using Focus in Swing, Part 2. Preface

Lecture 3: Java Graphics & Events

CHAPTER 2. Java Overview

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

SD Module-1 Advanced JAVA

PIC 20A GUI with swing

SD Module-1 Advanced JAVA. Assignment No. 4

CS 3331 Advanced Object-Oriented Programming Final Exam

Overview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

Packages: Putting Classes Together

Chapter 12 Advanced GUIs and Graphics

Building Graphical User Interfaces. GUI Principles

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

Building Graphical User Interfaces. Overview

Introduction. Overview of the Course on Java. Overview of Part 1 of the Course

Graphical Interfaces

Java. GUI building with the AWT

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali

Programmierpraktikum

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

JFrame In Swing, a JFrame is similar to a window in your operating system

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

Java - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything.

Java AWT Windows, Text, & Graphics

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

GUI in Java TalentHome Solutions

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS

Overloading Example. Overloading. When to Overload. Overloading Example (cont'd) (class Point continued.)

Windows and Events. created originally by Brian Bailey

JAVA NOTES GRAPHICAL USER INTERFACES

Graphical User Interfaces (GUIs)

Courier system report

Java Applets / Flash

Part 3: Graphical User Interface (GUI) & Java Applets

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide

Sketchpad. Plan for Today. Class 22: Graphical User Interfaces IBM 705 (1954) Computer as Clerk : Augmenting Human Intellect

Graphic User Interfaces. - GUI concepts - Swing - AWT

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

Java Programming Lecture 6

Programming Languages and Techniques (CIS120e)

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI

GWT - UIOBJECT CLASS

CS 349 / SE 382 Design Patterns. Professor Michael Terry January 21, 2009

Example: Building a Java GUI

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Example: Building a Java GUI

CS11 Java. Fall Lecture 3

Sri Vidya College of Engineering & Technology

Graphical User Interface (GUI)

The Java Programming Language Basics. Identifiers, Keywords, and Types. Expressions and Flow Control. Object-Oriented Programming. Objects and Classes

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1

DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

GWT - POPUPPANEL WIDGET

AP CS Unit 11: Graphics and Events

RAIK 183H Examination 2 Solution. November 10, 2014

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Dr. Hikmat A. M. AbdelJaber

CS11 Java. Fall Lecture 4

Java Help Files. by Peter Lavin. May 22, 2004

CS 11 java track: lecture 3

Example 3-1. Password Validation

About This Lecture. Data Abstraction - Interfaces and Implementations. Outline. Object Concepts. Object Class, Protocol and State.

Programming Mobile Devices J2SE GUI

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

Transcription:

http://www.tutorialspoint.com/awt/awt_window.htm AWT WINDOW CLASS Copyright tutorialspoint.com Introduction The class Window is a top level window with no border and no menubar. It uses BorderLayout as default layout manager. Class declaration Following is the declaration for java.awt.window class: public class Window extends Container implements Accessible Class constructors S.N. 1 Constructor & Description WindowFrameowner Constructs a new, initially invisible window with the specified Frame as its owner. 2 WindowWindowowner Constructs a new, initially invisible window with the specified Window as its owner. 3 WindowWindowowner, GraphicsConfigurationgc Constructs a new, initially invisible window with the specified owner Window and a GraphicsConfiguration of a screen device. Class methods S.N. 1 Method & Description void addnotify Makes this Window displayable by creating the connection to its native screen resource. 2 void addpropertychangelistenerpropertychangelistenerlistener Adds a PropertyChangeListener to the listener list. 3 void add Property ChangeListenerStringpropertyName, PropertyChangeListenerlistener Adds a PropertyChangeListener to the listener list for a specific property.

4 void addwindowfocuslistenerwindowfocuslistenerl Adds the specified window focus listener to receive window events from this window. 5 void addwindowlistenerwindowlistenerl Adds the specified window listener to receive window events from this window. 6 void addwindowstatelistenerwindowstatelistenerl Adds the specified window state listener to receive window events from this window. 7 void applyresourcebundleresourcebundlerb Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation. 8 void applyresourcebundlestringrbname Deprecated. As of J2SE 1.4, replaced by Component.applyComponentOrientation. 9 void createbufferstrategyintnumbuffers Creates a new strategy for multi-buffering on this component. 10 void createbufferstrategyintnumbuffers, BufferCapabilitiescaps Creates a new strategy for multi-buffering on this component with the required buffer capabilities. 11 void dispose Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. 12 AccessibleContext getaccessiblecontext Gets the AccessibleContext associated with this Window. 13 BufferStrategy getbufferstrategy Returns the BufferStrategy used by this component. 14 boolean getfocusablewindowstate Returns whether this Window can become the focused Window if it meets the other requirements outlined in isfocusablewindow. 15 Container getfocuscyclerootancestor

Always returns null because Windows have no ancestors; they represent the top of the Component hierarchy. 16 Component getfocusowner Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise. 17 Set<AWTKeyStroke> getfocustraversalkeysintid Gets a focus traversal key for this Window. 18 GraphicsConfiguration getgraphicsconfiguration This method returns the GraphicsConfiguration used by this Window. 19 List<Image> geticonimages Returns the sequence of images to be displayed as the icon for this window. 20 InputContext getinputcontext Gets the input context for this window. 21 <T extends EventListener> T[] getlistenersclass < T > listenertype Returns an array of all the objects currently registered as FooListeners upon this Window. 22 Locale getlocale Gets the Locale object that is associated with this window, if the locale has been set. 23 Dialog.ModalExclusionType getmodalexclusiontype Returns the modal exclusion type of this window. 24 Component getmostrecentfocusowner Returns the child Component of this Window that will receive the focus when this Window is focused. 25 Window[] getownedwindows Return an array containing all the windows this window currently owns. 26 Window getowner Returns the owner of this window.

27 static Window[] getownerlesswindows Returns an array of all Windows created by this application that have no owner. 28 Toolkit gettoolkit Returns the toolkit of this frame. 29 String getwarningstring Gets the warning string that is displayed with this window. 30 WindowFocusListener[] getwindowfocuslisteners Returns an array of all the window focus listeners registered on this window. 31 WindowListener[] getwindowlisteners Returns an array of all the window listeners registered on this window. 32 static Window[] getwindows Returns an array of all Windows, both owned and ownerless, created by this application. 33 WindowStateListener[] getwindowstatelisteners Returns an array of all the window state listeners registered on this window. 34 void hide Deprecated. As of JDK version 1.5, replaced by setvisibleboolean. 35 boolean isactive Returns whether this Window is active. 36 boolean isalwaysontop Returns whether this window is an always-on-top window. 37 boolean isalwaysontopsupported Returns whether the always-on-top mode is supported for this window. 38 boolean isfocusablewindow

Returns whether this Window can become the focused Window, that is, whether this Window or any of its subcomponents can become the focus owner. 39 boolean isfocuscycleroot Always returns true because all Windows must be roots of a focus traversal cycle. 40 boolean isfocused Returns whether this Window is focused. 41 boolean islocationbyplatform Returns true if this Window will appear at the default location for the native windowing system the next time this Window is made visible. 42 boolean isshowing Checks if this Window is showing on screen. 43 void pack Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. 44 void paintgraphicsg Paints the container. 45 boolean posteventevente Deprecated. As of JDK version 1.1 replaced by dispatcheventawtevent. 46 protected void processeventawtevente Processes events on this window. 47 protected void processwindoweventwindowevente Processes window events occurring on this window by dispatching them to any registered WindowListener objects. 48 protected void processwindowfocuseventwindowevente Processes window focus event occuring on this window by dispatching them to any registered WindowFocusListener objects. 49 protected void processwindowstateeventwindowevente

Processes window state event occuring on this window by dispatching them to any registered WindowStateListener objects. 50 void removenotify Makes this Container undisplayable by removing its connection to its native screen resource. 51 void removewindowfocuslistenerwindowfocuslistenerl Removes the specified window focus listener so that it no longer receives window events from this window. 52 void removewindowlistenerwindowlistenerl Removes the specified window listener so that it no longer receives window events from this window. 53 void removewindowstatelistenerwindowstatelistenerl Removes the specified window state listener so that it no longer receives window events from this window. 54 void reshapeintx, inty, intwidth, intheight Deprecated. As of JDK version 1.1, replaced by setboundsint, int, int, int. 55 void setalwaysontopbooleanalwaysontop Sets whether this window should always be above other windows. 56 void setboundsintx, inty, intwidth, intheight Moves and resizes this component. 57 void setboundsrectangler Moves and resizes this component to conform to the new bounding rectangle r. 58 void setcursorcursorcursor Set the cursor image to a specified cursor. 59 void setfocusablewindowstatebooleanfocusablewindowstate Sets whether this Window can become the focused Window if it meets the other requirements outlined in isfocusablewindow. 60

60 void setfocuscyclerootbooleanfocuscycleroot Does nothing because Windows must always be roots of a focus traversal cycle. 61 void seticonimageimageimage Sets the image to be displayed as the icon for this window. 62 void seticonimageslist <?extendsimage > icons Sets the sequence of images to be displayed as the icon for this window. 63 void setlocationbyplatformbooleanlocationbyplatform Sets whether this Window should appear at the default location for the native windowing system or at the current location returnedbygetlocation the next time the Window is made visible. 64 void setlocationrelativetocomponentc Sets the location of the window relative to the specified component. 65 void setminimumsizedimensionminimumsize Sets the minimum size of this window to a constant value. 66 void setmodalexclusiontypedialog. ModalExclusionTypeexclusionType Specifies the modal exclusion type for this window. 67 void setsizedimensiond Resizes this component so that it has width d.width and height d.height. 68 void setsizeintwidth, intheight Resizes this component so that it has width width and height height. 69 void setvisiblebooleanb Shows or hides this Window depending on the value of parameter b. 70 void show Deprecated. As of JDK version 1.5, replaced by setvisibleboolean. 71 void toback If this Window is visible, sends this Window to the back and may cause it to lose focus or

activation if it is the focused or active Window. 72 void tofront If this Window is visible, brings this Window to the front and may make it the focused Window. Methods inherited This class inherits methods from the following classes: java.awt.window java.awt.container java.awt.component java.lang.object Window Example Create the following java program using any editor of your choice in say D:/ > AWT > com > tutorialspoint > gui > AwtContainerDemo.java package com.tutorialspoint.gui; import java.awt.*; import java.awt.event.*; public class AwtContainerDemo { private Frame mainframe; private Label headerlabel; private Label statuslabel; private Panel controlpanel; private Label msglabel; public AwtContainerDemo(){ preparegui(); public static void main(string[] args){ AwtContainerDemo awtcontainerdemo = new AwtContainerDemo(); awtcontainerdemo.showframedemo(); private void preparegui(){ mainframe = new Frame("Java AWT Examples"); mainframe.setsize(400,400); mainframe.setlayout(new GridLayout(3, 1)); mainframe.addwindowlistener(new WindowAdapter() { public void windowclosing(windowevent windowevent){ System.exit(0); ); headerlabel = new Label(); headerlabel.setalignment(label.center); statuslabel = new Label(); statuslabel.setalignment(label.center); statuslabel.setsize(350,100); msglabel = new Label(); msglabel.setalignment(label.center); msglabel.settext("welcome to TutorialsPoint AWT Tutorial.");

controlpanel = new Panel(); controlpanel.setlayout(new FlowLayout()); mainframe.add(headerlabel); mainframe.add(controlpanel); mainframe.add(statuslabel); mainframe.setvisible(true); private void showwindowdemo(){ headerlabel.settext("container in action: Window"); final MessageWindow window = new MessageWindow(mainFrame, "Welcome to TutorialsPoint AWT Tutorial."); Button okbutton = new Button("Open a Window"); okbutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { window.setvisible(true); statuslabel.settext("a Window shown to the user."); ); controlpanel.add(okbutton); mainframe.setvisible(true); class MessageWindow extends Window{ private String message; public MessageWindow(Frame parent, String message) { super(parent); this.message = message; setsize(300, 300); setlocationrelativeto(parent); setbackground(color.gray); public void paint(graphics g) { super.paint(g); g.drawrect(0,0,getsize().width - 1,getSize().height - 1); g.drawstring(message,50,150); Compile the program using command prompt. Go to D:/ > AWT and type the following command. D:\AWT>javac com\tutorialspoint\gui\awtcontainerdemo.java If no error comes that means compilation is successful. Run the program using following command. D:\AWT>java com.tutorialspoint.gui.awtcontainerdemo Verify the following output

Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js