jtable

Tame Swing examples - initial images online

Whew, getting all the images together for the Tame Swing sample applications is taking a little time and a lot of effort. I hadn't thought about how to organize it, and now that I have a better feel for what I want to do it's just a matter of time.

If you want to see the images of the running applications I do have them on a temporary page here. Please note that this page may change at any time.

How to create a JComboBox in a JTable column with JFormDesigner

In a heavy day of JFormDesigner use, I just learned how to create a JComboBox in a column in a JTable, using only JFormDesigner.

First, create your JTable in JFormDesigner. I'll skip the details here, hoping that process is easy enough. Then, click the ellipsis button for the model property in the Properties list. This brings up the JTable model editor.

JFormDesigner - how to set the column width of a JTable

I just noticed that you can set the preferred size of a column in a JTable using JFormDesigner. If you're looking at a JTable in the normal JFormDesigner view, click the ellipsis button for the model property in the Properties list. This brings up the JTable model editor.

Next, click a cell in the column you want to modify. Then on the bottom-right of this dialog you'll see a few fields labeled "Pref. Width", "Min. Width", and "Max. Width". Just type in a value you want for the preferred width of your column.

JTable popup menu example

JTable popup menu introduction

Here's a copy of a class file I created to demonstrate how to put a popup menu (JPopupMenu) on a JTable in a Java application. Actually, the intent of this particular class was to see if I could get the popup menu to work on the header cell of a JTable, but that ended up being a no-brainer.

How to add a JPopupMenu to a JTable

Here's an example of how to add a JPopupMenu to a JTable. The purpose of the popup menu is to let the user right-click on contents in the table and work directly with those contents.

In the code below I've taken a real class and trimmed it down considerably for these demo purposes. I hope the code remaining is useful enough to help you implement your own JPopupMenu on a JTable, or perhaps in other components as well.

Initial JDialog - JTable size

(From a recent email.) Help, I have a 13-column JTable, inside of a jscroll pane, inside of a borderlayout, inside a JDialog. Ideally, I would like the dialog to initially open up to the correct width needed to display the 13 columns without horizontal scrolling.

Setting the preferred width of each column (only) does not work very well. Setting the minWidth gets the columns to open up to the correct width, but then the last 7 or so columns fall off the right hand side of the dialog.