Friday, December 19, 2008

Snow storm time!

Friday, November 28, 2008

A tale of three IDEs

I think I should tell a little bit about the environment I am in. I am sure all Windows users can safely ignore everything below.
  • OS X 10.5.5
  • Default Java - java version "1.5.0_16"
  • Also have the latest (and buggy) apple Java 1.6.0_17
IDEVersionProblemFix
Netbeans6.5As soon as I launch, the netbeans icon jumps on the dock and then crashes. No error message on screen.This is due to some but in Apple's Java and updates. To address, you will have to edit file :
Applications/NetBeans/NetBeans 6.5.app/Contents/Resources/NetBeans/
platform9/lib/nbexec
and change
eval ${_NB_PROFILE_CMD} "\"${jdkhome}/bin/java\""
-Djdk.home="\"${jdkhome}\"" -classpath "\"$cp\"" \

$jargs org.netbeans.Main "$args" '&'
change it to:
ARCH_CMD="/usr/bin/arch -i386";
eval ${ARCH_CMD} ${_NB_PROFILE_CMD} "\"${jdkhome}/bin/java\""
-Djdk.home="\"${jdkhome}\"" -classpath "\"$cp\"" \
$jargs org.netbeans.Main "$a
rgs" '&'
Intellij IDEA8,7.xCompiler internal error. Process terminated with exit code 139 - This occurs whenever you try to build your projectNot sure how this gets fixed by my work-around, but all you have to do is : launch compiler properties- Intellij IDEA->Preferences..->Compiler->Java Compiler and put a valid option in "Additional command line parameters - for ex: -verbose
EclipseGanymedeNone so far

The fix for Netbeans issue is specified in netbeans issues
However, I had to figure out fix for issue with IDEA through trial and error(accidentally)
Screenshots for fixes mentioned above.
Netbeans :


IDEA


Wednesday, November 26, 2008

India Under attack(Again)

Well, this is the umpteenth 9/11 for india, but our laid back attitude will allow these terrorist factions to grow bigger and bigger. I am waiting for the day when our government will declare "the war on terror". Wonder if that will happen in my lifetime. 
At the same time this is the message for the stupid fanatics who were trying to eliminate North indians out of Bomaby. Wake up and face the "real music" you morons.

Wednesday, October 29, 2008

India as it is..

Though I am in USA these days, I closely follow what is going on in my "Des"(Hindi word for Country). Most of the media today focuses on spreading bad news, that would let you down for the day. Just for this reason, I go through the Indian online newspapers only in the nights.
These days, the fight between thoughtless natives of  Bombay and people from other states are spreading like wild fire. This leaves me thinking if our country of billion people is going to be the next Congo. Today's headline news is that a man from U.P( northern Indian state) was beaten to death (Well, what a nice way to showcase our 3000 years of culture and tradition!) in a commuter train. Bombay, as of today is built by men from all states all over India. There is no reason why a Bombay-native should have preference over an outsider. Everyone in the country is entitled for his dreams and fortunes in the so called "commercial capital of India". What has Bombay-natives given to Bombay except for renaming it to "Mumbai"?

Sunday, September 14, 2008

Leopard-like toolbar buttons in Java Swing - part 2

I had been trying to create "leopard-like" toolbar buttons. This required a lot of Swing coding and a bit of imagination. Apple, with its Apple JDK 1.6 features, has introduced ways to create many different kinds of Apple buttons. Namely : square, gradient, bevel, textured, roundrect, recessed and help.
 This greatly reduces the work that you need to do. However, the look will not carry forward to other platforms. For that, you need to paint your own buttons as I mentioned in my earlier blog.
The technique for rendering leopard like toolbar button is :
  • Create a transparent PNG icon for the button - for example, a plus sign
  • Create a JButton and set button.putClientProperty("JButton.buttonType", "segmentedTextured") and various other options in apple's technical note website.


Monday, September 8, 2008

State of clientProperty in OS X Java 1.6

Started looking at my pet Java Swing application - jSpent. This time the attempt was to create a leopard-like unified toolbar. I was so excited to see that there is a clientProperty "apple.awt.brushMetalLook" - By setting this as : 
myFrame.getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE);
This will cause OS X to render the title bar in the unified style. But unfortunately, there is no good clientProperty setting for the toolbar itself. So we end up with a light gray window title bar. The toolbar appears like a gray box, painted in different color. Not sure if this is a bug in Apples Java. However, I had to again resort to pick and choose and paint my own gradient just below the window title bar to make it look "Unified". So, here is the output. 


But oh well, I need to repaint the toolbar in ligher gradient when the window goes out of focus.. hm.. that's too much to do!

Thursday, August 14, 2008

Why OS X is sweet..

Since I am a guy who moved from MS Windows/GNOME world to OS X, I used to miss the "start menu". But soon I discovered how handy the spotlight search is.
I started discovering interesting features and applications as I continued to use mac. For example, for ripping a DVD, we have Handbreak. For video format conversion there is iSquint. But how on earth would you remember these names when you need it. I installed iSquint and one day I was racking my brain to find what was the name of that application that would convert one video format to another in Mac. At last, I had to google it though I had the software on my desktop. Then I thought hey! the spotlight must have a feature to tag an application with whatever keywords you want. And yes! there is.
Select the application from Application folder, right click and goto info dialog. There is a top text area called "Spotlight comments" enter your keywords. Now, if you type just the key words in plain English on spotlight, it lists the application that will match your keywords..awesome!!

So here are the screenshots with what I did for Handbreak. Right click and invoke the info dialog. Enter the key word:


Now when you want to rip a DVD ( hey its illegal!), type rip DVD on your spotlight search textbox and here is what happens


This is far far better from searching through your program in a startmenu with 100 different shortcuts. And may be its just me, I like keyboard short cuts ( apple + space bar for spotlight search) and a little typing.

Friday, July 18, 2008

Yet another test for syntax highlighting

This time the code is a piece of HTML created using Vim's Syntax->Convert to HTML feature.
/**
* @author ranjith
* @date May 13, 2008
* JPA Persistance in action
*/
public class MessageJPATest {
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa-learn");
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();

This seems to be working? Yes - only when your Vim color theme matches your blogger background color.
Plus, too much work to paste code snippets.

Thursday, April 24, 2008

Does Blogger(blogspot) support code formatting?

Here are some attempts..
This is using format my source code for blogger utility.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>





Some trial with an excellent web based tool provided at http://www.manoli.net/csharpformat/

I copied the CSS given by this site to my blogger template.
The results are good. But needs tweaking as default blogger linespacing is kind of messed. Then I tweaked it a little bit and mixed with the pre tag in above code formatting style. Works to certain extend. But I am not satisfied with the output. May be I need to change my Blog's basic template to a wider one to accommodate the source code. Thats for later!!!

Tuesday, February 5, 2008

Work in progress - my very rich swing application - part 6

Recently, I got some free time to re-visit my rich swing application. The target was to implement in-place table cell editing with focus running on tab key and getting the table cell "edit-ready" up on focus. This requires a plenty of nasty work around, but works nonetheless.
If you are interested in the code, it is available at jspent - Google code.

Here is a closer look:


Recently updated my Mac to 10.5 ( leopard ) and no Java 6 for further work on Mac :(
When will apple release Java SDK 6 for intel core duo based Macbooks? no idea.