erhapsthesinglebiggestchallengeinwritingJavaapplicationsisdealingwithUIissues.Regardlessoftheapplication'spowerandflexibility,peoplewillalwayswantittolookfamiliar—tolooklikeaWindowsapplication.WithJGoodiesyoucangivethemwhattheywant,andawholelotmorebesides!Javahasneverreallybeenacompetitorforpremiumdesktopsystems.Itsverynaturebeingthatofwriteonce,runanywhereleadstoalowestcommondenominatorapproach.Forexample,someoperatingsystemssupportmicewiththreebuttons,somewithtwoandsomewithonlyone.ForaJavaapplicationtorun'everywhere,'itcanonlysupportasinglemousebutton.Theextrabuttonfunctionalitythatcouldbeavailableonothersystemsislost.Thereareotheruserinterfacewidgetsanddesignpatternsthataresimilarlyunexploitable,andtheultimateeffectisthatJavaneverreallypenetratedtheapplicationsmarket.VisualBasicreinedsupreme.However,whenitcomestomiddlewareorserverware,Javaprovidesanamazingproposition.Thesamecoderunsyourtransactions,youranalytics,yourbusinessappsregardlessoftheoperatingplatform!IsSolaristooexpensive?ReplaceitwithMicrosoft.Yoursoftwarewillstillwork.IsMicrosofttoounstable?ReplaceitwithLinux.Yoursoftwarewillstillwork!However,theJava-baseddesktopmaybemakingacomeback.SomeofthependingAPIsfromSunaswellasinnovationscomingoutoftheopen-sourcecommunityareredrawingthemapandwillchangetheperceptionofhowJavaworksinthedesktopapplicationenvironment.Forexample,BEA'sWeblogicWorkshop8.1,sportsatrulybeautifuluserinterfaceusingJava.OracleandothersarealsodevelopingJavaIDEswithgreat-lookingJavaUIs.Oneofthesetransformativelook-and-feelAPIsisJGoodies.JGoodiesisfreelyavailableandcanbeusedinyourownapplications.BybrowsingtheJGoodiessiteat(e.g.c:\jgoodieslooks).TheresultshouldlooklikeFigure2.ForthepurposesofthisarticleyouwillonlyneedtheLookandFeelAPI,butinordertocompileandtestthedemoapplicationfromtheLookandFeelAPI,youwillneedtheJARfilesthatcomewiththeFormsAPIaswell.TherearetwowaystoworkwiththeJGoodiesLookandFeelAPI:YoucanreferdirectlytoJGoodiesclasses,whichisdoneatcompiletime.Thisisthepreferredmethodandgenerallylesspronetoerrorsthanindirectreferences.Itrequiresyoutoimporttheprecompiledclassestoyourproject,soyoushouldonlyuseitifyouFigure1.PreviewingtheGoodies:AsampleuserinterfacemadeusingtheJGoodiesAPIisshown.Figure2.UnpacktheGoodies:ThisiswhatyourunzippedJGoodiesdirectorystructureshouldlooklikebeforeyoubegindeveloping.knowthattheclasseswillbepresentatruntime.Example:try{UIManager.setLookAndFeel(newPlastic3DLookAndFeel());}catch(Exceptione){}Indirectreferenceusingclassnames.Ifyouarenotsurewhethertheclasseswillbyavailableatruntimeyoucanreferencetheminthismanner.Example:try{UIManager.setLookAndFeel(com.jgoodies.plaf.windows.ExtWindowsLookAndFeel);}catch(Exceptione){}Theclassmustbeoneofthefollowing:com.jgoodies.plaf.windows.ExtWindowsLookAndFeelcom.jgoodies.plaf.plastic.PlasticLookAndFeelcom.jgoodies.plaf.plastic.Plastic3DLookAndFeelcom.jgoodies.plaf.plastic.PlasticXPLookAndFeelThePlasticthemesuseadefaultcolorschemethatisappropriateforyouroperatingsystem.HoweveramethodsetMyCurrentThemeisprovidedthatallowsyoutooverridethis.Forexample:PlasticLookAndFeel.setMyCurrentTheme(newDesertBlue());Here,DesertBlue()isacolorthemespecifiedinthecom.jgoodies.plaf.plastic.themepackage.JGoodiesValidationExampleSeptember27,2008at11:26am(JavaSwing)viewsourceprint?01importjavax.swing.BorderFactory;02importjavax.swing.InputVerifier;03importjavax.swing.JComponent;04importjavax.swing.JFrame;05importjavax.swing.JLabel;06importjavax.swing.JPanel;07importjavax.swing.JTextField;0809importcom.jgoodies.forms.builder.DefaultFormBuilder;10importcom.jgoodies.forms.layout.FormLayout;1112publicclassInputVerifierExampleextendsJPanel{13privateJLabelvalidationLabel;1415publicInputVerifierExample(){16DefaultFormBuilderformBuilder=newDefaultFormBuilder(newFormLayout(right:pref,3dlu,p:g));17formBuilder.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));1819JTextFieldjavaField=newJTextField();20JTextFieldswingField=newJTextField();21this.validationLabel=newJLabel();2223javaField.setInputVerifier(newStrictInputVerifier(Java));24swingField.setInputVerifier(newStrictInputVerifier(Swing));2526formBuilder.append(JavaField:,javaField);27formBuilder.append(SwingField:,swingField);28formBuilder.appendParagraphGapRow();29formBuilder.append(validationLabel,3);3031add(formBuilder.getPanel());32}3334privateclassStrictInputVerifierextendsInputVerifier{35privateStringvalidString;3637publicStrictInputVerifier(StringvalidString){38this.validString=validString;39}4041publicbooleanverify(JComponentinput){42JTextFieldtextField=(JTextField)input;43if(validString.equals(textField.getText())){44validationLabel.setText();45returntrue;46}else{47validationLabel.setText(Fieldmustonlycontain+this.validString);48returnfalse;49}50}51}5253publicstaticvoidmain(String[]a){54JFramef=newJ