Tuesday, June 26, 2007

Swing

This ain't really a dumb mistake or anything like that, but it kept me in the office till pretty late in the night today so i will give it credit by posting it here.

There will come a time when you need to do some fancy stuff like changing ur cursor's icon while you are hovering a Swing component. What i tried today was to change my cursor while hovering across a JLabel. What was supposed to be a one liner turned out to be irritating. Somehow the JLabel's setCursor() method won't work, in the end i had to resort to creating some MouseListeners over the Jlabel and set cursor for the frame instead. Its quite untidy but i guess its a temporary patch.

Sunday, June 10, 2007

explorer.exe - 100% cpu load

Its kinda stagnant to be digging into my own mistakes all the time, lets be a bit more adventurous by looking at what other people do as well. And which software has a large number of bugs with a huge user base? That has to be Micro$oft.

Alright, here goes.
If you encountered issues with your windows explorer slowing down and even hanging on you at wierd times, take a look at your task manager, its probably eating your CPU cycles. What may have happened is that during your traversal of folders in Windows Explorer, it got stuck with retrieving certain meta for some files, particularly AVI files. So one way is to disable Windows Explorer's nosey behaviour through the following methods.

Pls backup before you do the following
1. Start --> Run --> type regedit
2. Goto HKEY_CLASSES_ROOT\SystemFileAssociations\.avi\shellex\PropertyHandler
3. Delete it

Note: This will also solve issues where you can't delete certain avi files.
Note: You can extend this method to extensions of other types as well.

Wednesday, May 30, 2007

StackOverflow

I am pretty sure a lot of programmers encountered the StackOverflow error.
To be frank, in my early programming adventures, i never thought too much about the stack. 'Just another theory thing', i thought. But then, i learned my lessons.

Now, there ain't a lot of ways to cause stack overflows, but if you are really feeling itchy, the following mistake will certainly create it.


public void methodB()
{
methodA();
}

-- Call one of these methods --
public void methodA()
{
methodB();
}
But usually when i create stackoverflows, its usually because i call such recursive methods which are residing in different classes. So be careful, u never know when you create such a situation in the jungle of code.

Saturday, May 26, 2007

if statements

Method 1:

if(isTrue())
doSomething()


<--- identical --->
Method 2:

if(isTrue())
{
doSomething()
}

Me being the bad programmer, found myself debugging for a looonnnnggg time over a very stupid mistake made from the above convenience.

I used the first method somewhere in the thick jungle of my code. After some weeks, i decided to add some operation that would do another thing before the doSomething() function, along with many other changes.

As you might have guessed, i forgot the braces, and what happens next is an hour of scratching head and tearing of hair. :)
I felt like giving myself a tight slap when i found out why my code did not work as expected.