jtable

JTable listener problem

I added a mouse clicked listner to my jtable, when i double click the row, will pop up an window accordingly. jTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { double amount = Double.parseDouble(jTable.getValueAt(getSelectedRow(), 4).toString()); String remarks = jTable.g...

JTable Insert row and refresh

Hi All, I am trying to create simple application where JTable gets updated and refreshed after data is changed.Structure is as follows. 1)Class Main which contains JFrame,JTable details. 2)SampleTableModel class which extends AbstractTableModel.I am overriding most of the methods. import javax.swing.table.*; import java.util.*; public...

create TableModel and populate jTable dynamically

Hi all! I want to store the results of reading lucene index into jTable, so that I can make it sortable by different columns. From index I am reading terms with different measures of their frequencies. Table columns are these : [string term][int absFrequency][int docFrequency][double invFrequency] So i in AbstractTableModel I can defi...

Drag and drop rows with jtable

Hello, I am programming a Matrix Explorer that allows me to reorder the rows and columns of a matrix. The Problem that I have is that I want the drag and drop to be visually consistent, meaning that the rows reordering should be visually similar to the one of the columns reordering( that is already implemented in Jtable). In the Jtable...

Initial state of autoCreateRowSorter in Swing JTable

I have this JTable on my Swing app with the autoCreateRowSorter enabled. My table only has 3 columns, two strings and one int, it works well for all of them when I click the column headers. However, I'm looking for way to do it programatically. I wanted to set the "initial state" for this table. With the Windows look and feel, the colum...

Rendering Dragged object during drag

Hello, I have been stuck on this problem for a while now. I want to drag a row in a jtable to reorder it. But I really want the user to see the row while dragging it and not just the default "drag" rectangle symbol. So I took a look at the java DnD tutorial finding it very useful, but.. The problem is that I still dont know which meth...

JTable custom header renderer that looks like other headers with nimbus look and feel?

Any time I create a custom header renderer for a JTable it ends up not looking correct with the nimbus look and feel. The default table headers have a silvery gradient, custom renderers do not look that way. In the past I just avoided creating custom header renderers. Is it possible to copy the default look onto my new custom renderer? B...

Allowing users to resize columns of JTable

Im creating a table which is dynamically changing its width. And I add columns by time as well. And I have bounded this table to a scrollpane. Here I have set the auto resizing to false in the JTable (else it will fill the whole area from the beginning). And I'm adding images to cells using cellrenderer as well. Now I need to allow use...

JTable custom cell renderer to create row header

Can somebody please explain how I would create row headers? I already have the data and header texts set in the JTable: all I want to know is how I can use a cell renderer to take that first column (i.e. the row header column) and make it look like the column headers (i.e. the first row). Right now its background is white, so it looks ...

JTable - Getting a cell into Edit mode on pressing Tab

This is possibly has a trivial solution, but I am at the end of my tether so I hope somebody can help out. I use a JTable which has a custom renderer and a custom editor for a set of columns. The renderer uses a JLabel component and the editor uses a JSpinner component. Our users want to be able to enter values in a column, and then pre...

How to invoke DefaulCelleRenderer from a CustomCellRenderer for a specific JTable cell

Hi All, I have a class that has a Boolean field in it. I display in a JTable a list of of those classes. I created a CustomCellRenderer to change the background color of the rows, so I could have different colors. the problem: when the customrenderer is applied on the Boolean field, (true/false) is rendered instead of the default rende...

JTable .. colour of selected row

Hello pip`s, I have a JTable in Java that has a custom dataMOdel and custom renderer. Now when i select some cell it has a dark blue border around it. I want the selected row to be all highlighted in some colour. How to do that? ...

Jtable live updating problem

Hi all, I'm trying to display a jtable in a pop up Jframe and am running into some problems. What i'am trying to do is as follows: catch a button action event in the main frame and display a pop up frame with a jtable populated with some data. The problem i have is that the jtable is populated with metadata i receive from a ...

JTable's and DefaultTableModel's row indexes lose their synchronization after I sort JTable

JAVA NETBEANS // resultsTable, myModel JTable resultsTable; DefaultTableModel myModel; //javax.swing.table.DefaultTableModel myModel = (DefaultTableModel) resultsTable.getModel(); // event of clicking on item of table String value = (String) myModel.getValueAt(resultsTable.getSelectedRow(), columnIndex) I use JTable and DefaultTab...

Resize JTable in JScrollPane by dragging

Hello all, How can I implement the functionality of being able to resize a JTable by dragging a corner by mouse (to see more rows during a single view) which is embedded in a JScrollPane? Is their any other easy alternative way? Thanks a lot. ...

JAVA - Strange problem (probably thread problem) with JTable & Model

I am using 2 Tables (JTable) with their DefaultTableModels. The first table is already populated. The second table is populated for each row of the first table (using an SQL Query). My purpose is to export every line of the first table with it's respective lines of the second in an Excel File. I am doing it with a for (for each line of ...

java swing : JTable strange behavior from getAccessibleChild() method resulting in null pointer in client code

Hello, I've encountered a strange behavior from JTable (JDK 1.5_22): After a selection change in the table and under some unknown particular circumstances, the JTable will call the cell renderer with 'null' for the value parameter. This will eventually lead to a nice 'Null Pointer Exception' on a custom renderer code that is not ready f...

Intercept jTable selection change events

I found this forum thread which suggests overriding ListSelectionModel to prevent rows from being selected. I would like to prevent selection changes when there are unsaved changes (external to the table) for the currently selected item UNTIL the user confirms the discard. Something like: public class confirmSelectionChange extends Def...

Mouse event in Java

I am trying to move a JComponent say a label over a table.I am tracking this event using MouseMotionListener's mouseDragged method.This method perfectly helps me in tracking the item.Is there a way to track the mouse release after dragging is complete(.ie the dropping event). tktLabel1.addMouseMotionListener(new MouseMotionListener() ...

JTable after setDefaultRenderer Row selection problem

This is my JTable Renderer class. After I applied this to my jTable, when i click on the row it only highlight the cell instead of whole row. I tried to setRowSelection(true) and setCellSelection(false) but still no use. class jTableRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable tab...