jtable

how to let JTable listens to user's selection and updates a cell value

旧巷老猫 提交于 2020-01-06 01:30:13
问题 I am new to JAVA and I am trying to make a JTable. What I want is that whenever a user make a selection from the comboBox in the Jtable, the Jtable will put the current date in the cell next to the comboBox. I wrote a code, but the code cannot upate the cell value. Here is my code(I just want the Jtable to insert "a" at row 1 column 4 for right now). public class GChamber extends JPanel { private boolean DEBUG = true; ListSelectionModel listSelectionModel; public GChamber() { ... JTable

JTable / TableModel MVC Implementation [Help]

Deadly 提交于 2020-01-05 23:31:31
问题 I'm trying to implement the MVC on a test example. How can i update the table when there is a change Class: Model class valueUpdater extends Thread { private String sValue; public valueUpdater() { this.start(); } public String getValue() { return this.sValue; } public void run() { try { for (int i = 0; i <= 100; i++) { this.sValue = String.valueOf(i); try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (Exception e)

rows not deleted from JTable

▼魔方 西西 提交于 2020-01-05 18:24:32
问题 In my JTable, all my checkboxes are in column 3. after I onclick a button, it will remove those rows that are checked. But however after implementing the functions in my onclick. It does not remove the the rows. The method for the button listener class DeleteBtnListener implements ActionListener { @Override public void actionPerformed(ActionEvent arg0) { for(int row = 0; row < table.getRowCount(); ++row) { if((Boolean) table.getValueAt(row, 3) == true) { myTableModel.removeRow(row); table

Continue code execution after new JFrame is created and then closed

家住魔仙堡 提交于 2020-01-05 09:05:27
问题 So this is probably a silly question but I just cant figure it out. Basically I have my MainWindow, when I press a button a new window should appear named PartSelectionWindow that contains a JTable (the JTable is filled out with a custom table model). Then I select a row and press ok to go back to the MainWindow and work with the info selected. Here's the problem: If I use a JFrame for the PartSelectionWindow, after the window is closed the code execution does not continue in the MainWindow

Java - table - change table format

◇◆丶佛笑我妖孽 提交于 2020-01-05 07:36:11
问题 how can I change table format in java? Now, I have left table, but I want my table looks like right table. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.TableCellRenderer; public class Farby extends JTable { public Farby(String[][] data, String[] fields) { super(data, fields); } @Override public Component prepareRenderer(TableCellRenderer renderer,

Java - table - change table format

纵饮孤独 提交于 2020-01-05 07:35:09
问题 how can I change table format in java? Now, I have left table, but I want my table looks like right table. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.TableCellRenderer; public class Farby extends JTable { public Farby(String[][] data, String[] fields) { super(data, fields); } @Override public Component prepareRenderer(TableCellRenderer renderer,

java : when is this method called : getTableCellRendererComponent?

空扰寡人 提交于 2020-01-04 17:39:38
问题 In order to set the color for a specific table cell, I should create a custom TableCellRenderer which has the following method : getTableCellRendererComponent . when is this method called : getTableCellRendererComponent ? just when a JTable is drawn for the first time ? In case I have a set of buttons and a jtable on a jframe, and each button when pressed will cause a certain number of cells in the table to be colored, how can I cause this method "getTableCellRendererComponent" to be called

java : when is this method called : getTableCellRendererComponent?

荒凉一梦 提交于 2020-01-04 17:39:09
问题 In order to set the color for a specific table cell, I should create a custom TableCellRenderer which has the following method : getTableCellRendererComponent . when is this method called : getTableCellRendererComponent ? just when a JTable is drawn for the first time ? In case I have a set of buttons and a jtable on a jframe, and each button when pressed will cause a certain number of cells in the table to be colored, how can I cause this method "getTableCellRendererComponent" to be called

Add cellpadding to a Java JTable

╄→尐↘猪︶ㄣ 提交于 2020-01-04 07:46:09
问题 I'm trying to implement a Swing JTable. I followed the tuorial on http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#simple I want the table cell's not to be editable (this works) and I want the table cells to have more padding to it's borders. Like cellpadding in HTML. This is part of my code and the cellpadding thing doesn't work. class BoardTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; public Component

Moving rows in JTable

烈酒焚心 提交于 2020-01-04 06:51:55
问题 I work with the MVC pattern and I've a JTable like this : List<Enregistrement> desEnregistrements = dao.lireTousLesEnregistrements(1); ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Date Enregistrement"); ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Libellé"); ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Motif"); ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn("Date facture"); ((VueAfficherCompteCIO)vue).getModeleJTableCIO().addColumn(