SlideShare a Scribd company logo
AWT ENHANCEMENTS
Arun Seetharaman
March 10, 1998
OVERVIEW
• AWT Enhancements
• Popup menus
• Scroll pane
• Clipboard
• The AppletContext object
• Audio and Images
• Inter-applet communication
DESKTOP COLORS
• The new SystemColor class helps Java detect the
color scheme set for the desktop
• Programmers can uses these colors by accessing the
final members of the class
• activeCaption : Caption background color
• contolText : Control’s text color
• desktop : Desktop’s background color
• menuText : Menu’s text color
• window : Window’s background color
POPUP MENUS
• Dynamically popped menus as specified position within
the component
• Defined the PopupMenu class of Java
• Invoke the show method to popup the menu
• void show(Component,int,int)
• If the popup menu object is used in place of a menu
item, the show() cannot be invoked
POPUP MENU - AN
EXAMPLE
public void mouseReleased(
MouseEvent evt) {
if (evt.isPopupTrigger()) {
popup.show(evt.getSource(),
evt.getX(), evt.getY());
}
else {
System.out.println("no popup");
}
}
AWT Enhancements in V1.1 - Supporting Richer GUI Development
SCROLLING CONTAINERS
• Container implementing automatic scrolling for a single
child component
• Needed in situations where the viewport is smaller than
the window
• Clipping the child’s contents appropriately depending
on the scroll position
THE SCROLLPANE CLASS
• Display policy can be set
• as needed
• always
• never
• Placement is controlled by platform-specifc properties
• Implements the Adjustable interface, which can
be used for fine tuning
SCROLLPANE - AN
EXAMPLE
ScrollPane sp = new ScrollPane();
sp.getHAdjustable().setUnitIncrement(2);
sp.getVAdjustable().setUnitIncrement(2);
sp.add(new ImageComponent(
getToolkit().getImage(filename)));
add(sp, BorderLayout.CENTER);
setSize(200, 150);
AWT Enhancements in V1.1 - Supporting Richer GUI Development
DATA TRANSFER
• Clipboard and Drag-drop are the two major models of
data transfer
• Data transfer occurs using “flavors” defined by the
Transfer APIs
• The flavors to be used for data transfer encapsulate the
various MIME types
• The java.awt.datatransfer package caters to the needs
of these operations
CLIPBOARD
• Clipboard is a globally shared memory
• The toolkit has an instance of a clipboard, that uses the
system clipboard
• Class willing to write to a clipboard need to implement
the ClipboardOwner interface
• Data flavors need to be compatible for transfer of data
using clipboard
WRITING TO A
CLIPBOARD
class ClipboardSource extends Frame
implements ClipboardOwner {
TextArea ta = new TextArea();
void setContents() {
String s = ta.getSelectedText();
StringSelection contents = new
StringSelection(s);
getToolkit().getSystemClipboard(
).setContents(contents, this);
}
}
AWT Enhancements in V1.1 - Supporting Richer GUI Development
READING FROM
CLIPBOARD
Transferable t = getToolkit().
getSystemClipboard().getContents(
this);
if(t.isDataFlavorSupported(
DataFlavor.stringFlavor)) {
String str = t.getTransferData(
DataFlavor.stringFlavor);
}
DRAG AND DROP
• Uses the same data transfer mechanism
• Discussed later as a part of JFC
APPLET CONTEXT
• Corresponds to the applet’s execution environment
• In the normal execution circumstances, this object is
the browser
• Defined by the AppletContext interface
• Use the getAppletContext() method to access
the context object
USING AUDIO
• Defined by the AudioClip interface
• A simple abstraction for playing audio clips
• Multiple clips can be played simltaneously
• Created using the getAudioClip() method of the
applet context
• Can play the audio clip using
• play()
• loop()
IMAGING
• Defined by the Image class
• BufferedImage can be used to achieve buffering
during image rendering
• Use getImage() of applet context to create a
Image object
• Use the drawImage() method in the Graphics class
to render images
ADVANCED FEATURES
• Defined in the java.awt.image package
• ImageProducer : a source of image data
• ImageConsumer : a user of image data
• ImageObserver : asynchronous notification on the image
• Defines color models to be used
• Defines some image filters
TRACKING THE MEDIA
• Useful for synchronous media preparation
• Defined in the MediaTracker class
• Applicable to both audio and images, but only images
supported currently
tracker = new MediaTracker(this);
for (int i = 0; i < 5; i++)
tracker.addImage(anim[i], 1);
for (int i = 0; i < 5; i++)
tracker.waitForID(i);
LOADING WEB PAGES
• Java applets can load other web pages
• Use the showDocument() method of the applet
context
• Can also be used to address framesets
• _self : same frame
• _parent : applet’s parent frame
• _top : top-level frame of applet
• _new : a new top-level window
• name : specified frame name
INTER-APPLET
COMMUNICATION
• Applets within the same applet context can
communicate with each other
• Obtain the object reference of the other applets using
• void getApplet(String);
• Enumeration getApplets();
• Communicate by invoking public methods
SCRIPTING APPLETS
• Help in communicating with applets from an external
entity
<SCRIPT LANGUAGE=VBScript>
Sub Update_onClick()
Marquee.setMessage(Message.Value)
End Sub
</SCRIPT>
<INPUT TYPE="Text" NAME="Message"
VALUE="">
<INPUT TYPE="Button" NAME="Update"
VALUE="Update">
REVIEW
• AWT offer capabilities like context menus, clipboard
support etc.
• Applet contexts help in
• rendering images and playing audio
• loading web pages
• inter-applet communication

