jtable

Question on jtable cell editors in swing

好久不见. 提交于 2020-01-11 11:13:13
问题 I want to implement a component that serves as a list of options, that a user can choose to select or not. Visually I thought that it would be best presented in a UI (if there is a better approach please tell me) as follows: Anyway, I thought that this could be implemented via a JTable (single column) and using a JCheckBox as a cell editor. I tried it but did not work. Example of code: public class ListRenderer extends JFrame { JCheckBox checkbox = new JCheckBox("Test"); DefaultCellEditor

Question on jtable cell editors in swing

六眼飞鱼酱① 提交于 2020-01-11 11:12:30
问题 I want to implement a component that serves as a list of options, that a user can choose to select or not. Visually I thought that it would be best presented in a UI (if there is a better approach please tell me) as follows: Anyway, I thought that this could be implemented via a JTable (single column) and using a JCheckBox as a cell editor. I tried it but did not work. Example of code: public class ListRenderer extends JFrame { JCheckBox checkbox = new JCheckBox("Test"); DefaultCellEditor

Generating a standard deviation plot from a row in a JTable

时光怂恿深爱的人放手 提交于 2020-01-11 07:45:11
问题 I am trying to create a JTable that I can be able to click on a row and it will display a standard deviation curve. Here is what my JTable looks like right now. So for example, the standard deviation for the string screen saver, action->login, login->disclaimer, ok would look like this (I plotted it in excel) So my question is #1 is this possible and #2 if so then how? 回答1: ChartFactory.createHistogram() with an IntervalXYDataset such as HistogramDataset might be a suitable choice.

Change Cell Editor for specific Cells with AbstractTableModel

别等时光非礼了梦想. 提交于 2020-01-11 07:21:35
问题 I have a written an AbstractTableModel for my JTable in my application. I see from tutorials that I can make the column to have a combobox by getting the column model and then the specific column for example: TableColumn sportColumn = table.getColumnModel().getColumn(2); ... JComboBox comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Chasing toddlers"); comboBox.addItem("Speed reading"); comboBox.addItem("Teaching high school");

JTable Cell Color

流过昼夜 提交于 2020-01-11 06:44:10
问题 Can someone give me an example of how to get the background color of a particular cell in a JTable? I am unable to find an example of how to do this. Plenty of examples on getting the value in a cell, but not the background color of a cell. 回答1: It should be something like the following (fixed according to all comments): Important: use table.prepareRenderer(...) to let JTable do all work for you public Color getTableCellBackground(JTable table, int row, int col) { TableCellRenderer renderer =

Unable to add two buttons in a single cell in a JTable

若如初见. 提交于 2020-01-11 05:51:08
问题 I am trying to make a dynamic table that fetches data from a database and adds those data in separate rows.. I want to add an extra cell with each row(dynamically) that contains two buttons...and on clicking those buttons some event should occur only on the respective row .. (P.S: I have managed to fetch data from the database and add it to the table though..) Here is an example: _____________________________________________________________ ID | Name | Application for leave | Accept/Reject |

How to add row dynamically in JTable

a 夏天 提交于 2020-01-10 10:22:52
问题 I want to add the row dynamically in JTable and I have writen the following code for that: tblTaskList = new JTable(); tblTaskList.setShowVerticalLines(false); tblTaskList.setCellSelectionEnabled(true); tblTaskList.setColumnSelectionAllowed(true); tblTaskList.setBorder(new LineBorder(null)); for (int count = 1; count <= 10; count++) { tblTaskList.setModel(new DefaultTableModel(new Object[][] { { count, "title1", "start", "stop", "pause", "status" }, }, new String[] { "status", "Task Title",

Making a JButton clickable inside a JTable

╄→гoц情女王★ 提交于 2020-01-09 07:20:28
问题 Here is the screenshot of what I want to do : What's happening there is the JButton shows correctly but nothing happens when I click on it. After some search, I've found that the Object returned by table.getValueAt() is a String instead of a JButton... Here is the code : tblResult = new JTable(data,cols) { public TableCellRenderer getCellRenderer( int row, int column ) { return new ClientsTableRenderer(); } }; I use this for populating at run-time the JTable : ( tblResult is now Clients

Values repeating when Populating a JTable

≡放荡痞女 提交于 2020-01-07 05:19:27
问题 I have a JTable. And I've added the column to it within a method like this. private void createSearchResultTable() { DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); String columnNames[] = {"Title", "Author", "Edition", "Availability", "Reserve"}; for (int i = 0; i < columnNames.length; i++) { TableColumn column = new TableColumn(); column.setHeaderValue(columnNames[i]); columnModel.addColumn(column); } tblBookSearchResults.setColumnModel(columnModel); ButtonColumn

JTable#repaint() not functioning as expected [closed]

回眸只為那壹抹淺笑 提交于 2020-01-07 05:10:49
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . This application pulls data from a text file and inserts it into JTable . An Observer is attached to check every 300 ms if there is a change to the file