tablemodel

Refreshing JTable when data has changed

廉价感情. 提交于 2019-12-25 08:57:29
问题 I have a problem with refreshing a JTable . I start with an empty ArrayList and after setting my choice of a combo box I load content to the ArrayList but JTable does not react to it - it remains empty. Is it a problem with a TableModel ? This is my code... public class ProjectTableModel extends AbstractTableModel{ private static final long serialVersionUID = 1L; private static ArrayList<String> caseList = new ArrayList<String>(); @Override public int getColumnCount() { return 1; } @Override

Pentaho - How to pass result-set (TableModel ) from xaction to prpt

て烟熏妆下的殇ゞ 提交于 2019-12-25 04:09:42
问题 I have an issue with pass result-set from xaction to prpt. When I use a example prpt then modify it, the report is ok. But when I create a new prpt (datasource: External, a TableModel type parameter is same as the first one) it does work, just prints out labels, miss the data. Did I miss something? Any help would be appreciated. Thanks 回答1: I resolved it. Click attribute of 'Master Report' on the Structure panel. Find query - name, add the value as the name of result set. 来源: https:/

How to refresh a JTable after database operations without frame reload?

戏子无情 提交于 2019-12-23 05:11:10
问题 I want to refresh a JTable after performing db operations like insert/update/delete without frame reload. Is there a programmatic solution to do so? 回答1: The answer depends on what type of TableModel you're using...and at what level the events are occuring. For example, if you have some kind of background Thread or "update" button and want to reload the content from the database, simple create a new TableModel based on the results from the database and apply it to the current JTable , this

How to make one mySQL's table column invisible

我怕爱的太早我们不能终老 提交于 2019-12-20 03:05:33
问题 I am running a query on ID column but I don't want it to be visible in my frame/pane. How can I achieve this? Shall I make another table, is there a function in sql/mysql which allows to hide columns? I tried to google it but havent found anything yet. Here is the code: public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int col = e.getColumn(); model = (MyTableModel) e.getSource(); String stulpPav = model.getColumnName(col); Object data = model.getValueAt(row, col);

How to make one mySQL's table column invisible

僤鯓⒐⒋嵵緔 提交于 2019-12-20 03:05:01
问题 I am running a query on ID column but I don't want it to be visible in my frame/pane. How can I achieve this? Shall I make another table, is there a function in sql/mysql which allows to hide columns? I tried to google it but havent found anything yet. Here is the code: public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int col = e.getColumn(); model = (MyTableModel) e.getSource(); String stulpPav = model.getColumnName(col); Object data = model.getValueAt(row, col);

JTable reading text files from second line

混江龙づ霸主 提交于 2019-12-18 09:44:08
问题 I'm working on JTable that reads text from a .txt file. the txt file gets updated dynamically after 3 sec. Now when I run the application, everything is good except that the output of .txt files comes in JTable from the second line. The first line of txt file doesn't appear on my JTable. Can anyone help? Here's the code: public class InterfaceFrame extends JFrame implements ActionListener{ public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {

How to refresh data in JTable I am using TableModel

风流意气都作罢 提交于 2019-12-17 07:39:11
问题 Hi, I have created my TableModel and want to refresh JTable once I added a new row. What should be added to the listener to "refresh" JTable? public class MyTableModel implements TableModel { private Set<TableModelListener> listeners = new HashSet<TableModelListener>(); //List<Staff> staffs = Factory.getInstance().getStaffDAO().getAllStaff(); private List<Staff> staffs; public MyTableModel(List<Staff> staffs){ this.staffs = staffs; } @Override public int getRowCount() { return staffs.size();

How to set icon in a column of JTable?

只谈情不闲聊 提交于 2019-12-17 06:51:53
问题 I am able to set the column's header but not able to set icon in all the rows of first column of JTable. public class iconRenderer extends DefaultTableCellRenderer{ public Component getTableCellRendererComponent(JTable table,Object obj,boolean isSelected,boolean hasFocus,int row,int column){ imageicon i=(imageicon)obj; if(obj==i) setIcon(i.imageIcon); setBorder(UIManager.getBorder("TableHeader.cellBorder")); setHorizontalAlignment(JLabel.CENTER); return this; } } public class imageicon{

How to implement dynamic GUI in swing

人盡茶涼 提交于 2019-12-17 02:28:05
问题 First of all, apologies for posting something perhaps a bit excessively specific, but I'm not very experienced with Swing, and can't seem to find good examples that fit my needs. So I'm trying to figure out the best way to implement the a dynamic GUI for choosing filtering criteria in Swing: The underlying model is a class containing a list of criteria that can be negated (i.e. applied with a NOT-prefix), and a property indicating whether these should be combined with AND or OR. The GUI would

JDBC TableModel for a JTable in Java?

筅森魡賤 提交于 2019-12-13 12:14:05
问题 I want to display a database table as a JTable. I have never used JTable before so I googled JTable and TableModel. With that googling, I am able to write my own custom TableModel which show data stored in Object[][] data; Now, I want to show my database table data into JTable. I searched that also and have got an idea of that but still confused about what should goes where in the implementation class of AbstractTableModel. Following is the code of custom TableModel. public abstract class