jtable

Changing the size of columns in a JTable.

I am creating a GUI program and I need a table with different sized columns. How do I change it so that the 1st column is smaller than the 2nd and 3rd column? ...

Single click in a drag and drop JTable

Hi Everyone, Sorry if this was asked before, I googled everywhere with no luck. Here's my problem: I'd like to drag and drop rows within a JTable. I cannot get it to work without first selecting the row, which is annoying, I'd like to get a similar behavior the Windows explorer has : if I single click on an item and start moving the mou...

JTable iTunes' like selection

Hi All, Is there a way yo get the same iTunes's selection mode behavior in a JTable: To drag a single row, the user just clicks that row, and multiple selection by dragging the mouse is NOT allowed (single selection mode) To drag a group of rows, the user has to hold down the control key (or shift). Thanks a lot ...

adding a JList to a table and adding the table to a scroll pane

I have created a JList and I want to add it to the table and then add the table to the scroll pane so that both of them will be contained in the scroll pane. import model.*; import java.awt. *; import java.text.*; import javax.swing.*; import javax.swing.table.TableColumn; public class ScrollPanel extends JPanel implements View { priva...

Empty model, empty table

I have a JTable as a viewer of a model that I have created. I can insert and remove columns and rows from this model. The problem is that when my model reaches size 0, i.e., no data in the model, the table continuouing showing the header for the last two columns. All the best, Leandro Lima ...

JMS Queue to JTable Update [Now getting exception after changes]

I am writing my own JMS Browser and I am struck at the JTable update of Messages from JMS servers. I have tried AbstractTableModel TableModelListener to make Jtable refresh when the data added into LinkedList. This below logis works , but its not updating realtime , means I would like to display each and every row added to Jtable immedia...

Creating and using Multiple Filters/Searches using JTable or GlazedLists

I looked up how to use multiple filters on here with a regular table and the answers all pointed to GlazedLists. However, the answers didn't specify how to use it. I was able to get one filter to work but do not know how to get more than one. For one filter I used: // nameE is a BasicEventList containing classes (name) which // c...

Can a Jtable save data whenever a cell loses focus?

The high level: I have a JTable that the user can use to edit data. Whenever the user presses Enter or Tab to finish editing, the data is saved (I'm asusming that "saved" really means "the TableModel's setValueAt() method is called".) If the user leaves the cell in any other way after making an edit, the new data is not saved and the v...

How to force a tooltip to update on a TableCellRenderer, when the text is identical ?

In a Java program, I am using a custom renderer for cells in a JTable. On this renderer I set a tooltip, for which the content depends on the current cell. When the values are different, the tooltip is updated, and will appear next to the mouse pointer, over the cell. However, when the text for this tooltip is identical when changing c...

Java: JTable adding and moving columns

Hi, im quite new in Java. I want to add Columns in a JTable at a specified index. For this i am using addColumn(..) and then move them with moveColumn(...), this works great at the first time, but when i add another column it kind of moves also the other(before added columns). Do you have any suggestions? this is the code i've written...

swing, show a JList over a editable jTable to select entries to autocomplete the text

Hello World ! I have a JTable with editable cells. Each Cell contains a CarretListener for quick validation of the entered text. But in one special cell you should be able to select entrys out of a list. The List is generated when you enter a text. The Programm serach in a list for entrys equal so the entered text, like google suggest. ...

java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 attempting to populate JTable

I'm subclassing JTable and using a DefaultTableModel to model my table data. The following class sets up the JTable, and adds one row to the model. import java.io.File; import java.util.Iterator; import java.util.Vector; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; pub...

Provide additional behavior when editing a cell in JTable

Hi SO'ers, I am creating a app in Java. I need to provide additional behavior when editing of a cell in a JTable. So ideally this will happen when the cell loses focus after editing. Depending upon some post processing I might reset the value of the cell. I tried using a a Cell Editor but it is not giving me the desired behavior. In th...

How do you add a border to a row in a Jtable?

I have a Jtable and I want to highlight a row by adding a border to the row. I have extended a DefaultTableCellRenderer and I figure the work needs to be done in the getTableCellRendererComponent method. I'm guessing that since there doesn't seem to be a concept of a row that I need to create a custom border for the individual cells in ...

JTable Won't Show On JPanel

Hi I have created a Jtable and can get it to show on my frame yet not on the JPanel I have ontop of my JFrame. I can't seem to change import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.util.ArrayList; import java.util.Comparator; import javax.swing.*; import javax.s...

how can we make an editable table?

what should I do for editing all the cells of a Table? for example if in a one cell is written "abc", I want to change it to" def", how can I do that? ...

JTable that can save to a file

Does anyone know of a JTable based Swing component OR code example that can save to a file? i.e: provides a menu item or button that when clicked on prompts the user for a file location and saves the table's contents to a file (CSV, XLS, TXT, or whatever). The easy part is looping through the rows and saving to a file. But there also ne...

How can I get the text in a JTable ?

For example I have a Table that I want to get text that's in the first column and store it in an ArrayList. ...

why it doesn't work correctly?

I have a table which in the first column ,I have student's name.such as "Esfandyar Talebi","Arash Nouri" and the number of rows can be changed. and just 2 rows are filled from 4 rows. the code that I have written: List<String> professorsName = new ArrayList<String>(); for(int i=0;i<InformationTable.getRowCount();i++){ ...

Java Swing: How to bind a JLabel's text to a column in the selected row of a JTable?

I am using Netbeans and am trying to find a way for the IDE to auto-generate the code for me. I remember binding a JLabel's text to a column in the selected row of the JTable before, but in that case, the JTable's values were from an entity manager, and it was very easy. I was wondering if there is a way to do it even if the JTable is no...