jtable

JAVA: Put Image in jTable Cell

Hi I need to display an image in one of jTable cells. I wrote this: class ImageRenderer extends DefaultTableCellRenderer { JLabel lbl = new JLabel(); public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { lbl.setText((String) valu...

Java Swing - Can i make a JTable column without borders ?

I have created a column with cells that contain a JTextArea + A JButton inside it, as you can see in the image below in Column 3 : But i have faced lots of problems with my CellRenderer and CellEditor when updating the cells values in that column, as my code is a bit complicated. So instead i want to replace that column with 2 columns...

Search in JTable

I have created with Java Swing a dialog window which presents in a JTable a list of items. I would like to implement some sort of search functions. Can anyone suggest me the best way to implement such feature? ...

How to make the jList selectable inside a jTable.

How to make the jList selectable and jScrollPane scrollable inside a jTable. This is my table code : private JTable getCalendarTable() { if (calendarTable == null) { calendarTable = new JTable() { public boolean isCellEditable(int nRow, int nCol) { if (nRow % 2 != 0) { return ...

JComboBox in a JTable cell

Hello... I have a JTable created using a model, which is based on a matrix of objects. For each row, I want to put in a specific column (the 5th) some information using a JComboBox. I have tried the following: for(int i=0; i < n ; i++) { ..... data[i][5] = new JComboBox(aux); // aux is a Vector of elements I wanna insert } ta...

Java - Changing JTable renderer per class

Hello, I was hoping someone could explain something to me as I found my solution, but I don't understand why it works. I wanted to set a default renderer by Class type to a whole table, not knowing at creation where objects will be in it. I had declared a JTable and set the default renderer to that of my own, for the Calendar class so...

Intersecting JLabels inside a JTable

In the below image I am trying to achieve the following.I have a table and lots of labels embossed over table cells.The height of the labels is always equal to the cell height.So if two labels come in the same point one hides the another as shown in the longer rectangles with red rect over blue.Alternatively what I want is to make the he...

Correctly sorting doubles with JTable

I have a table where the first column contains Strings and the second contains doubles. stars = new StarDatabase(path); Object[][] data = new Object[stars.size()][2]; int i = 0; for (String name : stars.keySet()) { data[i][0] = name; data[i++][1] = stars.get(name).period; } StarsTable = new JTable...

JTable without horizontal and vertical lines

How to create a JTable without vertical and horizontal lines in it... ...

Switching values when editing a cell

I have a JTable which uses a custom TableModel to display a series of object instances. There's a switch case inside getValueAt(int row, int column) to return values according to given attributes (see below). One return statement involves returning a value of 1/0 as true/false. Is there a way that I can modify this TableModel so that it...

How can you disable all sorting code in JTable in 1.6

I have a JTable extension that has been in use since Java 1.3/1.4 in the project that provided things like column reordering and sorting by clicking on the column. We are upgrading to Java 1.6, and the new JTable stops the old sorting code from working. It would be somewhat extensive rework to fit everything to the new JTable API. Until ...

Java Swing - Multiple column headers in a JTable?

Hello Community. Is there any way to create multiple column headers in a JTable? I mean, normally there is only one row, but I need two of them with the same format (headerlike), and combine some cells of one of those headers. I need something like this: Header0 | Header123 | Header4 Header0 | Header1 | Header2 | He...

How to get rid of the border with a JTable / JScrollPane

Hi All, If you run the small sample below you'll see a border around the center region. I'm not sure why this border is showing. It happens when a JTable is in a JScrollPane. I tried various things to remove it but so far no luck. A JTable without the JScrollPane shows no border. See sample below. TIA. public class TestScrollPane e...

JTable - multiple cell editors in one column

I would like my JTable to use different cell editors for different cells in a single column. Think of a two-column label-value table like: Name | Value --------------+-------------------------------- Identifier | ST33442 (string editor) Purchase Date | 7/7/10 (custom calendar editor) Status | Broken (combo editor) H...

How can I keep columns of a JTable from resizing when I resize the JFrame?

This code puts a JTable into a JFrame (sole component of the whole UI): JFrame frame = new JFrame( "Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = appender.createTable(); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); frame.getContentPane().add...

How can I fix the column in JTable so that the column is always visible

How can I fix the column in JTable so that the column is always visible ? If I use JViewport than for the first time table is coming correct but when I click btn for the second time the next column in the Jtable is made fixed this continues each time. ...

Common Scroll bar for two Jtable

I have two JTables sharing the same Model object and the first JTable returns the first two columns and the next JTable returns rest of columns.I have a common scroll bar and moving the scroll bar moves both at the same time.Initially I have 10 rows in the table and I try to add 22 rows on click of a button.When I add the rows I delete ...

Adding button to a jtable

Hi I am having a table in which i have to adda JButton. I am doing TableColumnModel colModel = table.getColumnModel(); colModel.getColumn(0).setCellEditor(new MYCellEditor(new JCheckbox())); MyCellEditor extends DefaultCellEditor{ public MyCellEditor(JCheckbox checkbox){ super(checkbox); Jbutton button = new JButton("Start...

JTable - wrap text in multiple cells

I know how to implement a wrapping cell renderer, but all popular implementations break when you have multiple wrapping columns. They set row height on demand, but this way one column can override another one's settings. Usually it's de facto the last column what determines row height. E.g. for this data: | Fairly lengthy text | Shorte...

Netbeans GUI builder and jtable stateChanged fired when add custom java bean to gui

Hi all, i make some custom java beans components to add at my GUI. This componenent contains a jtable with a stateChangeListener, the problem is when i add this component to my GUI stateChaged is fired (and fire an exception). How can i resolve this? ...