Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 16 - Pages: 2   [ 1 2 | Next ]
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

Easier Custom Components with Swing Fuse

URL: Easier Custom Components with Swing Fuse

At 10:46 AM on Nov 8, 2007, Michael Urban wrote:

Swing Fuse (actaully just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Read Daniel's article now .
1 . At 5:00 PM on Nov 8, 2007, Andrew McVeigh DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

what's the overlap with the resource management (injection?) in the Swing App Framework (JSR-296)?

Cheers,
Andrew
2 . At 5:14 PM on Nov 8, 2007, Romain Guy DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

Swing App Framework's resource management was inspired from Fuse. They are very similar but Fuse is more flexible and offer more features.
Romain Guy
Romain Guy's Java Weblog, #ProgX, Jext
3 . At 5:23 PM on Nov 8, 2007, Andrew McVeigh DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

a few questions spring to mind:

1. can appfuse be used with Swing App f'work? can it use the same config files?

2. what cases specifically can't the Swing App f'work handle?

I ask these questions, because it seems to me that once the Swing App f'work is eventually bundled with the JDK and goes into widespread use, people will make do with the injection facilities in it rather than using something else unless it is compelling.

Andrew
4 . At 6:35 PM on Nov 8, 2007, Daniel Spiewak wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

It's been a while since I've looked at the Swing Application Framework, but I'll try to answer from what I remember.

> 1. can appfuse be used with Swing App f'work? can it
> use the same config files?

Yes. No. Fuse is pretty flexible and doesn't really impose any sort of constraints on your application (beyond annotating field to inject, and even that is really optional). The application framework's config files are similar to Fuse's from what I remember, but different enough that significant conniptions would be required to make Fuse utilize them for resource loading. It's certainly possible, but not easy.

> 2. what cases specifically can't the Swing App f'work
> handle?

From what I remember, Fuse is more flexible in what values it can inject. More importantly, it can inject different types, parsing values differently for each type. Swing App Framework seems a bit more constrained in this regard.

> I ask these questions, because it seems to me that
> once the Swing App f'work is eventually bundled with
> the JDK and goes into widespread use, people will
> make do with the injection facilities in it rather
> than using something else unless it is compelling.

Agreed. I'll have to take a closer look at the app framework to decide, but based on what I know of Fuse and how it works in a large-scale Swing application, I'm totally sold on it. :-) I suppose that doesn't mean much, speaking as one of its developers, but I think I'd probably be as on about it even if I weren't involved in its internals.
Daniel Spiewak
ActiveObjects: an Easier Java ORM; Fuse: Resource Injection for Java
5 . At 7:39 PM on Nov 8, 2007, Kirill Grouchnikov wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

> Agreed. I'll have to take a closer look at the app
> framework to decide, but based on what I know of Fuse
> and how it works in a large-scale Swing application,
> I'm totally sold on it. :-) I suppose that doesn't

So speaking from a perspective of using this on a large-scale project - how would you compare Fuse with writing a custom theme for an existing LAF? At least in this example, it's all about the painting (colors, gradient stops), which can be done as a custom theme / skin.
6 . At 7:48 PM on Nov 8, 2007, Daniel Spiewak wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

> So speaking from a perspective of using this on a
> large-scale project - how would you compare Fuse with
> writing a custom theme for an existing LAF? At least
> in this example, it's all about the painting (colors,
> gradient stops), which can be done as a custom theme
> / skin.

Fuse is simultaneously both lower and higher level than writing your own LAF. Fuse by definition just loads and instantiates resources, reflectively injecting them into instance fields to make them accessible to your code. Thus, Fuse could very easily be utilized as the core of a custom LAF, handling the loading of things like gradients, colors, images, etc.

With that said, Fuse's primary *intended* use case is to load resources for use at the application level. Think of it like "CSS meets Swing".
Daniel Spiewak
ActiveObjects: an Easier Java ORM; Fuse: Resource Injection for Java
7 . At 7:50 PM on Nov 8, 2007, Romain Guy DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

You can, and I did, use Fuse to inject the values in a look and feel's UI delegates. It basically gives your look and feel themes for free. It also allows users to write their own themes using plain text files rather than creating a new class. And it saves the LaF writer the burden of writing his own parser.

Note that if you don't like Fuse's way of storing properties and values you can plug in your own parser very easily. Similarly you can plug in your own type converters.
Romain Guy
Romain Guy's Java Weblog, #ProgX, Jext
8 . At 8:05 PM on Nov 8, 2007, Kirill Grouchnikov wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

