Showing posts with label java. Show all posts

Showing posts with label java. Show all posts

Java Swing Layout made extremely easy

on Monday, 14 January 2008
If you're a Java developer working on desktop applications that require you to code the interfaces (especially the really complex ones), you'll love what I found.

First, take a look at this page. See that complex looking list? It's made with a custom ListCellRenderer which was created using GroupLayout. Really nice-looking doesn't it? (see the layout tutorial here)

GroupLayout was specifically designed for use with Project Matisse, the GUI builder for the Netbeans IDE, which by the way, is extremely impressive.

Unfortunately, GroupLayout is complex to use and difficult to read if you do not have access to Netbeans and do not wish to use/learn Netbeans solely for the purpose of designing the GUIs. Or maybe you're just old school and prefer to build GUIs by hand (I know, some of the generated code can be icky). What do you do?

You go and download MigLayout of course! Why? Well, go back and look at that fancy list above again and try to estimate how many nested panels you might need should you use the standard layouts, or how many lines of code and the calculations you need for GridBagLayout. Finished? Guess how many lines it takes for MigLayout... seven. Yes, you read it right, just seven simple lines:
cell.setLayout(new MigLayout("nogrid, fillx"));
cell.add(pic,   "dock west");
cell.add(title, "growx");
cell.add(count, "wrap");
cell.add(line1, "growx, wrap");
cell.add(line2, "growx");
cell.add(email);

Impressive, no? Check out the website for guides and Java Web Start demos.

From Eclipse to Netbeans

on Tuesday, 13 March 2007
I've been using Eclipse as my IDE of choice ever since I switch over from Netbeans version 3. But after attending the Sun Tech Days 2007 Kuala Lumpur, I can see that the latest release version, Netbeans 5.5, has been tremendously improved. I daresay that I think it's coming on par with the capabilities of Eclipse, even if you take MyEclipse into consideration. I'm actually giving Netbeans 5.5 a go with my current development work and first impressions are both good and bad. I'm not really attempting a critical and in-depth comparison of both IDEs (since I just started on using Netbeans) but just presenting how Netbeans impressed on me when compared to my experience on Eclipse.

I'll start with the negative impressions:
  • Personalization and syntax coloring is something I'm particular about. Netbeans has very few customisation options and syntax coloring is very limited. But the good thing over Eclipse is that you can save the colour scheme as a profile, so that's a small plus.
  • There's no easy way to change look-and-feel; have to much command line parameters. Although projects like this makes things much better.
  • Seeing what compile errors I have is a pain in Netbeans. Code errors don't show up in the project or file hierarchy trees. I can only see errors in the current file I'm looking at and if I rebuild the project. Eclipse shows errors in the project tree and traces it from the offending file all the way to the root project container.
  • "Find Usages" is very limited compared to the similar search references function in Eclipse. It also forces me to still have to click on "Next" before the search actually takes place. Why can't it search by default?
  • There's no shortcut to jumping quickly to methods in a class. You have to either use the standard find text or use the navigator window. No biggie, but one gets used to being able to jump directly to a method from anywhere else in a class.
  • I don't like the fact code errors don't show up immediately. Maybe it only checks for errors while you've slowed down your typing for better performance but it does mean I have to move my cursor back. The slight pause before the error appears is sometimes disruptive.
  • I find the configuration options window baffling. Is it really necessary to separate basic and advanced? The basic version is much easier to use and navigate, but mostly useless. The options that really help with personalisation and customisation are all in the advanced. Can't better forms and dialogs be designed for the so-called advanced options?
And then the positive impressions:
  • Speed. I just can't help but notice that Netbeans works much faster than Eclipse. It even exits much faster. This is a huge plus.
  • I found the wide array of tools that comes with the basic installation very impressive. The additional packs are even better - the web designer, the mobility pack, the Java EE designers, the profiler... very nice.
  • Built-in mapping for Eclipse shortcuts. Which really helps transition from Eclipse to Netbeans, although I'm using my own slightly-tweaked Eclipse keymap.


Biased? Yea, looks like it, since I'm way more familiar with Eclipse than Netbeans. But looking at the features list of Netbeans 6, it looks like those are just the polish Netbeans needs to make it much more persuasive for me.

EDIT: 15/3/07 Fixed the subversion issue on Netbeans.

Java anyone?

on Friday, 23 July 2004
I'm a programmer. Work day after day is churning out lines of code. But it's fun sometimes, as you wrack your brain trying to solve an elusive bug or producing just the right algorithm. The triumphant feeling you get sometimes justifies the previous scalp-scratching exercise. Ha! Don't let me scare you off though. I program mainly in Java, though I know alot others, just rusty in them by now.

As all programmers know, the tool with which you use to program is very important. My recommendation? vi. Yes, that Unix/Linux editor with an extremely steep learning curve. But once you get the hang of it, learning its nuances and secrets known only to the hardcores, it's a wonderful editor, not just for programming. Don't have Unix/Linux? Try gvim, the Windows version! vi (or vim) can do just about everything a sophisticated IDE can do, but at a much much much smaller size and faster speed. And there are several things it can do that modern IDE can't. vi has syntax highlighting (for dozens of syntactical stuff, even some obscure ones), text replacement, macros, hundreds of quick shortcuts to accomplish editing needs, code folding, method browser, method traversal, registers for copying, window splitting, sorting, aliases, key mappings, visual selection, regular expressions for just about anything, save options, encryption, initiating compilation within the editor, color schemes, allows plugins, and quite a few more I can't think of right now. Phew. Yes, it's that good.

But of course, you sometimes just can't beat the visual look of an integrated IDE. My favourite at the moment is NetBeans, which is a free open source development platform that supports just about anything about Java. It has official Sun support too! Of course, for those who do not prefer NetBeans, they usually prefer Eclipse, which appears more flexible as it is not limited to Java. Put in the right plugin, and you can start writing code in some other programming language. NetBeans is now version 3.6, while Eclipse is 3.0.

Download quick links: gvim, NetBeans, Eclipse.