More Related Content

Similar to AWT Enhancements in V1.1 - Supporting Richer GUI Development (20)

PDF
27 applet programming
Ravindra Rathore
 
PPTX
GUI (graphical user interface)
rishi ram khanal
 
PPTX
Python Graphical User Interface and design
VardhanKulkarni
 
PDF
GUI.pdf
Poornima E.G.
 
PPTX
What's new in Xamarin.iOS, by Miguel de Icaza
Xamarin
 
PPT
Applets 101-fa06
nrayan
 
PPT
Java1 in mumbai
vibrantuser
 
PPTX
introduction to c #
Sireesh K
 
PPT
graphical user interface using python easy
ravipati23phd7217
 
PPTX
java- Abstract Window toolkit
Jayant Dalvi
 
PDF
Java Foundation Classes - Building Portable GUIs
Arun Seetharaman
 
PPT
Swing and Graphical User Interface in Java
babak danyal
 
PPTX
Java For beginners and CSIT and IT students
Partnered Health
 
PDF
Gui programming (awt)
Ravi_Kant_Sahu
 
PPTX
object oriented programming examples
Abdii Rashid
 
PDF
Applet in java
Jancypriya M
 
PPTX
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
Jorge Hidalgo
 
PPTX
Presentation - Windows App Development - II - Mr. Chandan Gupta
MobileNepal
 
PPTX
Java-Intro.pptx
VijalJain3
 
PPTX
Unit3 part3-packages and interfaces
DevaKumari Vijay
 
27 applet programming
Ravindra Rathore
 
GUI (graphical user interface)
rishi ram khanal
 
Python Graphical User Interface and design
VardhanKulkarni
 
GUI.pdf
Poornima E.G.
 
What's new in Xamarin.iOS, by Miguel de Icaza
Xamarin
 
Applets 101-fa06
nrayan
 
Java1 in mumbai
vibrantuser
 
introduction to c #
Sireesh K
 
graphical user interface using python easy
ravipati23phd7217
 
java- Abstract Window toolkit
Jayant Dalvi
 
Java Foundation Classes - Building Portable GUIs
Arun Seetharaman
 
Swing and Graphical User Interface in Java
babak danyal
 
Java For beginners and CSIT and IT students
Partnered Health
 
Gui programming (awt)
Ravi_Kant_Sahu
 
object oriented programming examples
Abdii Rashid
 
Applet in java
Jancypriya M
 
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
Jorge Hidalgo
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
MobileNepal
 
Java-Intro.pptx
VijalJain3
 
Unit3 part3-packages and interfaces
DevaKumari Vijay
 

More from Arun Seetharaman (13)

