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. (sponsored)
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.
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.
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.
Those of you who are faithful readers will realize that this task sounds strikingly
familiar to one I just wrote not two weeks ago:
SwingX: Conserve
Navigation Real Estate with JXScrollups
. There is a reason for that - the
JTaskPane
and
JTaskPaneGroup
classes are an alternative
implementation of the same control implemented by the
JXScrollup
. I
thought it would be good to show the alternatives here so all of you can consider
what works best for you.
JXScrollups and JTaskPaneGroups are very similar, although the current support
for JTaskPaneGroups is arguably a little more robust. The design behind each
is definitely different. JXScrollup objects are designed to be able to be placed into
any parent component, as long as the parent component uses the ScrollupLayout.
JTaskPaneGroups, however, are designed to be held in a JTaskPane - which brings with
it an entire look-and-feel implementation (actually, set of implementations), which
perform background color rendering, layout management, etc. all transparently.
In reality you can use task pane groups in any container as well, but the task pane
manages all of the complex layout and rendering concerns for you.
Similarly, JXScrollups allow for any child container to be placed in them for their
content (
JXScrollup.setContentContainer()
), whereas a JTaskPaneGroup
is, itself, the container. Strictly speaking, the JTaskPaneGroup should be able to
hold any type of component - I have seen that it doesn't favor well with components
more complicated than buttons. The *correct* behavior per the documentation is to
use the
add(Action)
method - although that is a recommendation,
not really a design requirement. In my example below I am using buttons, simply for
consistency and simplicity.
Finally, it is important to note that L2FProd components are tightly integrated with
a very richly defined look and feel system. Look and feel implementations for the
various components (such as the JTaskPane and JTaskPaneGroup) are available for
most of the common platforms. The SwingX components certainly haven't reached this
level of maturity yet - this is probably the strongest advantage of the L2FProd components.
Here is a screenshot using the Windows XP look and feel:
package com.javalobby.tnt.l2fprod;
import javax.swing.*;
import com.l2fprod.common.swing.JTaskPane;
import com.l2fprod.common.swing.JTaskPaneGroup;
import com.l2fprod.common.swing.plaf.LookAndFeelAddons;
import com.l2fprod.common.swing.plaf.windows.WindowsLookAndFeelAddons;
publicclass JTaskPaneTest {
privatestaticfinalint NUM_TASK_PANE_GROUPS = 5;
publicstaticvoid main(String[] args) {
try {
// Simply installing Windows XP look and feel - see LookAndFeelAddons documentation
// for more information.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class);
}
catch(Exception e) { }
// Create and set up the window.
JFrame frame = new JFrame("JXScrollUpTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and set up the task pane.
JTaskPane rootPanel = new JTaskPane();
createTaskPaneGroups(rootPanel);
frame.setContentPane(rootPanel);
// Display the window.
frame.pack();
frame.setVisible(true);
}
privatestaticvoid createTaskPaneGroups(JTaskPane rootPanel) {
for (int i = 0; i < NUM_TASK_PANE_GROUPS; i++) {
JTaskPaneGroup taskGroup = new JTaskPaneGroup();
boolean isEven = i % 2 == 0;
// Task Groups support the concept of being 'special', which
// means they may be rendered uniquely to stand out from others.
taskGroup.setSpecial(isEven);
taskGroup.setExpanded(!isEven);
taskGroup.setText("Task Group: " + i);
taskGroup.add(new JButton("Button on TaskPane: " + i + " #1"));
taskGroup.add(new JButton("Button on TaskPane: " + i + " #2"));
rootPanel.add(taskGroup);
}
}
}
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
Hey R.J.
Just a quick note, I'm not sure if you are aware but Frederic Lavigne (l2fprod) is working on integrating the two components in the SwingX projects right now.
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
Hi,
thanks for the press I really like the article, it gives a good overview of the component!
About your comment:
> I have seen that it doesn't favor well with components more complicated than buttons.
What kind of problems did you encounter and with which components?
BTW, I just updated the webstart demo (both jdnc-incubator and l2fprod.com) with new look implementations to match the Microsoft XP visual styles Homestead and Silver.
I don't get it. I followed your links to the SwingX website and while you show nice screenshots from the components you discuss I see absolutely nothing available on the SwingX website. There is no downloadable code, screenshots, tutorials or anything.
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
> What kind of problems did you encounter and with
> which components?
In the application I've been working on, I've placed everything from jbuttons, jpanels, jtextfields, jtrees panels with textfields and buttons and even other JTaskPaneGroups (don't ask) - all without hiccup. Positive marks from me
Mark is absolutely right. I think in my first tip on SwingX, I mentioned that it was still alpha (unreleased), and that it was bound to change before the first release - but I haven't kept up that behavior properly - I apologize.
SwingX is still just in CVS only state - thankfully it is trivial to download and build.
We are currently using the taskpanegroup to hide/show filters for a Jtable and it looks/works great. we are quite pressed for real estate due to the nature of some of the machines our clients still use - sadly 800*600
Whilst using the widget, it was noted that it would be great to be able to add more than just text to the taskpane bar. ie, instead of just group.setText() it would be cool for us to be able to add a title text and then some more text over to the right to say something like "click here for more options...".
Re: Possibile to add aligned components to top bar?
thanks fred, i guessed so, id read the whole api, i was craftily trying to suggest it would be a good thing to implement indeed, once we have this app rolling screen shots are sure to follow, we have glazed lists, spring rcp, and all sorts. Cool time for java desktop
L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
At 11:17 PM on May 25, 2005, R.J. Lorimer wrote:
Fresh Jobs for Developers Post a job opportunity
Those of you who are faithful readers will realize that this task sounds strikingly familiar to one I just wrote not two weeks ago: SwingX: Conserve Navigation Real Estate with JXScrollups . There is a reason for that - the
JTaskPaneandJTaskPaneGroupclasses are an alternative implementation of the same control implemented by theJXScrollup. I thought it would be good to show the alternatives here so all of you can consider what works best for you.JXScrollups and JTaskPaneGroups are very similar, although the current support for JTaskPaneGroups is arguably a little more robust. The design behind each is definitely different. JXScrollup objects are designed to be able to be placed into any parent component, as long as the parent component uses the ScrollupLayout. JTaskPaneGroups, however, are designed to be held in a JTaskPane - which brings with it an entire look-and-feel implementation (actually, set of implementations), which perform background color rendering, layout management, etc. all transparently. In reality you can use task pane groups in any container as well, but the task pane manages all of the complex layout and rendering concerns for you.
Similarly, JXScrollups allow for any child container to be placed in them for their content (
JXScrollup.setContentContainer()), whereas a JTaskPaneGroup is, itself, the container. Strictly speaking, the JTaskPaneGroup should be able to hold any type of component - I have seen that it doesn't favor well with components more complicated than buttons. The *correct* behavior per the documentation is to use theadd(Action)method - although that is a recommendation, not really a design requirement. In my example below I am using buttons, simply for consistency and simplicity.Finally, it is important to note that L2FProd components are tightly integrated with a very richly defined look and feel system. Look and feel implementations for the various components (such as the JTaskPane and JTaskPaneGroup) are available for most of the common platforms. The SwingX components certainly haven't reached this level of maturity yet - this is probably the strongest advantage of the L2FProd components.
Here is a screenshot using the Windows XP look and feel:
Finally, here is the code from the JXScrollup example , reimplemented with JTaskPaneGroups.
package com.javalobby.tnt.l2fprod; import javax.swing.*; import com.l2fprod.common.swing.JTaskPane; import com.l2fprod.common.swing.JTaskPaneGroup; import com.l2fprod.common.swing.plaf.LookAndFeelAddons; import com.l2fprod.common.swing.plaf.windows.WindowsLookAndFeelAddons; public class JTaskPaneTest { private static final int NUM_TASK_PANE_GROUPS = 5; public static void main(String[] args) { try { // Simply installing Windows XP look and feel - see LookAndFeelAddons documentation // for more information. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class); } catch(Exception e) { } // Create and set up the window. JFrame frame = new JFrame("JXScrollUpTest"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create and set up the task pane. JTaskPane rootPanel = new JTaskPane(); createTaskPaneGroups(rootPanel); frame.setContentPane(rootPanel); // Display the window. frame.pack(); frame.setVisible(true); } private static void createTaskPaneGroups(JTaskPane rootPanel) { for (int i = 0; i < NUM_TASK_PANE_GROUPS; i++) { JTaskPaneGroup taskGroup = new JTaskPaneGroup(); boolean isEven = i % 2 == 0; // Task Groups support the concept of being 'special', which // means they may be rendered uniquely to stand out from others. taskGroup.setSpecial(isEven); taskGroup.setExpanded(!isEven); taskGroup.setText("Task Group: " + i); taskGroup.add(new JButton("Button on TaskPane: " + i + " #1")); taskGroup.add(new JButton("Button on TaskPane: " + i + " #2")); rootPanel.add(taskGroup); } } }Until next time,
R.J. Lorimer
rj -at- javalobby.org
http://www.coffee-bytes.com
14 replies so far (
Post your own)
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
Hey R.J.Just a quick note, I'm not sure if you are aware but Frederic Lavigne (l2fprod) is working on integrating the two components in the SwingX projects right now.
You can see this thread (http://www.javadesktop.org/forums/thread.jspa?threadID=11278&tstart=0) for more information, or you can try this webstarted app:
https://jdnc-incubator.dev.java.net/documentation/l2fprod/jnlp/l2fprod.jnlp
I'm not sure if that is the latest. For more info, see the forum thread posted above.
Thanks! And BTW, great article's
Richard
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
Richard,This is great news! Thanks for posting here about it. I'm glad to see there is some integration there.
Regards,
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
Hi,thanks for the press
About your comment:
> I have seen that it doesn't favor well with components more complicated than buttons.
What kind of problems did you encounter and with which components?
BTW, I just updated the webstart demo (both jdnc-incubator and l2fprod.com) with new look implementations to match the Microsoft XP visual styles Homestead and Silver.
-fred
Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
Fred,When I was writing the code for this tip, I tried putting JTextAreas, JScrollPanes with JTables, and all kinds of wierd stuff in them.
Tables weren't rendering properly for one reason or another, and the text areas were having some really unusual (and inconsistent) layout problems.
I can try and reproduce some test cases and screenshots if necessary.
Cheers,
SwingX not publically available?
I don't get it. I followed your links to the SwingX website and while you show nice screenshots from the components you discuss I see absolutely nothing available on the SwingX website. There is no downloadable code, screenshots, tutorials or anything.What do you go on?
Gili
Re: SwingX not publically available?
CVS. It is publically avalaible. Just no prebuilt binaries.Re: L2FProd: Conserve Navigation Real Estate with JTaskPaneGroups
> What kind of problems did you encounter and with> which components?
In the application I've been working on, I've placed everything from jbuttons, jpanels, jtextfields, jtrees panels with textfields and buttons and even other JTaskPaneGroups (don't ask) - all without hiccup. Positive marks from me
Cheers,
Ian
Re: SwingX not publically available?
Mark is absolutely right. I think in my first tip on SwingX, I mentioned that it was still alpha (unreleased), and that it was bound to change before the first release - but I haven't kept up that behavior properly - I apologize.SwingX is still just in CVS only state - thankfully it is trivial to download and build.
Regards,
Possibile to add aligned components to top bar?
Hi fred,We are currently using the taskpanegroup to hide/show filters for a Jtable and it looks/works great. we are quite pressed for real estate due to the nature of some of the machines our clients still use - sadly 800*600
Whilst using the widget, it was noted that it would be great to be able to add more than just text to the taskpane bar. ie, instead of just group.setText() it would be cool for us to be able to add a title text and then some more text over to the right to say something like "click here for more options...".
Is this something that could be done?
regards, and great work
Alan
Until SwingX runs on completely on OSX
it is dead to me and I will continue to use all of the L2FProd stuff that we aren't already using from JIDE.Re: Possibile to add aligned components to top bar?
Not possible with the current component.SwingX with it JXTitlePane allows to do that by defining areas on the left and on the right where developers can add components.
I'll keep you request in mind!
and BTW, feel free to post or email me screenshots of your app using the JTaskPaneGroup for my collection
-fred
Re: Possibile to add aligned components to top bar?
thanks fred, i guessed so, id read the whole api, i was craftily trying to suggest it would be a good thing to implementregards
Alan
Re: Until SwingX runs on completely on OSX
Hey Gregory,By "runs completely on OSX" are you talking about:
* look and feel implementations
* 1.5 support
* other?
Thanks!
Richard
Re: Until SwingX runs on completely on OSX
All of the components being available without rendering artifacts. Got the Java5 release for OSX already so that's not a big deal.