|
|
||
Kirill Grouchnikov's BlogDecember 2005 ArchivesSwinging Java IDEsPosted by kirillcool on December 29, 2005 at 11:05 AM | Permalink | Comments (2)This entry on JavaLobby has caught my eye a few days ago. It talks about a RAD-race at JavaPolis and the fact that the top three teams were using JDeveloper. During the course of (so) many flamewars on "which IDE is better", it's always Eclipse vs. NetBeans vs. IntelliJ (and don't start another one in the comments by telling that your favourite IDE should be the first in the list). I have started reading a little bit more about JDeveloper - it's free (but not open-source) and it's pure Swing application. The download size is comparable to that of the above three "flamewar heroes" (about 51MB without JDK 5.0), so you should definitely keep this option in mind. After showing how to put watermark on IntelliJ (described here) and NetBeans (described here and here), it's JDeveloper's turn to take a ride. Here is what you need to do in order to run JDeveloper under Substance (or any other) look-and-feel (originally described in Oracle forums):
The parameters in the jdev.conf file are: AddVMOption -Dsubstancelaf.theme=org.jvnet.substance.theme.SubstanceSunsetTheme AddVMOption -Dsubstancelaf.watermark=org.jvnet.substance.watermark.SubstanceImageWatermark AddVMOption -Dsubstancelaf.watermark.image=H:\JProjects\substance\temp\KingArthur.png AddVMOption -Dsubstancelaf.watermark.tobleed AddVMOption -Dsubstancelaf.useDecorations AddVMOption -Dsubstancelaf.heapStatusPanel AddVMOption -Duser.language=en AddVMOption -Duser.country=US NetBeans look and feel competition - a low-hanging iPodPosted by kirillcool on December 26, 2005 at 01:55 AM | Permalink | Comments (2)About two weeks ago NetBeans has announced a Look and Feel competition (which should really by Look only, since they are accepting screenshots). One of the more enjoyable ways to create an attractive screenshot (although this depends on male-to-female ratio on the judging panel :) is to use the Substance NB module that allows using the Substance LAF integrated into the View menu. One of the users has asked me if it would be possible to make the watermark image "bleed" through the editor panel. Obviously, without changing the NB editor module it's not possible. However, now it is possible to make the watermark bleed through trees, tables and lists. First, you are welcome to view a few Substance-enhanced NetBeans screenshots - note that the trees / tables / lists are opaque and do not show the watermark. Starting from the latest drop of version 2.2 (available in NBM download), Substance supports the -Dsubstancelaf.watermark.tobleed VM flag (no value needed). Once specified, this flag makes all trees, tables and lists transparent. Here's a screenshot to illustrate this (note the left-side trees that show the watermark - click for a fullsize view):
Note that although it's nice to use this option for the above competition, not all NetBeans screens will look good using this VM flag. Although this option instructs all trees, tables and lists (along with the cell renderers) to be transparent, it can't prevent the cell renderers from painting their own background if they override the paint() method. On the other hand this option can spot such problematic places in your application (unless they're there on purpose). In addition, the latest NBM version (under dev 2.2 directory) allows changing the watermark image from View -> Watermark -> Image menu. The history is limited to five entries (updated on selection) and persisted. One last thing - if you like Substance, help internationalize it! (small print - eternal glory is not guaranteed :) Starting from version 2.2 (code-named El Paso) the additional UI elements (system menu items, heap status panel, menu search panel) are internationalized. You are welcome to view the list of available translations and send me additional translations to kirillcool [at] yahoo.com. Thanks in advance Spicing up your JTabbedPane - part IIPosted by kirillcool on December 22, 2005 at 12:49 PM | Permalink | Comments (0)This entry describes the capabilities that release 2.1 of Substance look-and-feel provides for your tabbed panes. They are:
The first request was to enhance the listener mechanism on close buttons of tabbed panes. As mentioned in the above blog, you can register any number of listeners that will be called when close button of some tab in some tabbed pane is clicked. The CloseTabListener interface defines the following two methods: /** * Called when a tab is about to be closed. */ public void tabClosing(JTabbedPane tabbedPane, Component tabComponent); /** * Called when a tab is closed. */ public void tabClosed(JTabbedPane tabbedPane, Component tabComponent);There were two separate requests regarding this mechanism:
/** * Called when a tab is about to be closed. Can veto the tab closing. * * @returnAll vetoable listeners that are either registered for the specific tabbed pane, or are registered globally (for all tabbed panes) are called when the close icon is clicked. If at least one of them returns false, the tab will not be closed. Otherwise, the tabClosing and tabClose functions will be called. A simple example is to show the confirmation dialog as:
public void tabClosed(JTabbedPane tabbedPane,
Component tabComponent) {
System.out.println("Closed tab - specific");
}
public void tabClosing(JTabbedPane tabbedPane,
Component tabComponent) {
System.out.println("Closing tab - specific");
}
public boolean vetoTabClosing(JTabbedPane tabbedPane,
Component tabComponent) {
int userCloseAnswer = JOptionPane.showConfirmDialog(
Check.this,
"Are you sure you want to close this tab?",
"Confirm dialog", JOptionPane.YES_NO_OPTION);
return (userCloseAnswer == JOptionPane.NO_OPTION);
}
The following dialog will be shown to the user when the tab close button is clicked:
Note that this extension doesn't break the existing API which is still fully supported and provides the exact same functionality as before. The second request was to provide an option for drawing vertical rotated tabs when the current placement for the tabbed pane is either LEFT or RIGHT. The solutions described elsewhere (by Santosh and Lee Ann) involve a composite icon that simulates the tab and effectively hides the text from the tabbed pane UI delegate (by putting it in the icon and rotating the entire icon). The above solutions work, but involve using third-party classes and changing your code to use these classes. In addition, since Substance provides the close buttons on tabs, they are not easily applicable. Substance provides unintrusive solution for rotated vertical tabs. There are two properties that you can set:
JTabbedPane jtp = new JTabbedPane();
TabNumberedPanel tnp1 = new TabNumberedPanel(jtp, 1);
tnp1.putClientProperty(
SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS,
Boolean.TRUE);
jtp.addTab("tab1", SubstanceImageCreator.getThemeIcon(null), tnp1);
jtp.addTab("tab2", SubstanceImageCreator.getThemeIcon(null),
new TabNumberedPanel(jtp, 2));
TabNumberedPanel tnp3 = new TabNumberedPanel(jtp, 3);
tnp3.putClientProperty(
SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS,
Boolean.TRUE);
jtp.addTab("tab3", SubstanceImageCreator.getThemeIcon(null), tnp3);
jtp.addTab("tab4", SubstanceImageCreator.getHexaMarker(4,
SubstanceLookAndFeel.getTheme()), new TabNumberedPanel(jtp,
4));
jtp.addTab("tab5", SubstanceImageCreator.getHexaMarker(5,
SubstanceLookAndFeel.getTheme()), new TabNumberedPanel(jtp,
5));
jtp.setEnabledAt(2, false);
jtp.setEnabledAt(3, false);
jtp.putClientProperty(
SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION, true);
Note that you get the desired behaviour by setting a few client properties, which have no effect under other look-and-feels.The only limitation of this technique is for tabs that support arbitrary components (added in Mustang, described in this blog entry by Alexander Potochkin). Such tabs will not be rotated correctly, since these components are not painted using the UI delegates at all. I have discussed this with Alexander and he pointed out additional problem - the need to translate mouse coordinates to allow the tab component to correctly handle the events. The bottom line (at least for Mustang) is - do not use this feature if your application is using the new JTabbedPane functions (which automatically implies that it's running under Mustang). One last thing - if you like Substance, help internationalize it! (small print - eternal glory is not guaranteed :) Starting from version 2.2 (code-named El Paso) the additional UI elements (system menu items, heap status panel, menu search panel) are internationalized. You are welcome to view the list of available translations and send me additional translations to kirillcool [at] yahoo.com. Thanks in advance Visual feedback on password strengthPosted by kirillcool on December 16, 2005 at 03:03 AM | Permalink | Comments (1)The GMail provides a nice visual feedback while you are typing a new password. On each keystroke, the currently typed string is sent to the Google servers (hopefully encrypted) and the computed strength is shown to the user (weak - red, medium - yellow, strong - green). This can serve as either suggestion only (as is in Google's case) or as semi-client side validation (providing feedback to the user before he clicks OK). The new version of Substance LAF (currently starting its development) provides an option for specifying such feedback. First - three screenshots illustrating the technique: Weak password - red strip on the password field and custom tooltip text: Medium password - yellow strip on the password field and custom tooltip text:
Strong password - green strip on the password field and custom tooltip text:
You can also view view this short video clip (412KB, 0:22 min) that illustrates the interaction. The implementation is quite simple. The PasswordStrengthChecker interface in org.jvnet.substance.utils package defines the following two functions:
public enum PasswordStrength {
WEAK, MEDIUM, STRONG
}
public PasswordStrength getStrength(char[] password);
public String getDescription(PasswordStrength strength);
You need to implement this interface (the implementation for the above screenshots looks at the length of the password and returns the corresponding value):
private static class MyPasswordStrengthChecker implements
PasswordStrengthChecker {
public PasswordStrength getStrength(char[] password) {
if (password == null)
return PasswordStrength.WEAK;
int length = password.length;
if (length < 3)
return PasswordStrength.WEAK;
if (length < 6)
return PasswordStrength.MEDIUM;
return PasswordStrength.STRONG;
}
public String getDescription(PasswordStrength strength) {
switch (strength) {
case WEAK:
return "<html>This password is <b>way</b> too weak</html>";
case MEDIUM:
return "<html>Come on, you can do<br> a little better than that</html>";
case STRONG:
return "OK";
}
return null;
}
}
Note that you can return HTML text for the tooltip (as for any Swing tooltip). The last thing you need to do - decide which password fields need this functionality and set the following client property on them:
JPasswordField jpf = new JPasswordField("password", 10);
jpf.putClientProperty(
SubstanceLookAndFeel.PASSWORD_STRENGTH_CHECKER,
new MyPasswordStrengthChecker());
The value of the above property must be an instance of PasswordStrengthChecker (will be ignored otherwise).
One last thing - starting from version 2.2 of Substance (code-named El Paso) the additional UI elements (system menu items, heap status panel, menu search panel) are internationalized. You are welcome to view the list of available translations and send me additional translations to kirillcool [at] yahoo.com. JRockit 5.0 on desktop - show me the moneyPosted by kirillcool on December 13, 2005 at 08:24 AM | Permalink | Comments (9)In the world of seemingly arbitrary records set by JRockit 5.0 JVM from BEA (see this comment on the JavaLobby thread), i have decided to take my test Swing application for a ride. This application is a test-bed for Substance LAF, so it utilizes a lot of Swing-related stuff, creating all possible core components, a lot of listeners, various layouts, colors etc. After downloading the latest release of JRockit 5.0 and installing it, here are the results (first of all i should mention that i didn't get any compilation or runtime errors, so i guess that "write once run everywhere" is still partly relevant). There are two phases that i had timed - the UIManager.setLookAndFeel function (which eventually calls the constructor of some LAF, but also does a lot of other stuff) and the creation of the main frame itself (constructor, pack, setting the size, location and visibility). The results are:
As usual, the results of such a 'benchmark' should be taken with a shovel of salt, since you may have different LAF and different Swing application altogether. However, the main conclusion is that JRockit may be 'smoking' hot for running the WebLogic, but it's certainly not a prime option for running desktop applications. Substance 2.1 official releasePosted by kirillcool on December 12, 2005 at 11:40 AM | Permalink | Comments (7)Substance look-and-feel has reached the 2.1 release, with a lot of new features and a lot of bugs fixed. The brief overview of new features:
When you know that a programmer is a Java programmerPosted by kirillcool on December 04, 2005 at 04:47 AM | Permalink | Comments (21)A long long time ago in a blog far far away I wrote about JDK collections and how should you choose your data structures. This topic has been on my mind during the past year, and I still haven't reached a definitive conclusion. First, I should mention that i have interviewed about 40 people this year for the technical positions in our project, which gave me an opportunity to see a large variety of programming backgrounds, styles and approaches. Second, we program in Java, which is quite important for the following discussion. Now that this is said, let's continue. There are numerous techniques for interviewing candidates for technical positions. They range from writing the code on the paper to open-ended design discussions. Most would argue that the best candidate should be well-versed in many conceptually different languages (such as Java / Perl / Lisp), but doesn't have to be a master of any. This will allow him / her to pick the tool (language) that best suites the task. This is true in theory. In practice, however, there are quite a few formidable obstacles to this. First, most existing projects have already chosen an implementation language, so it would be quite annoying hearing "Let's do this in Ruby" when you have hundreds of man-years invested in the project under your belt. In addition, it's not only your decision - you have existing deployments at customer sites, when sometimes the customer is the one dictating the language (say, somebody invested in a farm of WebLogic servers and wishes your application to be a part of the eco-system there). Furthermore, what about other developers? Sure, in Ruby you can do it in half the time, if only you have 10 experienced Ruby developers (not all applications are CRUD in the real world, unfortunately). Until we get that many available Ruby developers, curb your enthusiasm :( And now, for the interesting part. Suppose you have an excellent Perl developer and a good Java developer. Which one should you take to your Java project? Arguably, an excellent non-Java developer can learn Java syntax in 4-5 days. But is syntax everything you need to know to write excellent Java code? How much time will it take until he starts to write Java code that looks like Java code and not like Perl code (don't forget that working on team means that the code is maintained by everybody, and even if somebody leaves, his code stays)? Do big projects really need "stellar" developers, or perhaps a team of good developers with solid Java knowledge does better job in the long run? Which brings me to something that has been on my mind - what turns a programmer to a Java programmer? In my opinion, it's the correct way of working with collections. Once I see a candidate using iterators and maps, this is a very good sign. Most of the people coming from C or C++ work only with arrays or vectors. They sure look like hammers, but most of the real-world problems are bolts. It takes some time to get used to the syntax, it takes more time to know the available options, and it takes much more time to make the correct and informed choice. During this time, an excellent ex-Perl developer is prone to make your code base slower, dirtier and a mess to maintain. Any thoughts? | ||
|
|