PDF
Implementing Load Balancing in COM+ Applications
Arun Seetharaman
 
PDF
Advanced Windows DNA Scripting with Visual InterDev
Arun Seetharaman
 
PDF
Implementing DHTML Behavior Script Components
Arun Seetharaman
 
PDF
Creating Data-based Applications Using DHTML
Arun Seetharaman
 
PDF
COM Events for Late-bound Delivery of Information
Arun Seetharaman
 
PDF
Understanding Windows NT Internals - Part 4
Arun Seetharaman
 
PDF
Understanding Windows NT Internals - Part 5
Arun Seetharaman
 
PDF
Understanding Windows NT Internals - Part 3
Arun Seetharaman
 
PDF
Understanding Windows NT Internals - Part 1
Arun Seetharaman
 
PDF
Understanding Windows NT Internals - Part 2
Arun Seetharaman
 
PDF
OLE DB Provider Development - Encapsulating a Service Provider
Arun Seetharaman
 
PDF
OLE DB 2.0 Architecture - Supporting Remote Data Exchange
Arun Seetharaman
 
PDF
Data Structures in Java and Introduction to Collection Framework
Arun Seetharaman
 
Implementing Load Balancing in COM+ Applications
Arun Seetharaman
 
Advanced Windows DNA Scripting with Visual InterDev
Arun Seetharaman
 
Implementing DHTML Behavior Script Components
Arun Seetharaman
 
Creating Data-based Applications Using DHTML
Arun Seetharaman
 
COM Events for Late-bound Delivery of Information
Arun Seetharaman
 
Understanding Windows NT Internals - Part 4
Arun Seetharaman
 
Understanding Windows NT Internals - Part 5
Arun Seetharaman
 
Understanding Windows NT Internals - Part 3
Arun Seetharaman
 
Understanding Windows NT Internals - Part 1
Arun Seetharaman
 
Understanding Windows NT Internals - Part 2
Arun Seetharaman
 
OLE DB Provider Development - Encapsulating a Service Provider
Arun Seetharaman
 
OLE DB 2.0 Architecture - Supporting Remote Data Exchange
Arun Seetharaman
 
Data Structures in Java and Introduction to Collection Framework
Arun Seetharaman
 
Ad

Recently uploaded (20)

PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
Lifting and Rigging Safety AQG-2025-2.pptx
farrukhkhan658034
 
PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
PDF
GITLAB-CICD_For_Professionals_KodeKloud.pdf
deepaktyagi0048
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
HydITEx corporation Booklet 2025 English
Георгий Феодориди
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
Productivity Management Software | Workstatus
Lovely Baghel
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
PDF
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Lifting and Rigging Safety AQG-2025-2.pptx
farrukhkhan658034
 
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
GITLAB-CICD_For_Professionals_KodeKloud.pdf
deepaktyagi0048
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
HydITEx corporation Booklet 2025 English
Георгий Феодориди
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Productivity Management Software | Workstatus
Lovely Baghel
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
Ad

