jtable

SwingX JXTable: use ColorHighlighter to color rows based on a “row object”

自作多情 提交于 2019-12-30 09:34:21
问题 I'm using JXTable and I know how to do this based on DefaultRenderers for JTable, but I want to know how to do it in a way that's JXTable-friendly based on HighlighterPipeline. I have a list of objects displayed in a table, and each row represents one object. I would like to color the rows displaying objects of a certain type a different color. It looks like I should be using ColorHighlighter. But I can't find examples for this, other than the simple highlighters like "color every other row"

How to make JTable cell editable/noneditable dynamically?

走远了吗. 提交于 2019-12-30 08:20:08
问题 Is there any way to make non editable cell dynamically in jtable ? Whenever user gives input like false, i want to make non editable cell...I have seen in DefaultTableModel isCellEditable method.But if i want to use that i have create each time new object.So i want to change it non editable dynamically. Can you anyone please help me?..thanks 回答1: public class MyDefaultTableModel extends DefaultTableModel { private boolean[][] editable_cells; // 2d array to represent rows and columns private

Get row by index from JTable

孤街浪徒 提交于 2019-12-30 07:39:22
问题 How to get row with index i froj JTable ? I looked at member functions but there is nothing like getRowAt . Can anybody help ? 回答1: There is no "row" object for a table, so nothing you could get with a getRow method. You can ask getValueAt() to get the individual values, use it for each column and you have your complete row. 回答2: AFAIK, there is no such method. Write something like that: public String[] getRowAt(int row) { String[] result = new String[colNumber]; for (int i = 0; i < colNumber

Making ArrayList to JTable

[亡魂溺海] 提交于 2019-12-30 07:05:07
问题 I have an ArrayList<Map<String, Object>> Object, I need to display the content of this array in a JTable. The Map - Key is the column name and Object is the data, how can I put it up? Baiscally the Map contains multiple-rows from a table and all the rows are added to the array list, now I need to display them in a Swing application in the form of a table and perform sorting and filtering on them. 回答1: For datas embed your list in a TableModel. A DefaultTableModel is best. For columns, embed

JTable with autoresize, horizontal scrolling and shrinkable first column

僤鯓⒐⒋嵵緔 提交于 2019-12-30 04:58:07
问题 I am having trouble creating a JTable with scrollbars. I want a JTable with 2 columns and no visible scrollbars. If I enlarge one of the columns the scrollbars should become visible and the columns resize. I followed this answer How to make JTable both AutoResize and horizontall scrollable? and works fine which basically comes down to: JTable table = new JTable() { @Override public boolean getScrollableTracksViewportWidth() { return getPreferredSize().width < getParent().getWidth(); } };

Dynamically changing the column header text in JTable

北城以北 提交于 2019-12-30 04:43:06
问题 I have a table with 3 columns which have the following values in the headers: 'No.', 'X [mm]', 'Y [mm]'. This table contain the coordinates of points in millimeters. I have a checkbox on checking of which the table should repopulate to show the coordinates in inches. Moreover, the column header values should be: 'No.', 'X [in]', 'Y [in]'. In short I want to dynamically change the header text of the table. In detail: The table is a subclass of JTable. Moreover, a subclass of 'DefaultTableModel

JTable - Getting a cell into Edit mode on pressing Tab

邮差的信 提交于 2019-12-30 03:19:06
问题 This is possibly has a trivial solution, but I am at the end of my tether so I hope somebody can help out. I use a JTable which has a custom renderer and a custom editor for a set of columns. The renderer uses a JLabel component and the editor uses a JSpinner component. Our users want to be able to enter values in a column, and then press TAB or ENTER to move to the next editable cell in the table. If I understand correctly, this is the default behaviour for a JTable. However, this doesn't

How to add data to JTable created in design mode?

安稳与你 提交于 2019-12-29 09:35:06
问题 I created an initial JFrame that contains a table with three columns, as shown below: This JFrame was created in design mode, and so now in the panel's constructor, I want to load some data so when the user selects to open this JFrame, the data is loaded. My column data types are Object (generally 'Status' is for an image representing the status of the share - active or inactive), String for the share's name and integer for the number of active clients connected to that share. My question is,

Selecting a row from Jtable and get that row data to a another form window in Java

两盒软妹~` 提交于 2019-12-29 08:23:41
问题 I created following forms for Inventory management module. Functionality be done is; When I select a row from Drug List window and click Select, the relevant ItemID and Item Name want to add in the Edit inventory window in relevant text Fields. I set variables access modifiers as private and did coding. But Is't correct. Anyone know any method for code above functionality? 回答1: try this.. add two jlabel on drug list jframe.. 1)itemIDlbl 2)itemNamelbl then.. Note: DT is jtable variable name.

How to set a custom object in a JTable row

两盒软妹~` 提交于 2019-12-29 07:03:36
问题 I should tell this first, this is NOT about Rendering a Table cell. Here is the TableModel that i'm building using a 2D array based on a User object in my DB. List<User> userList = userManagerService.getAllUsers(); /* String[] col_user = {"Username", "Name", "Phone", .... } */ String[][] data = new String[userList.size()][col_user.length]; int i = 0; for (User user : userList) { String[] userdata = new String[col_user.length]; userdata[0] = user.getUserUsername(); userdata[1] = user