Home Java Example Java Awt Java AWT Package Example
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java AWT Package Example

Advertisement
In this section you will learn about the AWT package of the Java. Many running examples are provided that will help you master AWT package.

Java AWT Package Example

     

In this section you will learn about the AWT package of the Java. Many running examples are provided that will help you master AWT package. Example provided are supported with tested code.

  1. Graphical User Interfaces
    A class library is provided by the Java programming language which is known as Abstract Window Toolkit (AWT).  
  2. What is AWT in java
    In this section, you will learn about the java.awt.*; package available with JDK. AWT stands for Abstract Windowing Toolkit.
  3. Describe the AWT Components
    In this section you will learn about the different components available in the Java AWT package for developing user interface for your program.
  4. AWT Components
    The class component is extended by all the AWT components. More of the codes can be put to this class to design lot of AWT components. Following are the AWT components:

    1. Canvas
    2. Checkbox
    3. Label
    4. Scrollbar
    5. TextField
  5. Common Component Methods
    The common methods of AWT components are as follow:

  6. Containers
    As discussed earlier a container is a component that can be nested. The most widely used Panel is the Class Panel which can be extended further to partition GUIs.

  7. Describe different types of event to provide by the AWT Components in java
     There are many types of events that are generated by your AWT Application. These events are used to make the application more effective and efficient. Generally, there are twelve types of event are used in Java AWT.

  8. Events
    In this section, you will learn how to handle events in Java awt. Events are the integral part of the java platform.

  9. Event Adapters
    There are some event listeners that have multiple methods to implement. That is some of the listener interfaces contain more than one method. 

  10. Button Pressing Example
    In the program code given below, the Frame contains three buttons named - "Bonjour", "Good Day", "Aurevoir".

  11. Adapters Example
    In the following program code, the adapter class has been used. This class has been used as an anonymous inner class to draw a rectangle within an applet.

  12. GUI-based Applications
    In this section you will learn about how to create a window for your application. You need to define a subclass of Frame to create a window for your application.

  13. Menus
    We can also develop an application with a Menu. As a name indicates a Menu consists of Menu objects.

  14. Menu Shortcuts
    The MenuItem class also provides a feature of menu shortcuts and speed keys.
  15. Pop-up Menus
    A PopupMenu is similar to a Menu as it contains MenuItem objects. The Pop-up Menu can be popped over any component while generating the appropriate mouse event rather than letting it appear at the top of a Frame. 

  16. Creating a Frame
    This program shows you how to create a frame in java AWT package. The frame in java works like the main window where your components (controls) are added to develop a application. In the Java AWT, top-level windows are represented by the Frame class.
      
  17. Setting the Icon for a Frame
    Here, you will learn how to set the icon of the frame. This program is the detailed illustration to set the icon to the frame.
      
  18. Setting the close button operation for the frame
    In this section, you will learn how to implement the close button of any frame or window in java application. By default the close button of the frame is not in working state.
      
  19. Making a Frame Non-Resizable
    This program illustrates you how to make a frame non resizable. It means that the disabling the maximize button of the frame.
      
  20. Removing the Title Bar of a Frame
    Here, you will learn how to display the frame or window without title bar in java. This type of the frame is mostly used to show the splash screen at starting of the application.
      
  21. Creating a Container
    This program illustrates you how to create a container. Container contains several control or tools for develop your application. All the controls used in your application are the container for one another.
      
  22. Changing the Cursor
    Here, you will learn how to change the mouse cursor in java. Changing the cursor means showing cursor in many different  shapes for the different objects.
      
  23. Draw Image in Frame
    In this section, you will learn how to display image on the frame. This program shows you how to display image in your application.
      
  24. Handling Focus Changes
    In this section, you will learn about handling the focus changes in java. This section shows you how the event be handled according to the focuses and to find out whether the component got the focus or lost the focus.  
      
  25. Handling Mouse Clicks
    In this section, you will learn about handling the mouse click event in the awt application.
      
  26. Handling Action Events
    In this section, you will learn how to handle events in java awt. Here, this is done through the java.awt.*; package of java. Events are the integral part of the java platform.
      
  27. Handling Key Presses
    In this section, you will learn about the handling key press event in java. Key Press is the event is generated when you press any key to the specific component.
      
  28. Item Events
    In this section, you will learn about handling item events in java. This demonstrates that the event generated when you select an item from the group of the items.
     
  29. How to use KeyListener 
    In this section, you will learn how to handle different key events on the Java Awt component by using the event handling in Java. When the given program is executed then you will see the several key events these are applied on the component like the key pressed, key release and so on.
      
  30. Simple Form in Java
    This is a simple program of java awt package which constructs a look like a form by using various java component. In this section, you will learn how to create it. This is done by using java gui programming using Classes or APIs of java awt package.
      
  31. Hiding Frame in Java
    This section illustrates you how to hide the Java Awt frame. Here, you have seen in the given following example that provides you the complete code of the program.
      
  32. How to Create Button on Frame
    In this section, you will learn how to create Button on  frame the topic of Java AWT package. In the section, from the generated output of the following program, complete window or frame is created in the ButtonText class that is the main class where the main() method lies. This part of the topic will show a simple command button labeled with the text "Submit" when the program will be executed.
     
  33. How to create CheckBox On frame
    This is very simple java program. In this section, you will learn how to create CheckBox on the frame. In the Java AWT, top-level windows are represented by the CheckBox class. This program provides you complete illustration with the full description. If you are fresher in java awt programming then you can learn in very efficient manner.
     
  34. Choice Option (Combo) In Java
    In this section, you will learn how to create Drop-Down List by using Java AWT package.
     
  35. Arcs Drawing In Java
    In this section, you will learn how to create arcs diagram in java awt package. The Java program uses Arcs2D class, arcs2D is the abstract superclass for all objects that store a 2D arc defined by a bounding rectangle, start angle, angular extent and a closure type.
      
  36. BorderLayout Example In Java
    In this section, you will learn how to create BorderLayout in java awt package. The Border Layout is arranging and resizing components to set in five position which is used in this program.
      
  37. Cubic Diagram In Java
    In this section, you will learn  how to create Cubic diagram. The Java2D API  provides you several classes that defines common Geometry object as a coordinate component. The Java Drawing program depends on the Java2D API class, and this class is support by the "java.awt.geom" package.
     
  38. How to Create Circle In Java
    This is a simple program of java awt. In this section, you will learn how to create Circle Diagram. The java circle is the most fundamental abstractions in a Java 2D in the supported  java.awt.shape package.  
       
  39. How to Create CurveDraw In Java 
    In this section, you will learn how to create CurveDraw in java.awt package. This class, supported by the java.awt.geom package, enables you to create a quadratic or cubic segment. Here, you will see in the following example that provide you complete code of the program.
     
  40. How to Create LineDraw In Java
    This is a simple java program . In this section, you will learn how to create Line Drawing. This program  implements a line Drawing component. A java program explains the stroke line i.e. how to make thick and thin line. For this we have used  BasicStroke class. This object is passed to the setStroke() method.
      
  41. RadioButton In Java
    In this section, you will learn how to create Radio Button on the frame. The java AWT , top-level window, are represent by the CheckBoxGroup.  A java program provides you CheckboxGroup. In this program, you will see how to create and show the Checkboxgroup component on the frame.
     
  42. Rectangle Image In Java
    In this section, you will learn how to create rectangle image. This program used the Graphics2D class which extends the Graphic class and control  all geometry or coordinate transformation and color management, text layout. The Java programming in  java 2D API provides several classes.
      
  43. Textarea Frame In Java
    In this section, you will learn how to create TextArea on the frame. This program uses the TextArea class of  java.awt package. Here, we are going to create  TextArea object. TextArea object is a multiline region. It displays text only. You can  read and edit the text only.
      
  44. Image Demo
    This section simply display the image demo that means multiple images and its name are based on the frame to a particular location. For displaying images demo first of all you will need multiple images that have to be displayed on the frame.
     
  45. Image Size
    This Java awt (Abstract Windowing Toolkit) tutorial describes about the image size. This is an actual representation of object. Simply, it helps us to feel associated with an object on the frame.
      
  46. Paint Icon 
    This section provides you to paint an image on the frame. Paint means draw an image and set its on the frame to the specified location according to its x coordinate and y coordinate.
     
  47. RanderingHints Graphics
     This Java tutorial teaches you about adding the rendering hints to a graphics on the frame. The rendering hints uses the Graphics2D and creates the following image.
     
  48. Line Animation
    In this example we are creating an animated line. The color of  line is changing alternatively.
     

  49. Beep Example
    Lets learn how to create beep using java.
      

  50. Open The Default Editor to Edit the File
    This section, you will see the method of opening the file in the default editor to edit and save the file. Here an example has been provided with the complete Java code for illustrating all the things that helps to open the file in the default editor to edit the file.
     

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 18, 2008

Ask Questions?    Discuss: Java AWT Package Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Manikandan
June 28, 2011
java

The rose india is very useful for learn any subject.
gayatri kulkarni
September 22, 2011
feedback for java tutorials.

I like the tuts for java as they are very simple and contain good sample codes.
jadhav vitthal Ankush
January 30, 2013
java notes

goods
mehadi abrahim
November 10, 2011
asking question

please send to me good project on java source code scientific calculator
jamal
December 7, 2011
Hi

provide example on gui general
Subhamoy Guha
December 17, 2011
Draw a Triangle

I like to know that how to draw a Triangle in Java.
patel milan
January 31, 2012
java

java.awt package (Button, CheckBox, CheckBoxGroup, Choice, Color, Label, List, TextArea, TextField) plz solve the problem
ravichandrareddy
March 18, 2012
awt programmes

very good material please some more examples
prakash
June 10, 2012
java

paint(Graphics g) and addWindowListener why this methods are using wil u please send acurate answer
bharat koshti
June 30, 2012
erroe in calci prog...

i hv an error in my calci prog...null pointer exception.... prog compile succesfully....but not run....
India
June 15, 2013
qQGOsgaVJhECLUJ

Thanks for taking the time to post. It's lifted the level of dbaete
DMCA.com