AWT Enhancements in V1.1 - Supporting Richer GUI Development

  • 2. OVERVIEW • AWT Enhancements • Popup menus • Scroll pane • Clipboard • The AppletContext object • Audio and Images • Inter-applet communication
  • 3. DESKTOP COLORS • The new SystemColor class helps Java detect the color scheme set for the desktop • Programmers can uses these colors by accessing the final members of the class • activeCaption : Caption background color • contolText : Control’s text color • desktop : Desktop’s background color • menuText : Menu’s text color • window : Window’s background color
  • 4. POPUP MENUS • Dynamically popped menus as specified position within the component • Defined the PopupMenu class of Java • Invoke the show method to popup the menu • void show(Component,int,int) • If the popup menu object is used in place of a menu item, the show() cannot be invoked
  • 5. POPUP MENU - AN EXAMPLE public void mouseReleased( MouseEvent evt) { if (evt.isPopupTrigger()) { popup.show(evt.getSource(), evt.getX(), evt.getY()); } else { System.out.println("no popup"); } }
  • 7. SCROLLING CONTAINERS • Container implementing automatic scrolling for a single child component • Needed in situations where the viewport is smaller than the window • Clipping the child’s contents appropriately depending on the scroll position
  • 8. THE SCROLLPANE CLASS • Display policy can be set • as needed • always • never • Placement is controlled by platform-specifc properties • Implements the Adjustable interface, which can be used for fine tuning
  • 9. SCROLLPANE - AN EXAMPLE ScrollPane sp = new ScrollPane(); sp.getHAdjustable().setUnitIncrement(2); sp.getVAdjustable().setUnitIncrement(2); sp.add(new ImageComponent( getToolkit().getImage(filename))); add(sp, BorderLayout.CENTER); setSize(200, 150);
  • 11. DATA TRANSFER • Clipboard and Drag-drop are the two major models of data transfer • Data transfer occurs using “flavors” defined by the Transfer APIs • The flavors to be used for data transfer encapsulate the various MIME types • The java.awt.datatransfer package caters to the needs of these operations
  • 12. CLIPBOARD • Clipboard is a globally shared memory • The toolkit has an instance of a clipboard, that uses the system clipboard • Class willing to write to a clipboard need to implement the ClipboardOwner interface • Data flavors need to be compatible for transfer of data using clipboard
  • 13. WRITING TO A CLIPBOARD class ClipboardSource extends Frame implements ClipboardOwner { TextArea ta = new TextArea(); void setContents() { String s = ta.getSelectedText(); StringSelection contents = new StringSelection(s); getToolkit().getSystemClipboard( ).setContents(contents, this); } }
  • 15. READING FROM CLIPBOARD Transferable t = getToolkit(). getSystemClipboard().getContents( this); if(t.isDataFlavorSupported( DataFlavor.stringFlavor)) { String str = t.getTransferData( DataFlavor.stringFlavor); }
  • 16. DRAG AND DROP • Uses the same data transfer mechanism • Discussed later as a part of JFC
  • 17. APPLET CONTEXT • Corresponds to the applet’s execution environment • In the normal execution circumstances, this object is the browser • Defined by the AppletContext interface • Use the getAppletContext() method to access the context object
  • 18. USING AUDIO • Defined by the AudioClip interface • A simple abstraction for playing audio clips • Multiple clips can be played simltaneously • Created using the getAudioClip() method of the applet context • Can play the audio clip using • play() • loop()
  • 19. IMAGING • Defined by the Image class • BufferedImage can be used to achieve buffering during image rendering • Use getImage() of applet context to create a Image object • Use the drawImage() method in the Graphics class to render images
  • 20. ADVANCED FEATURES • Defined in the java.awt.image package • ImageProducer : a source of image data • ImageConsumer : a user of image data • ImageObserver : asynchronous notification on the image • Defines color models to be used • Defines some image filters
  • 21. TRACKING THE MEDIA • Useful for synchronous media preparation • Defined in the MediaTracker class • Applicable to both audio and images, but only images supported currently tracker = new MediaTracker(this); for (int i = 0; i < 5; i++) tracker.addImage(anim[i], 1); for (int i = 0; i < 5; i++) tracker.waitForID(i);
  • 22. LOADING WEB PAGES • Java applets can load other web pages • Use the showDocument() method of the applet context • Can also be used to address framesets • _self : same frame • _parent : applet’s parent frame • _top : top-level frame of applet • _new : a new top-level window • name : specified frame name
  • 23. INTER-APPLET COMMUNICATION • Applets within the same applet context can communicate with each other • Obtain the object reference of the other applets using • void getApplet(String); • Enumeration getApplets(); • Communicate by invoking public methods
  • 24. SCRIPTING APPLETS • Help in communicating with applets from an external entity <SCRIPT LANGUAGE=VBScript> Sub Update_onClick() Marquee.setMessage(Message.Value) End Sub </SCRIPT> <INPUT TYPE="Text" NAME="Message" VALUE=""> <INPUT TYPE="Button" NAME="Update" VALUE="Update">
  • 25. REVIEW • AWT offer capabilities like context menus, clipboard support etc. • Applet contexts help in • rendering images and playing audio • loading web pages • inter-applet communication