jtable

Can jTable cell act as jList multiple row.

I want to show multipleline content in a cell like a monthly scheduler. Currently i am using jTextArea but the data is still too long. I was thinking to using jList, is there any sample jTable using jList as cell. Any other good practices or suggestion to display long data in one cell? ...

Load an array to a Java table.

This is driving me crazy. I read the Sun's tutorial regarding the creation of a basic table with a default data model, but cant figure out a simple example about how to load an array of data-objects like: class dataObject{ String name; String gender; Byte age; public dataObject (String name, String gender, Byte age){ this.name = nam...

JTable adjusting column width or height

In my JTable is there a way to restrict the user in adjusting the height of the row or width of a column using the mouse.I am already using JTable table=new JTable(); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getTableHeader().setReorderingAllowed(false); The table is inside a scroll panel. ...

Stretching out JScrollPane - Java.

I have this structure: <JFrame> <JPanel backgroundcolor = "pink"> <JScrollPane> <JTable>!!!Data here !!!</JTable> </JScrollPane> </JPanel> </JFrame> How do i stretch the ScrollPane it to cover the full window without using setSize? This is how it looks like now: Thanks! ...

JTable with JList cell

Is there possible to make the JTable cell like JList behaviour ? I want to display few data in one cell for example "A", "B", "C". If using JTextArea I can't specify which data i was choosing. Example if I want data A mouse click and do certain action. ...

JTable Autoscroll

I am adding a label to a JTable and adding mouseMotionListener event to the label.The label moves across the table on mouseDragged event.The table contains more than 50 columns and only 15 columns will be visible at any point of time.Now if I want to move the label to the other side of the same row I can't move the label without moving t...

JTable autoresize, with a twist?

Hi . This is a well known autoresizer for JTable : public JTable autoResizeColWidth(JTable table, DefaultTableModel model) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setModel(model); int margin = 5; for (int i = 0; i < table.getColumnCount(); i++) { int v...

Vertical headers in JTable?

Hi! Is there a way to rotate 90º the column headers of a JTable? ...

Keeping a single column static inside a JTable

Is there a way to keep the first column of a JTable embedded inside a JScrollPane static on scrolling the mouse horizontally.The table contains more than 50 columns. ...

Common scroll bar for two JTable

I have two tables. One table is a fixed column(ie. the table will not have any impact on the scrolling of scrollbar of another table). These two tables have to be commonly scrolled by a vertical scrollbar.Any idea or suggesstion or examples? This is a continuation of the previous question. Fixed Column The answer for which is here Fixed...

Disable userinput on a JTable

Hey, Is there a way to disable editing a JTable after creating it. Because my JTable is created automaticly using GUI Tools and I cannot edit the source code where it creates the JTable. Cheers ...

How to highlight a particular column header in a JTable

I need to highlight a particular column header in a JTable.Is it possible to do that? Also is it possible to draw a vertical line inside a JTable ? ...

Java JTable export to PDF

Currently, I am using iText to convert my jTable data to pdf. private void print() { Document document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Gra...

After JTable cell setDefaultRenderer to jTextArea how to highlight the selected row in jTextArea

This is my renderer class tblCalendarRenderer extends JTextArea implements TableCellRenderer { JTextArea textField; public tblCalendarRenderer() { textField = new JTextArea(); } public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focused, int row, ...

JTable how to save the new Row index

Hey there, I have the following Problem. Let's Say I have a JTable with the folowing Values: 1 2 3 4 5 Now I select "3" and press a button which saves the index of the row and prints "3" I have another Button let's call it the "next button", when I press it it will print "4" Now I sort (Or in this Case just randomise) the whole Table...

Java - How to remove JTable cell bgColor when hovering on another cell ?

I have created my own TableCellEditor for a JTable column to do some special stuff while editing the cells of this column. In that TableCellEditor i define a color when a cell in that column is hovered, like this : public Component getTableCellEditorComponent(JTable table, Object value,boolean isSelected, int row, int column) { i...

JTable How to refresh table model after insert delete or update the data.

This is my jTable private JTable getJTable() { String[] colName = { "Name", "Email", "Contact No. 1", "Contact No. 2", "Group", "" }; if (jTable == null) { jTable = new JTable() { public boolean isCellEditable(int nRow, int nCol) { return false; } }; } ...

JTable: how to select columns at runtime

I have too many columns in a table to display them all at once, and would like to let the user change which columns are visible. How can I do this? note: It is easy to make the application select columns at runtime. What I am asking is what UI element(s) to add to allow the user to hide/unhide columns at runtime. ...

JTable with striped background

Using a different background color for odd and even rows is a commonly used trick to improve readability of large tables. I want to use this effect in Swing's JTable. I started out by creating a custom table renderer, but this can only be used to paint actual cells, and I also want to add stripes to the "white" part of the table where ...

How to have multiple JTable headers synchronize their column widths, sorting, etc?

I have an interface that has multiple small JTables stacked on top of each other. I would like their column sizes, sorting, filtering, etc to stay in sync. Is there a straightforward way to do this? For the column widths, I tried having them share a common TableHeaderModel but this seemed to pose unexpected problems such as only bei...