jtable

html issues with images in JTable

我们两清 提交于 2019-12-25 03:37:00
问题 I have extendeded AbstractTableModel to create a custom TableModel. The reason for doing this is to bind a hashmap to a JTable. Within my TableModel, on one of the rows I am returning html code like this: @Override public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: String sTest = "<div style=\"margin-left:100px;\"><img src='" + new ImageIcon(Wds.class.getResource("/resources/video.png"))+ "'</div>"; return "<html>" + sTest + sTest + "hello" + "</html>";

vertical scroll bar in JTable

此生再无相见时 提交于 2019-12-25 03:27:32
问题 I have one JTable with vertical scroll bar on it,when i added new row the scroll bar will move to the new row. The problem is scrollbar is visible in the frame but i can't scroll it. this is way i created jtable table = new javax.swing.JTable(){ public boolean isCellEditable(int rowIndex, int colIndex) { return false; //Disallow the editing of any cell } }; model = (DefaultTableModel) table.getModel(); table.setRowHeight(20); selectionModel = table.getSelectionModel(); selectionModel

Refresh jtable after Delete An item from database

前提是你 提交于 2019-12-25 02:13:18
问题 Delete an item from jtable auto refresh is not working... here is the code @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btnEdit) { } else if (e.getSource() == btnDelete) { String str = JOptionPane.showInputDialog(null, "Enter The Reason : ", "", 1); if (str != null) { Book updatebook = new Book(); updatebook.setName(book.getName()); updatebook.setAuthor(book.getAuthor()); updatebook.setPublisher(book.getPublisher()); updatebook.setDelete(true); ServiceFactory

Read text file and display it in Jtable?

拈花ヽ惹草 提交于 2019-12-25 01:58:49
问题 i need to read the contents of text file, line by line and display it on the Jtable , the table should be editable by users as needed, Any help Appreciated. I am new to Java. Thank You. My Text File: File Name(people.txt) COLUMN_NAME COLUMN_TYPE IS_NULLABLE COLUMN_KEY COLUMN_DEFAULT EXTRA Names VARCHAR(500) NO Address VARCHAR(500) NO My Code So Far: import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util

JTable returning null for Graphics?

≡放荡痞女 提交于 2019-12-25 01:33:22
问题 I'm trying to draw lines over my JTable using a Painter object that I've made, but for some reason table.getGraphics() returns null. Painter class: import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JTable; public class Painter extends JTable { public Painter(){ } public void paintSudokuLines(Graphics g){ paintComponent(g); } public void paintComponent(Graphics g){ super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setStroke(new

Showing a JTable in a JTree behaves differently with different look and feels

泪湿孤枕 提交于 2019-12-25 01:08:29
问题 I have a JTree where some of the data to be shown should be shown in a JTable. So to do this, I created a renderer class (extending DefaultTreeCellRenderder) to change the rendered component returned depending on what the object value contains when initially passed into the renderer. If it is a table to be shown, it is contained within a JScrollPane (as the below code shows). This works (in that the JScrollPane containing the JTable is shown in its entirety) with the Cross Platform Look and

I have to select the checkbox two times to check/uncheck in jTable

梦想与她 提交于 2019-12-24 22:12:27
问题 I have a jTable code i intend to use, but the problem with it is that when i click on the checkbox once it doesn't select/deselect it, instead i have to click twice. But if i select any other cell in the row except the one containing the checkbox the purpose is solved. HERE IS MY CODE : public class TableSelectionTest extends JFrame implements ListSelectionListener { private final int COLUMN_COUNT = 5; private TblModel model; public TableSelectionTest() { initialize();

Why does this JTable get cut in half when repainting?

随声附和 提交于 2019-12-24 20:24:29
问题 Please help me debug code. I am making a calendar using JTable, but whenever I press the next or previous buttons, the calendar doesn't repaint properly. It gets "cut in half" and then another press it disappears. I have tried different ways to handle this but I really have no clue. Here is the code: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel;

JScrollPane not appearing?

痞子三分冷 提交于 2019-12-24 19:27:54
问题 Why is my JScrollPane not showing up? if I do it with the table (commented part) it works fine, but when I put it into a scrollpane ( I need too, the data base is really long) it never appears, can anyone help me? :o) Here's the code: JButton btnRefresh = new JButton("Refresh"); btnRefresh.setBounds(130, 35, 80, 30); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try{ ResultSet r = s.executeQuery("Select * From "+comboBox.getSelectedItem());

JTable only displays last record from table

删除回忆录丶 提交于 2019-12-24 18:49:39
问题 I'm trying to display all the records from my database table into an JTable. The problem is when I run the code it will only display the last record from the table. Code: public uitgifteInfo() throws SQLException{ final JFrame frame = new JFrame("Uitgifte punten"); String[] columns = {"Nummer", "Adres", "Postcode", "Plaats", "capaciteit"}; String sql = "SELECT * FROM uitgiftepunt"; try ( Connection conn = connection.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt