jtable

I get the Jtable but no data [duplicate]

狂风中的少年 提交于 2020-01-07 02:36:12
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: I can’t get my JTable to show anything I can show my Table but I can't get any data in the table, just the column name. My code looks like this. public static DefaultTableModel buildTableModel(ResultSet rs) throws SQLException { java.sql.ResultSetMetaData metaData = rs.getMetaData(); // names of columns Vector<String> columnNames = new Vector<String>(); int columnCount = metaData.getColumnCount(); for (int

Insert,Update,Delete rows of jtable having mysql data

拜拜、爱过 提交于 2020-01-07 00:36:17
问题 This class shows a list of employees that is a table in mysql, it works, the point is that I want to do an insert or update or delete dynamically in this way: The JTable has the function to select the cell in a specific row, just by clicking on it with the mouse cursor, i would like to take advantage of this fact to remove the value and insert another in the case of update, or remove the entire row if the delete, or insert a new row, all these operations once made ​​will be saved in the

Insert,Update,Delete rows of jtable having mysql data

允我心安 提交于 2020-01-07 00:35:09
问题 This class shows a list of employees that is a table in mysql, it works, the point is that I want to do an insert or update or delete dynamically in this way: The JTable has the function to select the cell in a specific row, just by clicking on it with the mouse cursor, i would like to take advantage of this fact to remove the value and insert another in the case of update, or remove the entire row if the delete, or insert a new row, all these operations once made ​​will be saved in the

How can I get the correct JTable width?

这一生的挚爱 提交于 2020-01-06 21:24:03
问题 I want to get a table width. I try to do it with this code: private static class ListenerForOk implements ActionListener { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub handle(); if (!dataIsNotInput()) { createDataTab(); System.out.println(table.getWidth()); } } Method createDataTab() does all the work to add the JTable. So, after createDataTab(); my table lies on frame and I can see it. But this code table.getWidth() returns zero. Another way I try

How can I get the correct JTable width?

早过忘川 提交于 2020-01-06 21:22:22
问题 I want to get a table width. I try to do it with this code: private static class ListenerForOk implements ActionListener { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub handle(); if (!dataIsNotInput()) { createDataTab(); System.out.println(table.getWidth()); } } Method createDataTab() does all the work to add the JTable. So, after createDataTab(); my table lies on frame and I can see it. But this code table.getWidth() returns zero. Another way I try

Applying a MaskFormatter to a column in my JTable, but the mask is only used on the first cell I edit in the column

為{幸葍}努か 提交于 2020-01-06 18:25:31
问题 ////DOB column formats to dd/mm/yy TableColumn dobColumn = table.getColumnModel().getColumn(3); DateFormat df = new SimpleDateFormat("dd/mm/yy"); JFormattedTextField tf = new JFormattedTextField(df); tf.setColumns(8); try { MaskFormatter dobMask = new MaskFormatter("##/##/##"); dobMask.setPlaceholderCharacter('0'); dobMask.install(tf); } catch (ParseException ex) { Logger.getLogger(DisplayStudents.class.getName()).log(Level.SEVERE, null, ex); } dobColumn.setCellEditor(new DefaultCellEditor(tf

java pass data to JTable's row upon button click

不想你离开。 提交于 2020-01-06 15:17:15
问题 I'm doing a java app which has to pass an initialized array of string to display as a row to a JTable. This is what I tried: Object[] _row1; public PrintMeNow() { table = new JTable(); table.setBounds(16, 203, 362, 16); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setModel(new DefaultTableModel( new Object[][] { _row1, {2,2,2}, {3,3,3}, {4,4,4} }, new String[] { "QTY", "Item Code", "Amount" } )); }

JTable render stops rendering sometimes but resumes on window resize

好久不见. 提交于 2020-01-06 15:16:04
问题 I`ve got a mysterious problem with my custom JTable and a custom TableRenderer. In 95%-99,99% it works perfectly, but sometimes the renderer just stops doing his job, and leaves a portion of the table (which is inside a JScrollPane) blank. The problem case looks like that: In all other cases, and after a slight resize of the window, the Table look like that: Now both columns has a TextAreaCellRenderer associated to, which works as follows: public class TextAreaCellRenderer extends JTextArea

How to make a JTable fill entire available space?

三世轮回 提交于 2020-01-06 13:56:20
问题 I want to created a panel with a table, which fills the entire available space. I do this using following code: public class MyFrame extends JFrame { public EconomyFrame() throws HeadlessException { super("..."); final JTabbedPane tabbedPane = new JTabbedPane(); add(tabbedPane); final JPanel companiesPanel = new JPanel(); final CompaniesTableModel companiesModel = new CompaniesTableModel (ApplicationStateSingleton.INSTANCE.getPersistence().getCompanies()); final JTable companiesTable = new

How to make a JTable fill entire available space?

雨燕双飞 提交于 2020-01-06 13:55:13
问题 I want to created a panel with a table, which fills the entire available space. I do this using following code: public class MyFrame extends JFrame { public EconomyFrame() throws HeadlessException { super("..."); final JTabbedPane tabbedPane = new JTabbedPane(); add(tabbedPane); final JPanel companiesPanel = new JPanel(); final CompaniesTableModel companiesModel = new CompaniesTableModel (ApplicationStateSingleton.INSTANCE.getPersistence().getCompanies()); final JTable companiesTable = new