I'm just thinking on how i would go and use this approach in a skinnable LAF. Would you have a separate properties file for each one of the themes, and then construct the identifiers dynamically at runtime using the name of the current theme? And what happens when you want to provide an option to use a third-party theme implementation? I'm sure that these can be addressed, i'm just curious whether this is easier than having a theme interface (like MetalTheme) that defines getColor*** methods and then using those.

With the properties-based approach you fail at runtime (when the resource name in the Java class doesn't match the resource name in the properties file). And you still have the actual painting logic in the Java code, so you're still doing some Java2D coding. Would it be correct to assume that the main advantage of Fuse approach is that you don't need to recompile the program when you change the resources? Because the *. can be easily achieved by extracting the theme / gradient implementation into a painter layer.
9 . At 9:12 PM on Nov 8, 2007, Romain Guy DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

>Would it be correct to assume that the main advantage of Fuse approach is
>that you don't need to recompile the program when you change the
>resources?

That's the reason why I created Fuse. Fuse also allows you to reload/reinject everything at runtime, thus providing very fast "theme switching." So not only you do not need to recompile, you also do not need to restart the application.

>Would you have a separate properties file for each one of the themes, and
>then construct the identifiers dynamically at runtime using the name of the
>current theme?

Yes, one properties file for each theme and you don't need to construct identifiers. Fuse, by default, rely on the class and field names (even though you can override that with annotation and/or XML configuration files). When you load a properties file, Fuse will do the matching for you. That means switching theme will just be a metter of calling ResourceInjector.get("my-look-and-feel").load(themePropertiesFile).
Romain Guy
Romain Guy's Java Weblog, #ProgX, Jext
10 . At 10:06 PM on Nov 8, 2007, Daniel Spiewak wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

> That's the reason why I created Fuse. Fuse also
> allows you to reload/reinject everything at runtime,
> thus providing very fast "theme switching." So not
> only you do not need to recompile, you also do not
> need to restart the application.
> ...
> configuration files). When you load a properties
> file, Fuse will do the matching for you. That means
> switching theme will just be a metter of calling
> ResourceInjector.get("my-look-and-feel").load(themePro
> pertiesFile).

To be clear, this code probably wouldn't do what you expect. This would load the new resource file, but none of the injected values would be changed. For this (and other theme-like uses) you would be better off using hives (org.jdesktop.fuse.swing.SwingHive). Hives work pretty much the same way as ResourceInjector, except they will allow you to load alternative properties files at runtime, automatically re-injecting the injected components and invoking repaint(). An example of this is in the demo/swing/ directory. As I understand it, Aerith itself also uses hives, but I haven't actually looked at the sources. Romain?
Daniel Spiewak
ActiveObjects: an Easier Java ORM; Fuse: Resource Injection for Java
11 . At 3:44 PM on Nov 9, 2007, Fabrizio Giudici wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

> So speaking from a perspective of using this on a
> large-scale project - how would you compare Fuse with
> writing a custom theme for an existing LAF? At least
> in this example, it's all about the painting (colors,
> gradient stops), which can be done as a custom theme
> / skin.

I have to thank Daniel and Michael for their posts, since I had looked ad Fuse a lot of time ago, forgot about it had just started some code that now I hope to get rid of and replace with Fuse (of course "also" thanks to Romain for writing it :-).

I see Fuse as a complement to the L&F especially useful for letting the programmer customize reusable components (in my case, NetBeans RCP components).
Fabrizio Giudici, TidalWave - We make Java work. Everywhere.
weblogs.java.net/blog/fabriziogiudici, www.tidalwave.it/blog
Member of the NetBeans Dream Team.
12 . At 5:02 PM on Nov 9, 2007, Romain Guy DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

It's worth mentionning that Fuse provides mechanisms to inject resources into components for which you don't have the source code (hence in which you cannot add the @InjectedResource annotation.)
Romain Guy
Romain Guy's Java Weblog, #ProgX, Jext
13 . At 5:28 PM on Nov 9, 2007, Daniel Spiewak wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

> It's worth mentionning that Fuse provides mechanisms
> to inject resources into components for which you
> don't have the source code (hence in which you cannot
> add the @InjectedResource annotation.)

Some documentation on this feature is available here: https://fuse.dev.java.net/hivesanddefs.html#injecting_thirdparty
Daniel Spiewak
ActiveObjects: an Easier Java ORM; Fuse: Resource Injection for Java
14 . At 7:01 AM on Nov 12, 2007, Mike P wrote:
  Click to reply to this thread Reply

Re: Easier Custom Components with Swing Fuse

Although the second search result (on my system) on Google on "fuse", not to be confused with the "Filesystem in Userspace" project.

thread.rss_message