Tuesday, November 25, 2008

Getting around NetBeans 6 GUI builder's dependence on Java 6

NetBeans 6 GUI builder is great, but uses a new type of swing layout called the "GroupLayout" by default. This type of layout is only available in Java 6, and so if you try to run your compiled NetBeans 6 code with an older Java version, you get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
 
The way to overcome this in NetBeans, is to open up the NetBeans inspector window (lower right when in design mode), right-click on each of your forms and go to properties. Inside the properties window, you will see an option for "Layout generation style". Change this value from "Standard Java 6 code" to "Swing Layout Extensions Library".
 
Recompile, and you will be able to run your app in older Java versions (for example, Java 5).
*Remember to change ALL your forms individually! 

Sunday, November 9, 2008

Screen resolution too low on monitor

I was unable to use the maximum resolution I have on my monitor with Ubuntu. I was limited to only using an 800x600 screen resolution.

Here are my specs:
  • Ubuntu 64bit Hardy
  • Samsung T240 22" monitor
  • NVIDIA Ge Force 9800 GTX
  • Intel Quad Core

I am using the Nvidia native driver + software and installed it onto my system. Get it from here (I can't remember which one, but probably the second):

To fix the resolution problem above, I did the following:
  1. Download and install the native NVIDIA driver software
  2. Close your X-session in order to run the nvidia drivers installation program. Do this by running the command:
    sudo /etc/init.d/gdm stop
  3. Run the NVIDIA drivers installation program by running the command:
    sudo nvidia-installer
  4. After running the driver installation program, your X11 config file that the installer generated could be incorrect (mine was), open up your X11 config file by typing the command:
    sudo vim /etc/X11/xorg.conf
  5. Change the following entries in your xorg.conf file:
    • In the section titled "Monitor", comment out the line defining "modeline" by putting a "#" before it. This line should not be executed.
    • In the sub-section called "Display" within the section called "Screen", change the resolutions listed to "1920" by "1200".
  6. Restart your X server by running the command:
    sudo /etc/init.d/gdm start
Your monitor should now start with the higher resolution. Try restarting your computer if you don't see a difference yet or all features are not yet working. Your final X11 config file could look the following:


# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by failsafeDexconf, using
# values from the debconf database and some overrides to use vesa mode.
#
# You should use dexconf or another such tool for creating a "real" xorg.conf
# For example:
# sudo dpkg-reconfigure -phigh xserver-xorg
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
EndSection

Section "Device"
Identifier "Configured Video Device"
Boardname "vesa"
Busid "PCI:3:0:0"
Driver "vesa"
Screen 0
EndSection

Section "Monitor"
Identifier "Configured Monitor"
Vendorname "Plug 'n' Play"
Modelname "Plug 'n' Play"
#modeline "640x480@60" 25.2 640 656 752 800 480 490 492 525 -vsync -hsync
Gamma 1.0
EndSection

Section "Screen"
Identifier "Default Screen"
Device "Configured Video Device"
Monitor "Configured Monitor"
Defaultdepth 24
SubSection "Display"
Depth 24
Virtual 1920 1200
Modes "1920x1200@60"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "Default Layout"
screen 0 "Default Screen" 0 0
EndSection
Section "Module"
Load "glx"
Load "GLcore"
Load "v4l"