Home arrow Java & J2EE arrow Page 6 - Using Abstract Windowing Toolkit (AWT) In Applications

How To Talk To Your Application - Java

A well laid out user interface is an effective means of making applications user-friendly. It is typically used by organizations for accepting orders from customers, getting customer’s feedback on a product, for conducting a market survey on the latest trends in economy.

TABLE OF CONTENTS:
  1. Using Abstract Windowing Toolkit (AWT) In Applications
  2. Read On….Its Not That Abstract
  3. Your Best Buddies….Java’s AWT
  4. Features Of The Component Class
  5. What Holds Components Together…The Container
  6. How To Talk To Your Application
By: Gayathri Gokul
Rating: starstarstarstarstar / 10
September 29, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
The Dialog Class:

Dialogs are pop-up windows that are used to accept input from a user. There are two kinds of dialog boxes-modal and modeless. Unlike a modeless dialog box, a modal dialog box does not allow a user to interact with other window while it is displayed. A frame or another dialog must own a dialog box. You cannot directly attached a dialog to an applet. You can attach a dialog to a frame.

When you create a dialog box, you can specify whether you want a modal or modeless dialog box. You cannot change the “modality” of the dialog box after creating it. We use Dialog class for creating dialog boxes. The dialog class offers overloaded constructors.

The following constructors create a dialog box that has a frame as its owner:

    •Dialog (Frame owner_frame)
    •Dialog (Frame owner_frame, String title).
    •Dialog (Frame owner_frame, String title, Boolean modal).
The following constructors create a dialog box that has another dialog box as its owner:

    •Dialog(Dialog owner_dialog)
    •Dialog (Dialog owner_dialog, String title).
    •Dialog (Dialog owner_dialog, String title, Boolean modal).


The single argument constructor creates a modeless dialog box without a title. The second argument that you could pass to a constructor is the title of the dialog box. To create a modal dialog box, you could use the third argument. An example is given below.
Dialog dialog = new Dialog (frame, “Demo Of Dialog”, true);
Getting To Know About PanelsThe Panel Class: Panels are used for organizing components. You can use the Layout Manager to decide how the components are to be arranged on the panel. Each panel can have a different layout. To create a panel, use the following command:
Panel panel = new Panel ();
Sub-Panels: You can also create what is called the “nested panels”, with one panel containing more than one sub-panels. You can nest panels, as many levels up as you like. Once you have created a component, the simplest way to add it to the container is to call the container’s add () method. For example:
Panel Mainpanel, Subpanel1, Subpanel2; Mainpanel = new Panel (); Subpanel1 = new Panel (); Subpanel2 = new Panel (); Mainpanel.add(Subpanel1); Mainpanel.add(Subpanel2);
So we have covered some basics about Java AWT, discussed at length about the Component class. Enumerated on the first component-the container and its various types like windows, Frame, Panel and Dialog boxes. In the next part of the tutorial we will see how to simplify user interaction and make data entry easier, with the use of use controls. Controls are components like buttons and text box, check box, radio button etc. that can be added to containers like frame, panels and applets. We will also cover additional information about Java AWT package which provide an integrated set of classes to manage user interface components and then write a few codes to test our knowledge.

 
 
>>> More Java & J2EE Articles          >>> More By Gayathri Gokul
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: