jtable

JTable with titled rows and columns

≡放荡痞女 提交于 2019-12-27 10:49:50
问题 How can I have a JTable with both columns & rows have title? something like this: +------+------+------+------+ |/\/\/\| col1 | col2 | col3 | +------+------+------+------+ | row1 | | | | +------+------+------+------+ | row2 | | | | +------+------+------+------+ | row3 | | | | +------+------+------+------+ Thanks 回答1: I think that you searching RowTable import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.*; import javax.swing.UIManager.*; import javax.swing.event.*; import

JCombobox value retrieve from My Sql

℡╲_俬逩灬. 提交于 2019-12-26 12:39:44
问题 I use the following code for retrieve the data from mysql Student data Base.It was work properly.It will show the student Name in combo box.The value is retrieved from Db. My problem is the first value(first student Name which is stored in Database column) displayed in the Jcombobox name field Automatically and it was show when I click Combo Box arrow..It means when I execute this following code I see the first value(first Name) in combobox's name field nearby arrow .But I need "Student Name"

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

Java - Disable scientific notation in JTable cells

自古美人都是妖i 提交于 2019-12-25 17:00:33
问题 I have a JTable where a series of Float are displayed. For small values the cell displays the number in scientific notation. Is there a way to disable that? 回答1: You should read the following page to get an insight about why it is happening: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender Then you should pass your own NumberFormat instance (somehow) in to your JTable , and then all numbers will be formatted properly. I think it's a good read to read through the

setValueAt(Object aValue, int row, int col)

£可爱£侵袭症+ 提交于 2019-12-25 16:10:03
问题 I am trying to change a value in the Object[][] data in a defaultTableModel but I am getting a nullpointerexception at if (data[i][j] == userFolderName) I have tried changing the variable to "Kathy" just in case it wasn't reading the userName correctly but it still throws the exception. Can you please have a look at my code and see where I'm going wrong? public class Statistics extends JPanel { public Object[][] data; public DefaultTableModel model; public Statistics() { super(new GridLayout

setValueAt(Object aValue, int row, int col)

半城伤御伤魂 提交于 2019-12-25 16:08:10
问题 I am trying to change a value in the Object[][] data in a defaultTableModel but I am getting a nullpointerexception at if (data[i][j] == userFolderName) I have tried changing the variable to "Kathy" just in case it wasn't reading the userName correctly but it still throws the exception. Can you please have a look at my code and see where I'm going wrong? public class Statistics extends JPanel { public Object[][] data; public DefaultTableModel model; public Statistics() { super(new GridLayout

Extends AbstractTableModel and populate jTable dynamically

百般思念 提交于 2019-12-25 09:40:13
问题 Basically, I'm working on a Client Server Architecture so Objects can be modified externally by some Clients. I have a bank : public class Bank{ private List<BankingOperation> operationList = new ArrayList<BankingOperation>(); public void addOperation(BankingOperation op) { this.operationList.add(op); //... } And my Server : public class ServerBank extends JFrame { private Bank bank; private JTable table; private OperationTableModel model; public ServerBank() { this.bank = new Bank(); this

Extends AbstractTableModel and populate jTable dynamically

假如想象 提交于 2019-12-25 09:40:08
问题 Basically, I'm working on a Client Server Architecture so Objects can be modified externally by some Clients. I have a bank : public class Bank{ private List<BankingOperation> operationList = new ArrayList<BankingOperation>(); public void addOperation(BankingOperation op) { this.operationList.add(op); //... } And my Server : public class ServerBank extends JFrame { private Bank bank; private JTable table; private OperationTableModel model; public ServerBank() { this.bank = new Bank(); this

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

Display Last Modified Sql Table in jtable

谁说我不能喝 提交于 2019-12-25 08:17:12
问题 I'm making a program in java that makes queries into SQL and show the result in a jtable, my problem is if i do Insert, delete or update i want my jtable to show the sql table that was modified, is there any function for that? This is my method to execute the query: public void executequery() { try { String userQuery = Query.getText(); Statement statement; statement = conn.createStatement(); statement.execute(userQuery); ResultSet rs = statement.executeQuery(userQuery); //in case of a instert