Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Friday, December 18, 2009

JTabbedPane for Netbeans Desktop Application

If any desktop application created in netbeans is using several tabs. Then each time the application is started, it will show the last selected tab. Even , by initially calling setSelectedIndex(int index) methodof JTabbedPane wont work. To resolve this issue following steps needs to be followed :Go to the class which extends SingleFrameApplication (,i.e,having public static void main).Update the overridden method shutdown() by selecting the default tab before super.shutdown() is called.

setResizable for Netbeans Desktop Application

  • Go to the class which extends SingleFrameApplication (,i.e,having public static void main)
  • Update the overridden method startup() by calling this.getMainFrame().setResizable(boolean resizable) after show(View view) is called.

Tuesday, November 24, 2009

ClassFormatError

ALERT: java/lang/ClassFormatError: Bad version information.
If when launching a Midlet in netbeans emulator the above errors, then check if any jar file is being used which is created using Java 1.5 and above.

Wednesday, November 11, 2009

Null Pointer Exception in Java

Item array in J2ME : While initializing a Form object in J2ME application the corresponding label as well as items array might not be null. But this can throw NullPointerException if any one element of items array is null.

Hashtable : If Hashtable is used in our application ,then any manipulation of its reference prior creating the object will throw NullPointerException.

String array : If String array is initialized at the beginning, but , if at a later point , if that String array calls a function which returns null, then , trying to get the length of that String array will throw NullPointerException

Wednesday, October 14, 2009

Out of Memory Exception in java

When we have 2 methods with following signature:
return_type method(String str);
return_type method(Object str);
if we call method("string") inside method(String str) assuming it will call method(Object str), it won't do so, rather function recursion will occur infinitely resulting in Out of Memory Exception.