Java Reference
In-Depth Information
5. Adding the previous exercise's support forantialiasing slows downrender-
ing. As a result, you may notice that it takes time to redraw the pseudo-
splashscreenandthattheGUI'sresponsetomouseclicksbecomessluggish.
Youcansolvethisproblemfornonresizablecomponentsbyprecreatingthe
noninverted and inverted images with the help of the BufferedImage
class.Createanewversionof SplashCanvas thataccomplishesthistask.
6. Becauseyoumightfind Figure7-29 ' sblurredimagehardtodistinguishfrom
Figure7-10 , modify BIP byaddingaBlurMoremenuitem.Theassociated
listenerwillcreatea5-by-5-elementkernelwitheachelementsetto 1.0f/
25.0f .Involvingmoreneighborpixelsresultsinmoreblurring.Compare
the Blur More and Blur results to see this for yourself.
7. The ColorSpace and ColorConvertOp classes can be used to create
agrayscaleversionofacoloredimage.IntroduceaGrayscalemenuitemto
BIP andhaveitsassociatedlistenerusetheseclassestogenerateagrayscale
version of the rose.
Summary
AbstractWindowToolkitisJava'soriginalwindowingsystem-independentAPIforcre-
ating GUIs that are based on components, containers, layout managers, and events.
AWT also supports graphics, colors, fonts, images, data transfer, and more.
Swing is a windowing system-independent API for creating GUIs that are based on
components, containers, layout managers, and events. Although Swing extends AWT
(you can use AWT layout managers and events in your Swing GUIs), this API dif-
fers from its predecessor in that Swing GUIs can look and feel the same when run on
anywindowingsystemor(atthedeveloper's discretion) adoptthelookandfeelofthe
windowingsystemonwhichit'srunning.Furthermore, Swing'snoncontainer compon-
entsandafewofitscontainersarecompletelymanagedbyJavasothattheycanhave
whateverfeaturesarenecessary(suchastooltips);thesefeaturesareavailableregardless
ofthewindowingsystem.Also,Swingcanoffercomponentsthatmightnotbeavailable
on every windowing system; for example, tables and trees.
Finally,Java2DisacollectionofAWTextensionsthatprovideadvancedtwo-dimen-
sionalgraphical,textual,andimagingcapabilities.ThisAPIoffersaflexibleframework
for developing richer GUIs through line art, text, and images.
Applicationsofteninteractwiththefilesystemtooutputdatatoand/orinputdatafrom
files. Chapter8 introducesyoutothestandardclasslibrary'sclassicI/OAPIsforaccom-
plishing these tasks.
Search WWH ::




Custom Search