82 Swing and Java 2D Demos

Filthy Rich Clients is available and several readers already received their copy. To make sure you can follow all of our examples easily, Chet and I just released the demos of the final chapters: Static Effects, Dynamic Effects and Animated Transitions.

These chapters’ demos are our favorites so make sure to check them out!

The official web site and the java.net project page now host a total of 82 demos, all available under the BSD license. We hope you will enjoy those demos as much as you will enjoy the book.

45 Responses to “82 Swing and Java 2D Demos”

  1. benoit.r says:

    Delivery estimate: 2007 October 2, 2007 – October 17, 2007 :'(

    I’ll wait :D

  2. Romain Guy says:

    That’s a bug on Amazon’s part. Some readers who pre-ordered it through Amazon already received a copy.

  3. Richard Osbaldeston says:

    Is that why amazon.co.uk is telling me to wait until the 28th of September too? or are there a lot of jokes about the English that need to be removed from our edition ;)

  4. benoit.r says:

    it would be a good news if the book was already sent :) (I pre-ordered it on August 8)

  5. Chet Haase says:

    Richard: I wouldn’t be surprised if the later date for amazon.uk is real. I think the US market gets it first, and then it makes its way elsewhere.

    Besides, won’t the book have to be translated into proper English first? Are the readers in the UK going to understand what we mean when we talk about “color”, or will they be colour-blind?

    There is actually one joke about the English (actually, the English language) that I can recall, but I think that one will work on both sides of the Atlantic (if you sea my point).

    Chet.

  6. honsali says:

    et la version fran├žaise, c’est pour quand :)

  7. Daniel says:

    Hi Romain,
    I’ve downloaded all the demos codes from your book and tested it.

    They are really cool. I’ve got one problem.
    When I test Animated Transitions, The Image Browser displays a browser to see the images. However, when I move the slider, I got the following Exception:
    Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException: glassPane cannot be set to null.
    at javax.swing.JRootPane.setGlassPane(Unknown Source)
    at org.jdesktop.animation.transitions.ScreenTransition$1.end(ScreenTransition.java:306)
    at org.jdesktop.animation.timing.Animator.end(Animator.java:755)
    at org.jdesktop.animation.timing.Animator.stop(Animator.java:660)
    at org.jdesktop.animation.transitions.ScreenTransition.start(ScreenTransition.java:205)
    at ImageBrowser.stateChanged(ImageBrowser.java:189)
    at javax.swing.JSlider.fireStateChanged(Unknown Source)
    at javax.swing.JSlider$ModelListener.stateChanged(Unknown Source)
    at javax.swing.DefaultBoundedRangeModel.fireStateChanged(Unknown Source)
    at javax.swing.DefaultBoundedRangeModel.setRangeProperties(Unknown Source)
    at javax.swing.DefaultBoundedRangeModel.setValue(Unknown Source)
    at javax.swing.JSlider.setValue(Unknown Source)
    at javax.swing.plaf.basic.BasicSliderUI.scrollByUnit(Unknown Source)
    at javax.swing.plaf.metal.MetalSliderUI.scrollDueToClickInTrack(Unknown Source)
    at javax.swing.plaf.basic.BasicSliderUI$TrackListener.mousePressed(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

  8. Mehlam Kalverts says:

    Hi Romain,

    Can’t wait to get the book. Amazon is being slow. I pre-ordered it on August 2.

  9. benoit.r says:

    Daniel, you can fix it with that :

    if(!transition.getAnimator().isRunning()){
    transition.start();
    }

    in stateChanged(ChangeEvent ce) ;)

  10. Daniel says:

    Hi benoit.r,
    Thank you for your help. It works.

  11. Mike says:

    Psh, I’ve had it on order since before JavaOne! At least I still have the roughcuts available on my Safari subscription until I can get my hands on the finished product! ;)

  12. Chet Haase says:

    Thanks for the bug report – I’ll try to get that fixed at the source…

    Chet.

  13. Rajesh says:

    Excellect book especially who has bit knowledge of Swing,2D & Thread(especially EDT).
    Book is cool in ealier chapter most of trick are thier in various blogs of Romain,Chet etc on java.net.
    I felt tough Animation section bcoz its new for me,but it explain right way to do it.
    Both Chet & Romain have done excellect job to make such a difficult topics in easy way,But still there is room for improvements to make more simpler to understand.

    GOOD LUCK & KEEP UP THE GOOD WORK

    Thanks,
    Rajesh

  14. Willis Morse says:

    I just got the book, and it is great! Even better than the specific techniqies is the fact that you’ve collected all the weird quirks in Java2D into one place. Now I don’t have to remember all the gotchas with LayeredPanes, for instance.

    What is the status of the AnimatedTransitions library? Is it open, and is it available anywhere? I’d like to be able to step through the source to get a better idea how to use it.

    Also, any chance of putting the demo classes inside seperate packages? It’s really handy to make one IDE project for all examples, but it won’t compile because there are duplicate classes like ApplicationFrame in the root package.

    Thanks for all the hard work,
    Willis Morse

  15. Chet Haase says:

    Willis: I’m hoping to post the AnimTrans library in the next few days. I’m still waiting for approval on the source code to be able to post it as a project (normal Big Company stuff), but hopefully that will happen soon (just cleared out a logjam on that last week).

    Don’t know about the package change stuff – I’ll chat with Romain and see.

    Glad you’re enjoying the book!

    Chet.

  16. Daniel says:

    I am excited about the book but I am not lucky to get the book soon because I ordered the book on August 14 and Amazon says that I will receive it in Septempber 17 – October 3.

    Why it takes so long?

  17. Romain Guy says:

    I am glad you guys liked the book.

    Willis: I’m not sure it would be that useful. We used one project per demo to make it easier to find each demo’s main class and to restrict the learning scope. Note that you can easily open several projects at once in NetBeans (that’s what we did.)

  18. ez says:

    I too am excited to read this book… mostly because I have a pretty slick UI going (using SubstanceLNF and some hacks) and want to improve it. I am pretty disappointed in the publisher, though. I have a conference in early September and I can’t seem to actually get the book anywhere (my corporate Safari account doesn’t have it, for some reason). Meaning, I’d like to polish up my stuff for a demo… but with no access :( I can’t find a single vendor that has it in stock (Amazon, Bookpool, etc).

  19. Chet Haase says:

    ez: I’m pretty disappointed by Amazon’s fits and starts in getting this rolling, but I’ve heard of some people getting the book earlier through Safari (ordering the hardcopy, not just the online version). Also, bn.com says the book is shipping immediately (although I don’t know whether people have received copies from there yet). And some stores *should* start getting copies soon (depending on whether a particular store would carry such a weighty tome). And presumably ordering direct from the publisher would work, although I don’t have personal experience with that, either.

    Chet.

  20. Fabrice says:

    Is there any plans to be able to buy and download the PDF instead of being “forced” to subscribe to O’Reilly Safari ??

    That would make a lot of sense as many developers do not care any more with “paper” books but prefer ebooks…

  21. Romain Guy says:

    Wow, you’re the first person I hear say he prefers ebooks to real books :)

  22. Fabrice says:

    Basically, eBooks have huge advantages compared to paper books and helps preserving trees and mother nature, dont they ?

    Developers should be more respectfull about this.

    Then, having eBooks on your hard drive / pocket device (like the Sony Reader or any other) allow to read and refer to them everywhere you are ;-)

    Any response for its availability in PDF ?

  23. Romain Guy says:

    And they have a great drawback: reading on a screen is tedious and annoying.

    The PDF is available on Safari :)

  24. Chet Haase says:

    Fixed the bug in the java.net project site for ImageBrowser (still have to upload the fixed jarfile). It’s not a complete fix, as it ignores changes to the slider value that happen in quick succession. But heck, it’s a demo -it works well enough to get the point across (I think).

    Fabrice: No idea on the PDF – I’ve asked the publisher.

    Chet.

  25. Chet Haase says:

    Fabrice: ignore my comment on the PDF, which crossed wires with Romain’s. He seems to have a better answer.

  26. Fabrice says:

    Romain,

    It seems that you have never used a Sony Reader with EInk technology: this is NOT tedious nor annoying at all. In fact, now I read much more traditional book than before.

    Concerning the PDF, my question was if you intend to have out of Safari. Lots of potential reader dont want a Safari subscription for 1 book they have interest to.

  27. Romain Guy says:

    I have used a Sony Reader and I just hate it. Up to one second to switch to the next page with an annoying flash?! Reading on a screen is still very annoying.

  28. Rod Dunne says:

    Amazon just informed me that my copy has shipped here in Canada, and they provided a tracking number. I did preorder it though.

  29. Daniel says:

    Chet, Romain,
    I try the demo for Static Effects with TextHightlighting. It is really cool when I
    see the VistaSearchDialog displayed.

    Questions:
    1) How can I make the dialog resizable?
    2) When I replace the SearchPanel with JTextArea, and do textArea.setOpaque(false), it does not work. The text area displayed but there is no translucency. How can it be?

  30. Romain Guy says:

    Daniel, you can make the dialog resizable by adding a mouse motion listener and detecting drags in on the edges/corners. As for the text area, did you put it inside of a JScrollPane? I used JTextArea.setOpaque(false) with great success in the Aerith demo.

  31. JPuppy says:

    I placed my Amazon(Prime) order 3 days ago, and the status has been updated to Shipping Soon. I can’t even change the order now, so I assume it’s being boxed as I write this.

    I hope you guys that preordered have yours coming soon….

  32. Romain Guy says:

    Our publisher told us that Amazon should have received a shipment yesterday or today. So it’s coming really soon now :)

  33. cmack says:

    Received mine yesterday! I pre-ordered mine pretty much as soon as it was possible; it’s been a loooong wait Romain and Chet! :P

  34. Chet Haase says:

    Tell me about it – it’s been a lifetime in the past year…

    Chet.

  35. JPuppy says:

    My book is sitting on the UPS truck out for delivery. I love getting stuff, but this is the most agonizing part!

  36. Daniel says:

    Romain, Chet
    Which Java Swing Docking Framework (OPEN SOURCE) is the best in your opinion?

  37. Romain Guy says:

    None of us ever used a docking framework.

  38. Daniel says:

    Thank you Romain,
    Another question:
    From the filthyrichclients.org Web site, I noticed that when I select the menu from the right side of the Web page, you and Chet make the page move to the new one.
    You do this using Java Script? or Java Swing?
    Can you have the same effect using Java Swing for Desktop application?

  39. Romain Guy says:

    It’s JavaScript, CSS and HTML. And you could definitely do the same in a Swing application.

  40. Daniel says:

    Romain, Chet,
    I’ve got Filthy Rich Client book last night. Very excited to read it.

    You guys have done a great job with this book.

    The book contains very good info about Java Swing and 2D and a lot of tips.

    Did you see movies “Spider man” or “Harry Potter”? I believe that you should publish the Filthy Rich Client 2, and 3, and so on because the book is very good.

  41. Romain Guy says:

    Daniel, thanks a lot!

  42. Nikhil says:

    i just came across this site….
    1st of all thank u very much… to showing a way how to perform animation on java… excellent…
    i tried modifying it in my own way…
    another way i tried doing is… (i am using netbeans)…as i wanted to bring u’r animation above all my topComponents so i took the whole windowcomponent added the component on it, i suppose u using a glasspane of a frame to perform animation… all the components i have added goes behind…. any way u can suggest to bring them above all the components…