Tuesday, October 12, 2010

How to Change the Selection Mode in a Java JTable

JTable table;
.
.
.
table.setSelectionMode(ListSeletionModel.SINGLE_INTERVAL_SELECT);

Upgrading your Arch Linux Box

It's very easy to upgrade your Arch Linux box. Just make sure you are connected to the internet. If, for instance, you are using Cricket broadband, you can use wvdial to connect (run wvdialconf the very first time to create an auto config file).

After you are connected to the internet, just run sudo pacman -Syu.

Java Events

Adapter classes defined in java.awt.event:
Listener Interface Event Class Adapter Class
ComponentListener ComponentEventComponentAdapter
ContainerListenerContainerEventContainerAdapter
FocusListenerFocusEventFocusAdapter
KeyListenerKeyEventKeyAdapter
MouseListenerMouseEventMouseAdapter
MouseMotionListenerMouseMotionEventMouseMotionAdapter
WindowListenerWindoweEventWindowAdapter

Thursday, October 7, 2010

How to Initially Set Focus to an Element in Java

Let's say you have a form with a text field, a text area and a button, in that order. You want the user to be able to start typing into the text area right away without having to press the tab key first to go from the top text field to the text area below. Well you need to call the text area's resquestFocus() method. But here is something very important, you have to call that method after you make the form visble by calling setVisible(true). If you do it beforehand, it won't work...

Java JTable Cell Editors

I'm trying to understand JTable cell editors so I'll use this post to organize my thoughts to help my brain understand this new concept. This is a work in progress...

First of all, let's cover the sequence of events that take places before a cell editor is called:

  1. JTable detects a mouse click over one of its cells and calls isCellEditable() in TableModel.
  2. If the cell is editable according to TableModel, the CellEditor's isCellEditable() method is called as well. This second method call determines whether the cell is single or double-clicked (which is required to make a editable cell, well editable).

Tuesday, October 5, 2010

From AAC to MP3

I had all these aac music files ready to transfer to my ipod but for some reason, gtkpod would not allow me to transfer them. It kept complaining that the format was unknown. mplayer was able to play those files so what I did was use mplayer to convert those files to wav format and then I used lame to convert them to mp3, and voila, problem solved...

Chromium Adsense Issue

In case you haven't noticed, this site is supported with Google's Adsense ads. While trying to open an Adsense account using Chromium, I kept getting this error about my browser not supporting cookies.

Chromium is the open source version of Google's Chrome broser. For some reason the Adsense signup page has a hard time setting cookies in Chromium (did not test this wth the regular Google Chrome) even after I doubled checked my settings to make sure Chromium was setup to allow cookies. If you run into this issue, don't think it's you. I had to install firefox in order for me to be able to complete the Adsense signup process...

Monday, October 4, 2010

Partition Table Accident Update

I found an article at http://salingfamily.net/trav/linux/lost_partition.html about a way to try to recover a lost partition table. The article mentions using gpart, which is a linux utility that tries to guess the original partition table. So I went ahead and installed gpart in my Arch linux box:

sudo pacman -S gpart

The size of the utility is 27.1K so it didn't take long to download and install. Then, after going through the man page, I found out what parameters to use (the article doesn't go into detail as to exactly how to use gpart). I'm currently running:

gpart -W wdpartable /dev/sdf

What this command does is scan my usb hard drive at /dev/sdf and save its findings in the wdpartable file. Looks like it found a possible partition, although the size of it is very small so I don't think it's right. We'll see what else it finds...

External Hard Drive Mistery

I just experienced something interesting. I plugged in my external hard drive to a usb port in the back of my computer, and the hard drive kept making a noise as if it was trying to load iteself, like the kind of noise you hear when your computer is trying to play a scratched CD. Then I unplugged it from that usb port and re-connected it to a port located in front of the PC tower, and the hard drive works fine... interesting..

Partition Table Accident

A few days ago I made the big mistake of accidentally erasing my USB external hard drive's partition table. Now I'm doing some research to see if I can recover it. I will be reporting my findings as soon as possible...