defaulttablemodel

Adding an image to JTable Cell [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-14 03:35:33
问题 This question already has answers here : Dynamically add images to JTable cells (2 answers) Closed 6 years ago . I am wanting to dynamically add data to a JTable including an image. Here is my code: Main class String image = matchedSlots.get(i).getImagePath(); String title = matchedSlots.get(i).getTitle(); String director = matchedSlots.get(i).getDirector(); int rating = matchedSlots.get(i).getRating(); int runTime = matchedSlots.get(i).getRunningTime(); searchResults.getColumnModel()

creating the same jtable in 2 different JtabbedPanes

拈花ヽ惹草 提交于 2019-12-13 18:57:00
问题 I want to create 2 JTabbedPanes that will have the same JTable but different values in one of the columns. Right now for some reason only one of the tabs is showing up and I am not sure why. Also am I doing this the best way by creating 2 different DefaultTableModel 's? public static void tableMaker(DefaultTableModel m, DefaultTableModel m1, final Map<String, NumberHolder> uaCount) { final JFrame frame = new JFrame("Strings"); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel();

How to add multiple items to the DefaultComboBoxModel

て烟熏妆下的殇ゞ 提交于 2019-12-13 03:07:21
问题 I have the following code but I don't know how to add all of the items to my combobox. DefaultTableModel rs = MyDB.DataTable("SELECT `Activity` FROM `transactions` WHERE `Group` = '" + Gname.getText()+ "' OR `Group` = 'ALL'"); DefaultComboBoxModel dmc = new DefaultComboBoxModel(); dmc.addElement(""); if (rs.getRowCount() > 0) { dmc.addElement(rs.getValueAt(0,0).toString()); } cboItem.setModel(dmc); It only adds one item to my DefaultTableModel , how can I add all of them? 回答1: The constructor

Where should definition my optional DefaultTableModel methods?

自闭症网瘾萝莉.ら 提交于 2019-12-11 19:33:58
问题 I use this 3 class for show data from database into JTable . public class TableContent { private final Vector<String> headers; private final Vector<Vector<String>> content; public TableContent(final Vector<String> headers, final Vector<Vector<String>> content) { this.headers = headers; this.content = content; } public Vector<String> headers() { return headers; } public Vector<Vector<String>> content() { return content; } And: public class TableData { public TableContent getData() { Vector

ImageIcon for DefaultTableModel

空扰寡人 提交于 2019-12-11 13:59:33
问题 I'm making a program for school which you can log the systems clipboard history, my teacher said it's good so far, but I need to add images. So I got a few images to represent an image, url, text, or a folder. But when I try to .addRow with the image, it shows the source of the image and not the actual image. Here's my class public class Main extends JFrame implements ClipboardOwner { private static final long serialVersionUID = -7215911935339264676L; public final Clipboard clipboard =

Refresh JTable after adding to ArrayList

旧巷老猫 提交于 2019-12-11 12:27:41
问题 I have a JTable that's filled with the inventory data of a garage. It has parts, number in storage etc. At this moment i have a JOptionPane where you can enter the data if you want to add a new part to the inventory. that works fine but how do i refresh the JTable data after the part is added? This is the code I use to fille the table initially : private String[] kolommenOnderdelen = { "Nr", "Omschrijving", "Vooraad" }; private DefaultTableModel modelOnderdelen = new DefaultTableModel

getValueAt() method returns null

巧了我就是萌 提交于 2019-12-11 11:29:42
问题 I am trying to save all the values of a defaulttablemodel to my sql database but whenever I put try to print the value on the last inserted row via table.valueAt(), it returns null. try{ System.out.print(table.getValueAt(5,0)); //<- this returns null even if the table.getRowCount() is 6 for(int i=0; i<table.getRowCount();i++){ if((Boolean)table.getValueAt(i,1)) val=1; else val=0; //System.out.print(table.getValueAt(i, 0) +","+ val); String sql1 = "INSERT INTO HREmpListofCard (EmpID, CardNbr,

ArrayIndexOutOfBoundsException when trying to empty a JTable

泄露秘密 提交于 2019-12-11 09:43:13
问题 I have created the following JTable and some buttons. One of the buttons (jbtClear) is trying to empty the table using the setRowCount() function. Any ideas , why it is not working and produces this error? Here is the code : /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package nysemarketpick; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileInputStream; import java.io.FileOutputStream; import java

Need to keep some columns editable and non-editable and allow cell editing on only double click on the cell

北城以北 提交于 2019-12-11 09:36:01
问题 In my implementation of JTable . I have to keep some columns editable and some columns UN-editable so I have override isCellEditable - @Override public boolean isCellEditable(int row, int col) { if (col == uneditableColumn) { return false; } return bEdit; } Now my requirement is to allow edit the cell only on Double click i.e. if user double clicks on cell then only it comes into editable mode. For this - I will have to make your own CellEditor and override. public boolean isCellEditable(

Error adding Row into JTable

和自甴很熟 提交于 2019-12-11 05:56:29
问题 I have a JButton which, once it is pressed, adds a row into a JTable . I have tried to make this by implementing the following code. columNames = new Vector<>(); columNames.addElement("Name"); columNames.addElement("CC"); columNames.addElement("Age"); columNames.addElement("PhoneNumber"); columNames.addElement("Date"); columNames.addElement("Amount$"); Object[] dataList = {"name", "cc", "age", "phone", "date", "amount"}; data = new DefaultTableModel(columNames, 0); data.addRow(dataList);