DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Spring Rich Client - Part 1

Spring Rich Client - Part 1

Peter Karussell user avatar by
Peter Karussell
·
Jun. 20, 08 · Java Zone · Interview
Like (0)
Save
Tweet
27.60K Views

Join the DZone community and get the full member experience.

Join For Free

today i will start a series about the great swing framework called spring rich client (src). the 1.0.0 version was released in march 2008 and it is not inactive as i thought before.

you can get more information about src from:

  • the forum
  • the german documentation or
  • the english documentation .

why i listed the forum as the first point? because for a beginner like me it was the best source of information (after the samples).

so, let us set up a hello world example.

  • download the spring rich client 1.0.0 from here (19 mb, apache license 2.0).
  • download my hello world skeleton (a netbeans 6.1 project, 60 kb) or use the spring-richclient-archetype from the download bundle of src, where you have to install maven before you can compile and run it.

if you use my hello world skeleton you should open it in netbeans, right click on the project node and resolve reference problems. then go to the place where you have unzipped the src and add the first jar file. the other jar files should be added automagically for you.

the project with dependencies would be about 2.7 mb, it is not a small overhead, but okay, i think. as an example for the reader one can compare it to the minimal size of the netbeans or eclipse rcp.

now it is time to start the project with f6 or run->’run main project’. you should see the frog-splashscreen and the final view:

now let me explain several things that one could customize in src. please see the resources section for the result of customization.

as the first point i wanted to know how easy it is to introduce docking capabilities (vl docking). it was really easy!

  • add spring-richclient-docking.jar and vldocking.jar
  • and change 2 things in the richclient-application-context.xml file:
  • change class of initialview to org.springframework.richclient.application.docking.vldocking.vldockingviewdescriptor
  • add a applicationpagefactory to the richclient-application-context.xml

then you can add a new window to see the results of dragging:

  • create the class view2
  • add the following to the richclient-application-context.xml:

    <bean id=”view2″
    class=”org.springframework.richclient.application.docking.vldocking.vldockingviewdescriptor”>
    <property name=”viewclass” value=”de.peterk.springr.view2″ />
    <property name=”autohideenabled” value=”true” />
    <property name=”closeenabled” value=”true”/>
    </bean> 
    


    and you are done! just start the application go to windows->show view->view2

now, how easy is it to use your own layout? configuring the look and feel:

  • remove the lookandfeelconfigurer and add instead:

    <bean id=”lookandfeelconfigurer” class=”de.peterk.springr.ui.kunststoffconfigurer”></bean> 
    
  • remove looks.jar: 350 kb
  • add kunststoff : 17 kb
  • add the kunststoffconfigurer class to the source package

okay, then changing the splash screen is trivial: just overwrite the splash-screen.png or change the path in the richclient-startup-context.xml file.

now we should adjust the size of the view, this can be done with 2 lines in the method simplelifecycleadvisor.onprewindowopen:

rectangle rect = graphicsenvironment.getlocalgraphicsenvironment().getmaximumwindowbounds();
configurer.setinitialsize(new dimension(rect.width, rect.height));

and to translate the messages simply copy all property files to e.g. file_de.properties and translate them! in our case it means “cp message.properties message_de.properties”. if you want to add a translateable tool tip of the initalview-label just use:

  • lblmessage.settooltiptext(getmessage(”initialview.tooltip”));
  • in initialview.createcontrol and add the property initialview.tooltip to the property file.

to set a keyboard shortcuts e.g. to leave the application. you need to add one line to the message.properties file

  • exitcommand.label=exit@ctrl q

another interesting action (in src they will be called commands) could be restart. so how can we add the action into the menu? you have to add

  • restartcommand.label=restart@ctrl r
  • in the message.properties file and use
  • application.instance().start(); application.instance().getactivewindow().close();
  • within your restartcommand class. then add
  • <bean class=”de.peterk.springr.restartcommand” />
  • into the commands-context.xml (e.g. after <value>propertiescommand</value> in filemenu)

the final result is:

resources

here you can download the extended “hello more” sample (a netbeans 6.1 project about 90 kb, without dep). the full project was 2.9 mb.

conclusion

one can say that spring rich client is a powerful jar collection :-). but i would say src is a great way for your next swing application!

it is very intuitive to use: the whole sample (including to write this blog) took me only about 6 hours. i think you could be really productive with it! in the case i published the documents with mistakes: please leave your comment here!

from http://karussell.wordpress.com/

Spring Framework

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 6 Things Startups Can Do to Avoid Tech Debt
  • How to Generate Fake Test Data
  • Composable Architecture
  • Ultra-Fast Microservices: When Microstream Meets Wildfly

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo