Hi I need to show an image thumbnail in one of jTable cells But I don't know how to do it! I'm using netbeans to design GUI . How can I do that? Thanks

Member Avatar
Member Avatar
+0 forum 11

Hi Guys, I ussually dont post anything here often, just get everything off of everyone elses questions, but I'm having a strange problem that im scratching my head over, I have a JTable where I can Add and remove rows... This is just for testing purposes, I'm about to make a ingrediants program. The thing is whenever I change one of the Comboboxes they all seem to change.. its really wierd, Could Someone run this and help me out, this is probably a stupid mistake? See my Code Below, My Main package doughtracker; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * * …

Member Avatar
Member Avatar
+0 forum 13

I have a JTable that a user can input data. I have an image that I would want to put at the top of my page when printed and also another image that I would want to work as footer. How do I print these on the same page including data from for a jtable(my images to works as logo and footer are not part of the table; i would take them from my directories)...I mean make it as shown in the image below. I would appreciate any links and ideas.

Member Avatar
Member Avatar
+0 forum 5

Howdy-ho. I am trying to right click on my table and change the cell border color and highlight color of that cell. I have figure out how to give that particular cell focus when I right click it by using int row = fixed.rowAtPoint(evt.getPoint()); int col = fixed.columnAtPoint(evt.getPoint()); fixed.changeSelection(row, col, false, false); fixed.requestFocus(); However when I want to visual distinguish a right click from any other click. Usually a cell with focus looks like this: with the blue thick border around the selected cell, as well as the blue background around everything in that row ![e6ef5c487a6756ad3c6856868a02f596](/attachments/small/3/e6ef5c487a6756ad3c6856868a02f596.png "align-left") How do I …

Member Avatar
Member Avatar
+0 forum 1

