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

PDF
PPTX
tL19 awt
PPTX
Mod_5 of Java 5th module notes for ktu students
PPTX
Java applet
PPTX
L18 applets
PPTX
Applet intro
PPTX
Applets
PPTX
Concurrency Programming in Java - 02 - Essentials of Java Part 1
tL19 awt
Mod_5 of Java 5th module notes for ktu students
Java applet
L18 applets
Applet intro
Applets
Concurrency Programming in Java - 02 - Essentials of Java Part 1

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

PDF
27 applet programming
PPTX
GUI (graphical user interface)
PPTX
Python Graphical User Interface and design
PDF
GUI.pdf
PPTX
What's new in Xamarin.iOS, by Miguel de Icaza
PPT
Applets 101-fa06
PPT
Java1 in mumbai
PPTX
introduction to c #
PPT
graphical user interface using python easy
PPTX
java- Abstract Window toolkit
PDF
Java Foundation Classes - Building Portable GUIs
PPT
Swing and Graphical User Interface in Java
PPTX
Java For beginners and CSIT and IT students
PDF
Gui programming (awt)
PPTX
object oriented programming examples
PDF
Applet in java
PPTX
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
PPTX
Presentation - Windows App Development - II - Mr. Chandan Gupta
PPTX
Java-Intro.pptx
PPTX
Unit3 part3-packages and interfaces
27 applet programming
GUI (graphical user interface)
Python Graphical User Interface and design
GUI.pdf
What's new in Xamarin.iOS, by Miguel de Icaza
Applets 101-fa06
Java1 in mumbai
introduction to c #
graphical user interface using python easy
java- Abstract Window toolkit
Java Foundation Classes - Building Portable GUIs
Swing and Graphical User Interface in Java
Java For beginners and CSIT and IT students
Gui programming (awt)
object oriented programming examples
Applet in java
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
Presentation - Windows App Development - II - Mr. Chandan Gupta
Java-Intro.pptx
Unit3 part3-packages and interfaces
Ad

More from Arun Seetharaman (13)

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

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Spectroscopy.pptx food analysis technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Electronic commerce courselecture one. Pdf
PDF
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
sap open course for s4hana steps from ECC to s4
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
cuic standard and advanced reporting.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
Digital-Transformation-Roadmap-for-Companies.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Spectroscopy.pptx food analysis technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
Machine learning based COVID-19 study performance prediction

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