Thursday, April 3, 2008

JTable : Adding Cell Listeners, Getting cell values

Here I intend to show you a sample program which demonstrates how to get the values edited by user in JTable. This is accomplished by using the CellEditorListener Interface. Note the Table Header, Column values, the font type and font size is set custom.This sample program also has the ability to retrieve data from the cell, by mentioning the row and column.

Have a look on these API's that I have used specific for getting the results I just mentioned above
1) javax.swing.event.CellEditorListener

2) javax.swing.event.ChangeEvent
3) javax.swing.table.TableCellEditor

4) javax.swing.table.JTableHeader

Click here to view the code : JTableDemo (2)

Sample screenshots while executing the program

Tuesday, April 1, 2008

JTableDemo : How to add rows to JTable, How to create a JTable by specifying Table Headers and Row Values.

The basic use of JTable is presenting Table, i.e, rows of column centric data to the user.
Here is a program that uses JTable to present such a sample data. Also provision for adding data/rows randomly.
The major Swing API's used for this pupose are
1) javax.swing.JTable
2) javax.swing.table.DefaultTableModel

There are more uses for this swing API, other than just presnting data.

Click Here to view the code

The figure is screenshot when the code mentioned here executes

Tuesday, March 25, 2008

Setting the Background Image on JFrame

To set the background image on JFrame, there is no such direct methods as setBackground(). So we have to build our own interfaces to do that. Here is an example which uses the JPanel swing component to set the Background Image.

Click here to view the code

or

Click here : JFrameBackgroundImage

Fig : shows the screen when you run the above code. you need to have an image named "image.jpg" for the background image to be placed in the same directory/folder where the class file resides.

Thursday, March 20, 2008


A simple program illustrating how to create a swing type frame and how to draw a string above it.

Sample Screen Shot
Click here to view the code

JFC Swing

FC is short for Java Foundation Classes, which encompass a group of features for building graphical user interfaces (GUIs) and adding rich graphics functionality and interactivity to Java applications.


"Swing" was the code name of the project that developed the new components. Although unofficial, it's frequently used to refer to the new components and related API. "Swing" is immortalized in the package names for the Swing API, which begin with javax.swing.