It is relaed to the thread i posted a while ago. Before I edited the model of my table, it was working properly, but when i added some columns thats when the problem came out. Everytime i click the button that will open this window, it goes blank. Only a big window filled with white comes out. here is my code: tblInventory.setModel(new TableDefault( new Object[][] { }, new String[] { "Borrow", "ItemID", "Item Description", "Quantity", "In-Stock", "Out-Stock", "Last Borrowed", "Remarks" }, new Class[]{String.class, Boolean.class} )); System.out.println("lllllllll"); scrollPane.setViewportView(tblInventory); JButton btnOk = new JButton("Ok"); btnOk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { …

Member Avatar
Member Avatar
+0 forum 6

Hello good day. Here is my problem: I have retrieved some a couple sets of data from my sql database and saved them in ArrayLists of (custom)types <Student> and <Subject>. I am using a single Table. I want to create a custom AbstractDataModel that displays the data from the ArrayList<Student>. The data that comes from ArrayList<Student> are simply Strings, and this constitutes half of the table. The other half of the table is populated by the user editing the cells via JComboBox editor. These choices are used to carry out calculations in order to populate the ArrayList<Subject>. Problem is, all …

Member Avatar
Member Avatar
+0 forum 6

I've got a JTable called chances_T full of doubles ranging from 0 to 100. I'm trying to set the background color of each cell based on the cell's value. So I built a custom cell renderer: class CustomRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); double chance = Double.parseDouble(String.valueOf(value)); if (chance > 80) { c.setBackground(Color.green); console_TA.append("Worked!\n"); } else if (chance >= 50 && chance < 80) { c.setBackground(Color.yellow); } else if (chance >= 25 && chance < 50) { …

Member Avatar
Member Avatar
+0 forum 8

Hi All, I have a questing regarding JTable. If i have two rows in JTable. if user selects a column in a particular row, I need to have the value of that particular column and also the values of rest of the columns in that row. Please advise how to achieve that ...

Member Avatar
Member Avatar
+0 forum 1

Hi All, I am having a JTable which runs so strange. Jtable is very basic having three rows and three columns. If I use SetValue method to place data in any cell and run the program JTable is not visible. If i delete the SetValue Method from the program and run it, it diplays the JTable correctly. public class TableTest { static JTable table ; public TableTest() { // TODO Auto-generated constructor stub JFrame jFrm = new JFrame("simple table"); jFrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrm.setVisible(true); jFrm.setSize(500,300); jFrm.setLayout(new FlowLayout()); table = new JTable(3,3); table.setPreferredScrollableViewportSize(new Dimension(500,30)); table.setValueAt("Apple", 1, 3); \\if I delete this line, prog becomes …

Member Avatar
Member Avatar
+0 forum 1

Hi All, I have a Jtable with six columns. I am displaying the contents of my database into my Jtable. Its working fine. But I am facing trouble updating the changes done in Jtable cells to appropriate database cell. In the below code when I tried to edit the First Row ,third column in my Jtable, it does not get reflected in the First row, third column in my database, Indeed im getting an error "Column count doesn't match value count at row 1". Here is my code which I created the JTable using defaultTable Model. Thanks in Advance. public …

Member Avatar
Member Avatar
+0 forum 7

**I want to enter the value in jtable run time and want to dispaly its sum on same jtable when i pressed calculated button ** how to do please help :) import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.*; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.*; import javax.swing.event.TableModelEvent; import javax.swing.table.DefaultTableModel; public class TestTable { public static void main(String[] args) { TestTable testTable = new TestTable(); } public TestTable() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } JFrame frame = new JFrame("Testing"); …

Member Avatar
Member Avatar
+1 forum 18

Hi.. I want to seek help about database in SQL and Jtable in Netbeans. In our sales inventory system, we have these tables in database namely 'stockmasterlist' and 'pricemasterlist'. They are relational since they have in common with regards to their 'ProductNumber'. Now, since they are of different tables but relational, **I wanted to display both of their values in ONE JTABLE in Netbeans. So that, everytime the owner wants to see every detail of his product(Not only the name and description but as well the price, quantity, etc), he could just directly see it in one JTABLe.** Please, Please …

Member Avatar
Member Avatar
+0 forum 1

Hello good day. I am designing two JTables; one on top of the other. The first one has nine columns. And the second one has 8 columns (The first column spans the first columns of the topmost table). What I wish to do now is to make the bottom table reactive to the movement of the margins in the topmost table. I wish for them to stay aligned. How do I accomplish this please?

Member Avatar
Member Avatar
+0 forum 19

I am using Netbeans 7.1 and MySQL. I need 1 column in jtable which will contain jradiobutton and user can select any 1 row's jradiobutton Please refer the fig for detail. After selecting RB further processing will be done on jbutton click event. ![64496cca6997d07cf995950d67a3e3f0](/attachments/large/2/64496cca6997d07cf995950d67a3e3f0.JPG "64496cca6997d07cf995950d67a3e3f0") Here is the code - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { final Object[] columnNames=new String[] {"Date","Flight Name","Departure Time","BC Seats Available","XC Seats Available","EC Seats Available"}; DefaultTableModel dtm=new DefaultTableModel(columnNames,0); String origin=jComboBox3.getSelectedItem().toString(); String target=jComboBox4.getSelectedItem().toString(); String fclass=jComboBox1.getSelectedItem().toString(); String search = ""; Date dt; //Economy Class Processing try { smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rs = smt.executeQuery(sql); int i = 0; SimpleDateFormat sdf= new SimpleDateFormat("dd-MM-yyyy"); …

Member Avatar
Member Avatar
+0 forum 6

Hello Good day. Here is the problem I am trying to solve. I have a table as seen below. ![232465554203149acd8363d3a4a127ae](/attachments/large/3/232465554203149acd8363d3a4a127ae.jpg "232465554203149acd8363d3a4a127ae") My GOAL: Columns A through G are going to be filled with integers. (I have already created an integer model so that these cells only take integers). As the cells in that range are filled, the Totals column will decrease in number until it reaches zero. So far I have managed to use a TableModelListener to respond to the changing cell values. What I wish to do now is to prevent a cell, *that is being edited*, from *accepting* …

Member Avatar
Member Avatar
+0 forum 14

I have been tryin to get this to work for the past week if not two >:( with no joy. Worst of all its such a trivial problem. The program asks you to choose a town name from a combo box when you choose the location you shoud be brought to a brand new Jframe with a populated Jtable. Now everything does what its meant to do except the jframe window which opens as the border of the window and the minmise,maximise and close buttons. You can view the database by expanding the jframe window from the bottom right corner(Click …

Member Avatar
Member Avatar
+0 forum 7

Hey Guys, i was looking at the post linked below and been trying to solve the issue, however, i have been unable to solve it. [Click Here](http://www.daniweb.com/software-development/java/threads/384109/data-from-text-file-into-jtable) The post says i "MUST create a new Vector for each row" in order for it to work. as mentioned above, i have tried doing this but failed. Would really appreciate some help. The code i have is displayed below: package game; import java.awt.BorderLayout; import java.io.BufferedReader; import java.io.FileReader; import java.util.Vector; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; public class HighScores { public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> …

Member Avatar
Member Avatar
+0 forum 6

From Class Model: public TableModel getTableData() { TableModel model=null; try { String sql = "SELECT eventID as 'Event ID', date as 'Date',eventName as 'Name', time as 'Start Time' FROM Event"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); model = (DbUtils.resultSetToTableModel(rs)); } catch(SQLException e){ e.printStackTrace(); } finally { try {rs.close(); pst.close(); } catch(SQLException e){} } return model; } public void getEvent(String tableClick) { Events e = new Events(); try { pst = conn.prepareStatement("SELECT * FROM Event WHERE eventID='"+tableClick+"' "); rs = pst.executeQuery(); while(rs.next()){ e.setEventName(rs.getString(2)); e.setEventDate(rs.getDate(3)); e.setEventTime(rs.getString(4)); e.setEventVenue(rs.getString(5)); e.setEventDetail(rs.getString(6)); e.setEventOpportunity(rs.getString(7)); e.setEventMoreDetails(rs.getString(8)); e.setEndTime(rs.getString(9)); } } catch(SQLException ex){ ex.printStackTrace(); } finally { try { rs.close();pst.close();conn.close();} …

Member Avatar
Member Avatar
+0 forum 1

I am finding it difficult to update the `JTable` when I enter a person's name in search button. The program compiles correctly without any errors, but in `SearchActionPerformed` event when the search button is pressed an empty table comes up. Where without search, the table is full of values from database. In the search criteria, I have typed a surname exactly as one from database but no returns. public class MainMenu extends javax.swing.JFrame { Academic ac = new Academic(); Connection conn = JavaConnect.ConnectDB(); PreparedStatement pst = null; String sql; ResultSet rs = null; ImageIcon format = null; public byte[] imagedata …

Member Avatar
Member Avatar
+0 forum 1

How to select data from different tables in a single database and show in a single jtable.. Pls I need help

Member Avatar
Member Avatar
+0 forum 1

Hello perhaps you could help me with a problem please. I wish to display a table of results using a JTable. Customarily I use a 2D Object array which is initialized with the data in a manner as follows: public Object[][] data={ {"Biology",25},{"Additional Math", 54},{"Geography",43},{"History",21},{"Spanish", 47}, {"Information Tech.",110},{"Technical Drawing",54},{"French",45},{"Physics",76},{"Chemistry",76}, {"Principles of Accounts",34},{"Principles of Business",30} }; However this time, initialising won't work because the data that I am receiving will be subject to change, thus the 2D array needs to be created at a later point. The added data that I will be receiving, will come from two(2) arrays, one containing …

Member Avatar
Member Avatar
+0 forum 2

Hi, I have 1 jframe containing 1 panel. This panel shows data using JTable. I want to put button at the bottom of the panel to print that data in PDF. Can I reduce the size of the JTable? Currently it takes the size as that of the panel. Thanks

Member Avatar
Member Avatar
+0 forum 3

how to instantly update jtable after addition/deletion of any record.And how to add checkBox in every rows of jtable in java .i will be grateful for any help...plzzzzzz rply thanx in adwc...

Member Avatar
Member Avatar
+0 forum 1

Hi! I have a huge problem with my PERT program. I've been trying to figure out how to display all of the data in jTable with one click and how to delete all them as well, like if I click on "reset" or "clear". What I've done is just the design of the table with 5 textfields. Can anyone help me?

Member Avatar
Member Avatar
+0 forum 2

Need help with JTable header group : Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.table.JTableHeader cannot be cast to id.co.aal.common.GroupableTableHeader this is the part of table drawing ..... if(tabledraw) { tabledraw=false; for (int k = 0; k < m_data.getColumnCount(); k++) { TableCellRenderer renderer; if (k==Kehadirantable.COL_ALOKASI) renderer = new CheckCellRenderer(); else { DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer(); renderer = textRenderer; } TableCellEditor editor; final TableCellEditor comm = null; JComboBox cmb=new JComboBox(CATEGORIES); if (k==Kehadirantable.COL_KODE) { editor = new DefaultCellEditor(cmb); } else if (k==Kehadirantable.COL_ALOKASI) editor = new DefaultCellEditor(new JCheckBox()); else editor = new DefaultCellEditor(new JTextField()); TableColumn column = new TableColumn(k,m_data.m_columns[k].m_width,renderer, editor); tblKehadiran.addColumn(column); tblKehadiran.getColumnModel().getColumn(k).setResizable(false); } TableColumnModel …

Member Avatar
Member Avatar
+0 forum 1

HOw can i assign a default action of Enter key after cell of jtable is edited to a Button???

Member Avatar
Member Avatar
-1 forum 2

I am trying to update database by editing cell values in jtable. my table looks like ![a](/attachments/large/2/a.JPG "a") When i edit the value in particular cell and without clicking anywhere if i click on Update button the database is not updated as like this ! ![b1](/attachments/large/2/b1.JPG "b1") but if i click somewhere in the updating row, which again turns the look of table as fig. 1 then the database is upodated with particular value, why is this happening please help. My code for refresh Button goes like this: int pos = recordTable.getSelectedRow(); int id = (Integer) recordTable.getModel().getValueAt(pos, 0); ListSelectionModel selectionModel …

Member Avatar
Member Avatar
+0 forum 5

there are two panel in one panel there is search button and in the another one there is Jtable for displaying search result. In that jtable initially all the records are displayed. But when i try to search, it works but the problem is that i need to click search button two times for searching 1st time and from second time onwards it works normally means even with single click results are displayed properly. what mistake am i making ? please suggest.

Member Avatar
Member Avatar
+0 forum 5

I want to update the contents of Jtable as shown below when the Jcombobox's item state is chaged in the left panel. but i am not being successful in it .Please help. ![untitled29](/attachments/large/2/untitled29.JPG "untitled29") when the table no value is changed in the left panel , i want corresponding Jtable values updated/refreshed as per the table number. how can i do this. please help.

Member Avatar
Member Avatar
+0 forum 8

Hello, I need to create a JDBC that connects to a mySQL database, retrieves the data from a table and displays it into a JTable. I have done this successfully, but have ran into a problem. The initial values I entered into the database (for testing) are permament. If I change the database values, save, close mySQL and re-execute the code it still displays the first set of values. I reloaded mySQL to make sure it wasn't a problem with the database, but sure enough it shows the newly entered values. Could someone please take a look at my code …

Member Avatar
Member Avatar
+0 forum 14

The End.