jtable

How to export data from JTable to CSV

Hi all, I am just having problems starting a bit of code to extract values from JTable so that I can eventually say them as a CSV file for viewing on Excel. Currently I have a JTable created using the following code: package com.alpha; import javax.swing.*; import java.awt.*; public class JTableComponent{ public static void main(S...

JTable - explanation of the setValueAt method in this code below

Can I get an explanation of how the setValueAt method here works ? final DefaultTableModel model = new DefaultTableModel(data, columns) { @Override public boolean isCellEditable(int row, int column) { switch (column) { case 0: return true; case 1: return true; ...

JTable JCheckbox - trying to use a checkbox in one column to return a double value in another

I am trying that if a checkbox in column0 is selected a double value will be displayed in column2. Not sure where I am going wrong. Please review the code and advise.....thx.... package JavaTutes; import java.awt.; import javax.swing.; import javax.swing.table.*; import TablewCheckBoxComboBox.HeaderRenderer; public class TableWithCh...

How to change a table content based on the selection of a row from another table

I have created a JDialog which displays two different tables. When the user selects a row from the first table, the content of the second table should update accordingly and display some new data. Can someone give me some guidelines in order to create such table behaviour? Thanks! ...

How to implement jtable with variable row-height

None of the answers to two previous questions (here and here) resolve my problem. I have a multi-column jtable for which I want to display string-content of some columns over more than one line within the cell based on newline char's ("\n") within the string. The number of newlines per string is random, known only at run-time. Only the ...

Help on XML to JTable Please

Hi all, I am trying to learn how to import from XML to JTable. I am analyzing the following code in an attempt to understand what is happening. The problem is I am unable to figure out why am I failing to see any values in the JTable. I am sure that the XML is being parsed using the DOMBuilder etc. I have included the code and the X...

JTable column headers localization

I have a subclass of javax.swing.table.AbstractTableModel that defines table column headers like this: protected String[] columnNames = new String[] { "Column1", "Column2};. How do I localize the columnNames from a resource bundle? I want to read the column headers from a .properties file instead on hard-coding them in my code. Is there ...

Interaction with a cell renderer in JTable

Is there any way to get a cell renderer to respond to mouse events, such as mouseovers? ...

How do I speed up JTable built in table sorting?

I have a JTable with a custom TableModel that extends AbstractTableModel. I have also used the built in table sorting by calling: table.setAutoCreateRowSorter(true); The model also return the right class of the data for each column from the getColumnClass() call, which from what I read should ensure the fastest sorting being done. W...

problem when implementing a selection listener in a JTable

I am developing a JTable with different rows. I would like to associate an event to the selection of a row in this table. I have used the following selection class to provide behaviour to the table selection: public class TableSelectionListener implements ListSelectionListener{ public Integer item; public TableSelectionListener(In...

Creating a JDialog with three related lists

I am an inexperienced Java Swing developer and I need to create a JDialog which displays three different lists of data. The user's selection of an item in the first list will update the content of the second list and the selection of an item in the second list will update the content of the third list. Also when the dialog is launched th...

JPanel in a cell of a JTable

How could I put a JPanel into a cell of a JTable? (There would be a column what would contain String objects, and an other column with JPanel objects. ) ...

Weird behavior of a MouseListener added to a JTable

I've hooked up a mouse listener to a JTable to call some stuff when mouse cursor leaves table's bounds. However, mouseExited() method is also called when the mouse cursor is leaving individual cells of a table. Is it some strange quirk in my code or a bug in Swing? EDIT: I didn't mention that my table is a subclass of a JTable and not a...

JComboBox sizing issue in a table with Multi line Cells

Hello Everyone, I recently had a problem where I needed to have a field that can wrap the text and increase the height of the row as the text is wrapped, similar to Microsoft Excel. I managed to get it working correctly, the only problem is that the table contains multiple JComboBoxes. When the row's height increases from the field tha...

GlazedLists and JTable with multiple sources

I have 3 ArrayLists and a JTable. I would like to be able to add/edit/remove elements from the selected (from one of the 3) ArrayList by selecting the elements in the JTable and for example clicking on a button. I have this code for using only one ArrayList: /* ... */ EventList<MyClass> eventList = GlazedLists.eventList(myFirstArrayL...

How to retrieve header values from JTable

Hi! How can I retrieve the header values from a JTable? Thanks. ...

Change the background color of a row in a JTable

I have a JTable with 3 columns. I've set the TableCellRenderer for all the 3 columns like this (maybe not very effective?). for (int i = 0; i < 3; i++) { myJTable.getColumnModel().getColumn(i).setCellRenderer(renderer); } The getTableCellRendererComponent() returns a Component with a random background color for each row. How co...

JTable: how to add data without displaying ?

I have a column for images. I would like to attach some additional text information that will only be read but not for display. How can I achieve this ? I am looking for some "ghost" column. Looking for some way to store persistent data that stores temporarily on client java application, and later uploads it to the server. ...

clear contents of a jTable

I have a jTable and it's got a table model defined like this: javax.swing.table.TableModel dataModel = new javax.swing.table.DefaultTableModel(data, columns); tblCompounds.setModel(dataModel); Does anyone know how I can clear its contents? Just so it returns to an empty table? ...

JTable with a CellEditor containing a JComboBox on a JPanel

Hello, you can reference this question for the initial problem: http://stackoverflow.com/q/3826264 . This table consists of cells that are both editable and not editable. For some reason, clicking on the cell editor that contains the JPanel with the JComboBox after clicking on a non-editable cell does not bring the cell into edit mode....