0% found this document useful (0 votes)
6 views9 pages

Java AWT Advanced Concepts Guide

The document covers advanced concepts in Java AWT, including dialogs, graphics, images, and clipboard functionalities. It explains the types of dialogs, how to create file dialogs, custom canvases for drawing, and the use of the Graphics class for rendering shapes and text. Additionally, it discusses color and font management, image handling, double buffering to prevent flickering, and clipboard operations for data transfer.

Uploaded by

gourav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Java AWT Advanced Concepts Guide

The document covers advanced concepts in Java AWT, including dialogs, graphics, images, and clipboard functionalities. It explains the types of dialogs, how to create file dialogs, custom canvases for drawing, and the use of the Graphics class for rendering shapes and text. Additionally, it discusses color and font management, image handling, double buffering to prevent flickering, and clipboard operations for data transfer.

Uploaded by

gourav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Java AWT – Advanced Concepts

Dialogs, Graphics, Images, Clipboard


(Slides 37–44)
Dialogs
• • Popup windows used for interaction
• • Types:
• - Modal → blocks parent window
• - Modeless → does not block
• Example:
• Dialog d = new Dialog(f, "Dialog", true);
• [Link](200,100);
• [Link](true);
FileDialog
• • Used to open or save files
• Example:
• FileDialog fd = new FileDialog(f, "Open File",
[Link]);
• [Link](true);
• String file = [Link]();
Custom Canvas
• • Canvas class for drawing graphics
• Example:
• class MyCanvas extends Canvas {
• public void paint(Graphics g) {
• [Link]("Hello AWT", 50, 50);
• }
• }
Graphics Class
• • Provides methods for drawing shapes, text,
images
• Example:
• [Link](20,30,200,30);
• [Link](40,50,60,30);
• [Link]([Link]);
• [Link](120,50,50,50);
Colors & Fonts
• • Use Color class for predefined & custom
colors
• • Use Font class for text style
• Example:
• [Link]([Link]);
• [Link](new Font("Serif", [Link], 18));
Images in AWT
• • Load and draw images
• Example:
• Image img =
[Link]().getImage("[Link]");
• [Link](img, 20, 20, this);
Double Buffering
• • Technique to avoid flickering in graphics
• • Draw off-screen, then display
• Example:
• BufferedImage buffer = new BufferedImage(w,
h, TYPE_INT_ARGB);
• Graphics g2 = [Link]();
Clipboard & Data Transfer
• • Supports cut, copy, paste
• Example:
• Clipboard cb =
[Link]().getSystemClipboard
();
• StringSelection s = new
StringSelection("Hello");
• [Link](s, null);

You might also like