Why do JTables make TableModels non serializable when rendered?

非 Y 不嫁゛ 提交于 2019-12-22 14:39:39
问题 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 of JTable objects with my own implementation of the AbstractTableModel. After I had built everything, and got to the point where I was testing saving and loading using the AbstractTableModel (just written to disk using the ObjectStreamWriter)

Don't updating JTable

て烟熏妆下的殇ゞ 提交于 2019-12-21 05:36:16
问题 I found sample with updating data, but it uses DefaultTableModel. When I created my own TableModel and my own data class, when I add data into JTable it doesn't update. How do I add a listener to my TableModel? Here is my code: package by; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.util.LinkedList; import javax.swing.AbstractAction; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing

Change/Update JTable content with JComboBox(category)

孤者浪人 提交于 2019-12-20 04:51:27
问题 I have a problem with my JTable. My JTable displays content of a database. One database table has the name category. Every category is displayed in the JComboBox. If I click on a category it should update the table content. Here is a short snipped of my code for you, so it is easier to help me. The code should be runable: (TestClass - Main) package test; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import

remove rows from JTable with AbstractTableModel

爱⌒轻易说出口 提交于 2019-12-17 20:54:27
问题 I would like to remove selected row from JTable with AbstractTableModel using a button. The code below works with DefaultTableModel: ... MyTableModel mtb; ... private String[].... private Object[][]... ... JTable table = new JTable(mtb) JButton delete; ... public void actionPerformed(ActionEvent e) { if(e.getSource().equals(delete)) { if(table.getSelectedRow()<0) { JOptionPane.showMessageDialog(this,"Select row"); } else { mtb.removeRow(table.getSelectedRow()); } } } but it deosn't work with

JTable not showing

ⅰ亾dé卋堺 提交于 2019-12-17 02:01:11
问题 In my application everything is distributed. On a action, application retrieves data from DB and saves in ArrayList<T> . I create an object of RelativeTableModel where I pass the ArrayList<T> . public void RelationsClicked() { ArrayList<Relation> data = myParent.dbOperation.getRelations(); RelativeTableModel tModel = new RelativeTableModel(data); // subclass of AbstractTableModel myParent.SetBrowsePanelData(tModel); myParent.SetMainPanel(CashAccountingView.BROWSEPANEL); } I have a

How do I make Swing delete an entry from a table by selecting rows and clicking delete?

牧云@^-^@ 提交于 2019-12-14 03:18:16
问题 I have a panel with one table in it. The table is a simple view of entities from database. I want the user to be able to select the entries(=rows) and click delete. I have my own table model that extends AbstractTableModel. I didn't find any method in AbstractTableModel to do this. Does it mean that this is not supported? 回答1: Delete a row(s) from a table is not always straight forward as the table could be sorted or filtered which means you first need to convert the view row to the model row

Java Swing | extend AbstractTableModel and use it with JTable | several questions

女生的网名这么多〃 提交于 2019-12-13 08:51:16
问题 I followed Oracle's model for implementing an AbstractTableModel http://download.oracle.com/javase/tutorial/uiswing/examples/components/TableDemoProject/src/components/TableDemo.java I did this because my table has to contain 3 columns, and the first has to be a JCheckBox. Here's my code: public class FestplattenreinigerGraphicalUserInterfaceHomePagePanelTableModel extends AbstractTableModel { private String[] columnNames = {"Auswahl", "Dateiname", "Pfad"}; private Object[][] data = { {new

How to make a cell behave like it's editable but have it read only?

三世轮回 提交于 2019-12-12 16:45:54
问题 I have a JTable in which I want the cells to behave the way it behaves when you have the cells editable, but the cells cannot be editable, in other terms, read only. So if I double click on a cell, I should only be able to select text within the cell and copy text from that cell. 回答1: is it possible to prevent the user to make any changes? You would need to use a custom editor: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import javax.swing

AbstractTableModel GUI display issue

让人想犯罪 __ 提交于 2019-12-12 06:29:02
问题 I'm making a GUI Project for database there are two classes which are for GUI's . And connector class is used to connect from user credentials. If credentials are correct than it fetch all data in the from of AbstractTableModel . When program run first GUI has a button in which we click it and it fetch all data in underlying TableModel . But i'm facing two problems. First in GUI2 class, sometimes it open like this. and sometimes it show like this I don't know why it's happening. And second

Dynamically set non-editable JTable row as editable

十年热恋 提交于 2019-12-11 20:20:03
问题 I have extended the AbstractTableModel class to make my JTable non-editable,expects the first row. By the way, i have overrided the isCellEditable(int row, int col) methode.By putting an integer variable, that hold the nextRow to activate, i got the first row respects my creterias.So, the problem is to make the next row active when the the cell in previous row column zero is filled by the user (data changed and must have a value).Her is my code so far. package MODEL.tableModel; import MODEL