Questions tagged [jtable]

JTable is a Java Swing component used to display and edit regular two-dimensional tables of cells.

JTable is a Java Swing component used to display and edit regular two-dimensional tables of cells.

JTable is used to display and edit regular two-dimensional tables of cells. See The Java Tutorial: How to Use Tables for task-oriented documentation and examples of using JTable.

Reference: Class JTable

8514 questions
2
votes
3 answers

Java JTable: Setting a primary column to always sort by first

I'm using a JTable with say 3 columns, displaying information about files and folders: Col1: Either "file" or "folder" (String) Col2: Name of the file or folder (String) Col3: Creation date (Timstamp) I can easily sort the table by any column.…
Andreas
  • 31
  • 1
  • 2
2
votes
2 answers

JScrollPane doesn't dispatch event

I have a JTable inside JScrollPane inside JPanel. And I have a MouseListener added to the last JPanel. The problem is, I can't listen to mouse events when mouse pressed on free space outside JTable. I have another JPanel with JTextField in it, and…
SeniorJD
  • 6,946
  • 4
  • 36
  • 53
2
votes
2 answers

using JTable cell editor

I am not sure why the editor i am setting for my jtable is not being called. I used the editor example from another SO Question. When i edit my jtable it simply edits as string... i expected it to accept only number values. may be some exception if…
Mohamed Iqzas
  • 976
  • 1
  • 14
  • 19
2
votes
1 answer

Refresh table JTable with data from a Excel file

I have a code to populate a JTable with data from a Excel File. The problem is that after set data to the JTable, I can´t to repaint the table with the new data. The information charging properly but no refresh the table. I charge the data by a…
mrvelez13
  • 23
  • 1
  • 4
2
votes
2 answers

JTable AutoCreateRowSorter sorting Numbers As Strings

I have a JTable: JTable table = new JTable(); String[] colNames = {"c1"}; DefaultTableModel model = new DefaultTableModel(); Integer[] x = new Integer[10]; int[] xi = {0,1,2,3,4,5,6,7,8,9}; for (int i=0; i<10; i++){ x[i]=new…
Eduardo
  • 6,900
  • 17
  • 77
  • 121
2
votes
1 answer

Sort JTable as I like

I have a JTable with follow values: Name age money A 13 SGD23 B 41 SGD133 If I click the Header(Name), it will sort as A,B, click again, will be B,A But for the money, if I click it, I want to…
Sstx
  • 604
  • 1
  • 8
  • 21
2
votes
1 answer

Changing the alignment for TableCellEditor objects

I have left-aligned my cell renderers, but how do I left-align my cell editors? This happens when I edit one of the cells import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import…
MxLDevs
  • 19,048
  • 36
  • 123
  • 194
2
votes
1 answer

Why do JTables make TableModels non serializable when rendered?

So recently I was working on an a tool for us here to configure certain applications. It didn't need to be anything really awesome, just a basic tool with some SQL script generation, and creating a couple of XML files. During this I created a series…
Mark W
  • 2,791
  • 1
  • 21
  • 44
2
votes
1 answer

How to receive mouseDragged events for my JTable

I'm trying to write a customized Drag and Drop behavior for a JTable, but can't receive MOUSE_DRAGGED events. I guess the problem is the native DnD operation consumes the event (as mantioned in mouseDragged's javadoc: "Due to platform-dependent…
Elist
  • 5,313
  • 3
  • 35
  • 73
2
votes
1 answer

JTable header background color

I'm trying to put background color on the JTable header but it seems that it doesnt change the header's color this is my code for my JTable.. what am I doing wrong? Color headerColor = new Color(25, 78, 132); itemTable = new JTable(){ …
Criz
  • 77
  • 4
  • 12
2
votes
2 answers

JTextField.selectAll() works strangely

I'm trying to implement a JTable which has to obey the following rules: Only the 3'rd column's cells can be edited. When double clicking any cell in row X, the 3'rd column of row X will start edit. Whenever start editing a cell, the text inside of…
user1028741
  • 2,745
  • 6
  • 34
  • 68
2
votes
2 answers

Get JTable cell value with rowInModel Or rowInTable?

Which is correct for getting a cell value from a table: int rowInTable = table.getSelectedRow(); int rowInModel = table.convertRowIndexToModel(rowInTable); Object id = this.getValueAt(rowInModel,1); Or: Object id =…
Sajad
  • 2,273
  • 11
  • 49
  • 92
2
votes
1 answer

How to store Student Daywise attendance in database and display in JTable?

I have to write a Attendance Module for a school. I am using Java Swing to design the screens. When user click on attendance tab of JTabbedPane, two buttons are there: 1) Add Attendance 2) Display Attendance Here to add attendance user have to…
Coder
  • 116
  • 1
  • 15
2
votes
2 answers

Create JTable from ArrayList of Objects - Java

How do I display my "Click" objects in a JTable? ArrayList myClicks = new ArrayList(); Click click = new Click(620, 1028); Click click2 = new Click(480, 230); myClicks.add(click); myClicks.add(click2); It should look something like…
Connor
  • 670
  • 3
  • 9
  • 29
2
votes
2 answers

JTable all column aligned right

Is there a way to align all the column in jtable at the same time? using this: DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer(); rightRenderer.setHorizontalAlignment( JLabel.RIGHT…
Mohammed Falha
  • 967
  • 8
  • 22
1 2 3
99
100