jtable

Editable JTable Tutorial

Are there any good books or website that go over creating a JTable? I want to make one column editable. I would like to actually put a inherited JCheckBox component (that we created here) into one of the table columns instead of just having the table put JCheckBox in based on it being an editable boolean field. I have the JFC Swing Tut...

Dynamically added JTable not displaying

Java Newbie here. I have a JFrame that I added to my netbeans project, and I've added the following method to it, which creates a JTable. Problem is, for some reason when I call this method, the JTable isn't displayed. Any suggestions? public void showFromVectors(Vector colNames, Vector data) { jt = new javax.swing.JTable(data,...

JTable column spanning

I am trying to make a JTable that has column spans available. Specifically, I am looking to nest a JTable inside another JTable, and when the user clicks to view the nested table, it should expand to push down the rows below and fill the empty space. This is similar to what you see in MS Access where you can nest tables, and clicking the...

Button text in JTable renderer not visible. Why ?

I have a custom cell renderer set in JTable and it works but instead an "x" visible on buttons being table cells I see "..." (three dots). What did I miss ?? /*************************************************************************** * Listener reagujący na dodanie nowej wartości ****************************************************...

How to do a check before allowing editing of a given row in a JTable

The problem is quite basic. I have a JTable showing cached data from a database. If a user clicks in a cell for editing, I want to attempt a lock on that row in the database. If the lock does not succeed, I want to prevent editing. But I can't seem to find any clean way to accomplish this. Am I missing something? ...

How to change data in JTable cells?

I can set data in JTable constructor, and then user can change this data when program is running manually(typing from keyboard). But what method should I use in case I want to change data in some column? To change column header I use TableColumn method setHeaderValue. What should I use to set value in JTable cell? ...

Populate JTable from a Hashtable in Java

I have a function which gets a key from the user and generates a Hashtable (on a pattern specified by the key). After creating a Hashtable, I would like to populate a JTable so that each each column represents a key and every rows represents the values associated with the key. I tried everything but couldn't get this work. I'm not creati...

How to return actual cell component bounds in a JTable?

I have a custom renderer in a JTable to display Jcheckboxes for booleans. However, this causes a slight issue because when the user clicks in the table cell, but not in the checkbox, the checkbox is still checked. Is there a way I can return the bounds of the actual JCheckbox that is rendered by the JTable at a particular point so I ...

mixed java version JTable

Hi, I would like to use the JTable row sorter new in Java 6. But also I need it to be compatible in Mac OSX with Java 5. Is it possible to find out the JVM version during runtime and use different code for the JTable with and without row sorter? ...

JTable entire table data change

Is there a relatively simple way to change all the data in a JTable? For example, if I have a JTable named books which contains information about all books by a certain author, and then the user changes the author, I would have to update that table with a completely new set of information (note, because of the volume of data in question,...

JTable updates not appearing

I have a JTable with a custom TableModel called DataTableModel. I initialized the table with a set of column names and no data as follows: books = new JTable(new DataTableModel(new Vector<Vector<String>>(), title2)); JScrollPane scroll1 = new JScrollPane(books); scroll1.setEnabled(true); scroll1.setVisible(true); JSplitPane jsp1 = new J...

Java nested list to array conversion

What is the most efficient way to convert data from nested lists to an object array (which can be used i.e. as data for JTable)? List<List> table = new ArrayList<List>(); for (DATAROW rowData : entries) { List<String> row = new ArrayList<String>(); for (String col : rowData.getDataColumn()) row.add(col); table.add...

JTable selection change event handling: find the source table dynamically

I've implemented my own event handler and added it to the selection model of the table: table.getSelectionModel().addListSelectionListener(event); And implemented the method for "event" (mentioned above): public void valueChanged(ListSelectionEvent e) { log.debug("value changed"); } Unfortunately the event fires twice if I chan...

How to stop editing with DefaultCellEditor when a separate JBtton is pressed

Hi, I got a table with a custom TableCellEditor (extending DefaultCellEditor) with a JFormattedTextField as the editor component. Now I got problem: when I press a separate button while editing. When the button is pressed, the editor remains "open and active" while I'd want it to stop editing so that the changes made would be available...

Changing JTable reference at runtime - not appearing in GUI

Hi there, I'm trying to get to grips with Java ME development for the Pocket PC. I'm running the NSIcom CrE-ME emulator and building my application with NetBeans 6.5. The application is based around three tab panels, each of which have Swing components. The contents Swing components are updated at various points in the application. The...

how to control focus in JTable

What I want to do is when user finish editing of data in table cell to move focus onto another cell depending of what user entered, and to turn that cell into editing mode so user can start typing immediately with no additional action. This way user can focus on his work and software will do the 'thinking' about which cell should be edit...

Putting JComboBox into JTable

Hi, I want to put individual JComboBoxes into each cells of a JTable. ie. The JComboBox content is not identical for each cell. I basically would like to be able to just call the following code to add a row of JComboBox into the JTable. Anyone has any idea? Thanks JComboBox cb1 = new JComboBox(...); JComboBox cb2 = new JComboBox(...)...

refresh setCellEditor for JTable

Hi, I was looking for an answer for a previous question and had an ingenious idea to overcome a limit on JTable. I need the editor to be different on a row by row basis, whereas JTable can only handle a single editor for each column. So my idea is to use a MouseListener to check the row and column on the JTable and set new editor ea...

Making a cell in a JTable editable - the default value of the cell

Hello, I am working with Java, and I am trying to make a cell in JTable to be editable. My class implements TableModel and extends AbstractTableModel (so that I can use the method fireTableCellUpdated(rowIndex, columnIndex)), and I have implemented the methods isCellEditable() and setValueAt(). I represent a single cell in the table as ...

JTable values "jump" in another cell after pressing Enter

Hello, I am working with Java. I have created a JTable, and I have made the cells of the table editable. My problem is that when I select a cell and write a value in it, and then click Enter, the value, which I have typed does not stay in the cell where I have typed it, but jumps in another cell somewhere in the table. The value stays t...