defaulttablemodel

Data doesn't display in jTable

无人久伴 提交于 2021-01-29 05:18:59
问题 I want to populate jTable from database I used a code that a member on stackoverflow proposed for me here is the code UsersTableModel.java: import com.home.user.db.vo.UsersVo; import java.sql.Date; import java.util.ArrayList; import java.util.List; import javax.swing.table.AbstractTableModel; public class DefaultTableModel extends AbstractTableModel{ private String[] columnNames = { "FIRST NAME", "LAST NAME", "AGE" } private List<UsersVo> users; public DefaultTableModel() { users = new

Delete row from JTable

北慕城南 提交于 2021-01-28 14:50:44
问题 I need to remove row from JTable. Here is my code : import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.GridLayout; import javax.swing.JPanel; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame;

Refresh a jTable

北城余情 提交于 2020-01-22 02:15:11
问题 I can't seem to get my table to refresh. I created a refresh button that calls jTable1.repaint(); private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) // Reader Refresh jTable1.repaint(); } I also tried just recalling the RegistryValues again in the button like RegistryValues.arp(null); private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) // Reader Refresh RegistryValues.arp(null); } Also tried combining the registryvalues and repaint in the button. Below is

Default Table Model in JavaFX

回眸只為那壹抹淺笑 提交于 2020-01-15 09:10:00
问题 I have encountered some problem when trying to select single row from table view in JavaFX. Here is how I populate my table with data from database: public void populateCategoryTable() { data = FXCollections.observableArrayList(); try { db.getConnection(); String sql = "SELECT * FROM sm_category"; ResultSet rs = null; // Call readRequest to get the result rs = db.readRequest(sql); while (rs.next()) { ObservableList<String> row = FXCollections.observableArrayList(); //All the rows are added

Default Table Model in JavaFX

情到浓时终转凉″ 提交于 2020-01-15 09:09:10
问题 I have encountered some problem when trying to select single row from table view in JavaFX. Here is how I populate my table with data from database: public void populateCategoryTable() { data = FXCollections.observableArrayList(); try { db.getConnection(); String sql = "SELECT * FROM sm_category"; ResultSet rs = null; // Call readRequest to get the result rs = db.readRequest(sql); while (rs.next()) { ObservableList<String> row = FXCollections.observableArrayList(); //All the rows are added

Java, string instead of double after editing cell in TableModel

寵の児 提交于 2020-01-04 02:34:46
问题 I import a CSV file into a DefaultTableModel , one column is formatted as double, so far so good. But if I edit a cell from this column (double) in the JTable , after that this cell is no longer a double. Now it is a string. How can I change the type of the edited cell in the TableModel ? I know that I can parse a string to double with double value = Double.parseDouble(str); , but how can I ensure that this happens after editing a cell? Do I need a new TableModel -class like: class

Java, string instead of double after editing cell in TableModel

狂风中的少年 提交于 2020-01-04 02:34:05
问题 I import a CSV file into a DefaultTableModel , one column is formatted as double, so far so good. But if I edit a cell from this column (double) in the JTable , after that this cell is no longer a double. Now it is a string. How can I change the type of the edited cell in the TableModel ? I know that I can parse a string to double with double value = Double.parseDouble(str); , but how can I ensure that this happens after editing a cell? Do I need a new TableModel -class like: class

How do I add a JCheckBox to DefaultTableModel by adding a Boolean column?

二次信任 提交于 2020-01-02 20:17:14
问题 I am trying to add a jcheckbox to the first column of a JTable, which uses a DefaultTableModel . I tried returning a Boolean.class for that column, but it doesn't work. I already have a jcombobox in the last column, but using the same method I used to add that in order to add a jcheckbox doesn't work. I read online that java automatically returns a checkbox for you if you render a Boolean.class in a column, but using it also doesn't work. I think this might be a problem in the way I am

Copying DefaultTableModel data to clipboard

做~自己de王妃 提交于 2019-12-28 04:35:12
问题 I have the next JTable private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {"Hat", "New York", "1000"}, {"T-Shirt", "New York", "3500"}, {"Sweater", "Washington", "2800"}, {"Bag",

Unable to set a DefaultTableModel to a JTable contained in a JDialog

徘徊边缘 提交于 2019-12-25 19:37:24
问题 I have created a JDialog that contains a JTable, when I try to assign a DefaultTableModel to it, it gives me an exception and the JDialog does not even appear. java.lang.ArrayIndexOutOfBoundsException: 11 . Code to assign the table model: jTable1.setModel(new BomModel(GetBomForSetupMaterial.getPartPositionList())); My AbstractTableModel class: public class BomModel extends AbstractTableModel { private static List<JPartPosition> partPositionList = new ArrayList<JPartPosition>(); private String