jtable

Refresh Jtable

I have a JTable created from Vector. How can the JTable be refreshed to display new data that is added to the Vector? ...

How can I remove a column from a JTable with dragging?

In Outlook I can remove a table column if I drag the column header out of the table. How can I do the same in Java with a Swing JTable? A default drag & drop operation is not possible because this feature is independent of the target position. It depends only from the drag source. ...

automatically calculating column width in JTable

What's the preferred way of this (based on header & contents width I believe)? TIA. ...

Relationship between JTable, TableModel & TableData

Whats the relationship between a JTable, TableModel and TableData. If i just modify the TableData, does that also change the data display on the JTable component or i have to call some method to sync the two. I have looked at this, but it does not explicitly tell or show me the relationship in terms of updates ...

focus issue using a JComboBox as a cell editor in a JTable

I'm having issues with the following code, where I use a JComboBox to change a String value in a table cell. The JComboBox works fine, but if I click in the box and then click away without selecting anything the JComboBox's dropdown remains visible, even if I delete the row. Clicking on another Swing component like a JButton often caus...

JTable with a complex editor

I have many custom editors for a JTable and it's an understatement to say that the usability, particularly in regard to editing with the keyboard, is lacking. The main reason for this is that my editors are always created with a similar (though often more complex) situation to this: @Override public Component getTableCellEditorComponen...

JTable sorting rows in Java 1.5

Is there a simple way to sort rows in a JTable with Java 1.5 (setAutoCreateRowSorter and TableRowSorter appear to be Java 1.6 features)? ...

Swing GUI : Scrolling not updated when a JTable gets bigger

Hi, I got a Java Swing GUI and got a problem with a JTable in a JScrollPane. For some reason, when the rows of the table model are increased during the program execution, the JScrollPane isn't updated - that is, if the rows are increased so that the height of the table is over the height of the scroll view, the scroll panes aren't updat...

An efficient way to display a time counter in a JTable cell

A time counter shows the age in seconds of a row in the table. Ideally, it would be updated once per second. I know I can just increment the appropriate data in the table model, fire the events (one per row), etc. It seems like overkill. Is there a better, lighter way? ...

What is the easiest way to display the contents of an ArrayList of Objects in a JTable?

I have an ArrayList of Track objects. Each Track object has the following fields (all Strings): url, title, creator, album, genre, composer I want to display these tracks in a JTable, with each row being an instance of a Track object, and each column containing one of the properties of a Track object. How can I display this data usin...

cell editing in JTable

Hi, Im doin a project using JTable, i want to make my table cells editable. I used, public boolean isCellEditable(int row, int column) { return true; } My problem is, the cells are ediable but once after entering data into one cell and move on to the next, the previous data gets erased... kindly any one help me... ...

Editing a JTable with Vectors

Hi, I'm doing a mini project using JTable. I used the Vector type for the row values. For example, public Vector textData = new Vector();. The problem is when I edit the cells in the JTable, it is editable but not keeping the changed value. That is, when I enter data in 1 cell and move on to next cell, the previous data is not updated....

How do I drag and drop a row in a JTable?

How do you setup a JTable to be able to drag a row to a different index in the table. For example if I have 5 rows and I want to drag the 4th row to the 2nd position? ...

Change the Ctrl + click behaviour on a JTable

Is there an easy way to manipulate the controls on a JTable to give different functionality when there is a keyboard button pressed (ie. CTRL button) and a row is selected? I've been asked to create a table where the CTRL + Click (mouse click) on a row will only deselect a selected row, never select a row. If the user CTRL + Clicks an un...

Strategy for detecting an object in JTable row?

Here's the thing: a sortable JTable backed by JTableModel with an array of objects that populate rows (one object = one row). Need to delete rows. Without sorting, deleting an object is simple: get selected row index, delete array object under the same index. With sorting, though, row indexes mess up in a sense that they no longer match...

Resizing Jtable column widths wont work.

//can set column widths using percentages private void setPreferredTableColumnWidths(JTable table, double[] percentages) { Dimension tableDim = table.getSize(); double total = 0; for(int i = 0; i < table.getColumnModel().getColumnCount(); i++) total += percentages[i]; table.setAutoResizeMode(JTable.AUTO_RESIZE_O...

Getting real row indices of selected rows in JTable when columns are alphabetized.

If the columns of my JTable are unalphabetized, I can use getSelectedRows() and get values of their rows without any trouble. But, if the user clicks on the column name and the rows are alphabetized in that column, getSelectedRows() returns not the currently selected rows, but the rows that were originally there before alphabetization. ...

JTable no update when selection

Hi all When I select a row in a JTable, my JTable doesn't get updated anymore. When I don't select a row, the code beneath works as expected. A row is added to the JTable. @Override public void update (Observable arg0, Object arg1) { if (arg0 instanceof Logger) { LogItem last = systemController.logController.getLog().getLastLog...

How do you remove selected rows from a JTable?

I've tried this: public void removeSelectedFromTable(JTable from) { int[] rows = from.getSelectedRows(); TableModel tm= from.getModel(); while(rows.length>0) { ((DefaultTableModel)tm).removeRow(from.convertRowIndexToModel(rows[0])); rows = from.getSelectedRows(); } from.clearSelection(); } But, it sometimes leaves one stil...

keeping JTable selection in viewport

I'm using GlazedLists to autogenerate an EventTableModel from an EventList, for use with a JTable in a JScrollbarPane. I'm using the EventList as a FIFO, a bunch of elements are added to the end, then a bunch of elements are sometimes removed from the beginning. When elements are removed, the selection works exactly as I expect: even th...