Home Answers Viewqa Java-Beginners add image in a row of table

 
 


sunnychadha
add image in a row of table
1 Answer(s)      6 months and 7 days ago
Posted in : Java Beginners

i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have a label in which instead of passing text i have inserted image using jLabel.setIcon(new ImageIcon("E:/2.jpg"));.But when i pass this jlabel in the row it shows its properties instead of showing the image...please some one help me on this...my project is on dead line...please

View Answers

November 20, 2012 at 12:48 PM


Here is a code that displays images in jtable cell.

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

public class DisplayImageInTableCell extends JFrame
{
    public DisplayImageInTableCell()
    {
        ImageIcon icon1 = new ImageIcon("c:/cut.png");
        ImageIcon icon2 = new ImageIcon("c:/copy.png");
        ImageIcon icon3 = new ImageIcon("c:/paste.jpg");

        String[] columnNames = {"Picture", "Description"};
        Object[][] data =
        {
            {icon1, "Icon of Cut"},
            {icon2, "Icon of Copy"},
            {icon3, "Icon of Paste"},
        };

        DefaultTableModel model = new DefaultTableModel(data, columnNames);
        JTable table = new JTable( model )
        {

            public Class getColumnClass(int column)
            {
                return getValueAt(0, column).getClass();
            }
        };
        table.setPreferredScrollableViewportSize(table.getPreferredSize());

        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );
    }

    public static void main(String[] args)
    {
        DisplayImageInTableCell frame = new DisplayImageInTableCell();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setSize(300,200);
        frame.setVisible(true);
    }

}









Related Pages:
add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have a label in which instead of passing text i have inserted image using
add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have a label in which instead of passing text i have inserted image using
JavaScript add row dynamically to table
JavaScript add row dynamically to table  ... to add row to a table dynamically then we can also do this with the JavaScript code. In this example we will describe you how to add row dynamically to the table
JavaScript add row to table
JavaScript add row to table       This section illustrates you how to add a new row to the existing... will get the table containing the columns Name and Address and a button 'Add row
How to add dropdown list in a row of a sort table applet?
How to add dropdown list in a row of a sort table applet?  How to add dropdown list in a row of a sort table applet
Adding button to each row for the table and adding row to another table
Adding button to each row for the table and adding row to another table  Hi I need to add button to each line in the table(Table data is retrived... row of the table
Delete and add row from Table View iPhone
Delete and add row from Table View iPhone In this tutorial will learn how to delete and also how to add row into the table view iPhone, with the help of edit... on Navigation bar. Will add this to insert object into the Table View and setting
ADD ROW - JSP-Servlet
ADD ROW  Hi Sir, How to use add row and delete row concept in jsp .  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/add-element.shtml Thanks
How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java...()) { Vector row = new Vector(columns); for (int i = 1; i <= columns; i++){ row.addElement( rs.getObject(i) ); } data.addElement( row ); } rs.close(); stmt.close
add row in grid using dojo
add row in grid using dojo  add row in grid using dojo
Delete a Specific Row from a Database Table
Delete a Specific Row from a Database Table   ... the facility for deleting specific row in a database table. Sometimes, you want... the connection we are going to delete a specific row from the table. If the row
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
Hoe to refresh a table row dynamically
Hoe to refresh a table row dynamically  Want to refresh a table data... Friend, Is there a link attribute with every row of a table through which we will able to refresh a particular table row? Please clarify this. Thanks
Mysql Last Row
; Mysql Last Row is used to return the last records from table. Understand... to add the records or rows to the table employee1. mysql>...) Query to view last row of Table named employee1: The Query sorts
Table maximum Row count - JDBC
Table maximum Row count  Dear friends I want to select maximum time entry Status from db. for example : Status : 3 4 6 8 3 5 7 5 5 7 5 3 4 5 2 5 1 my output will be 5 means 5 is maximum time
Highlight a corresponding table row - Struts
Highlight a corresponding table row  I have 2 jsps... the table being displayed with rows having links in them(paged display of the table due to huge data) 2.wen klik on the link it leads to Return.jsp 3.now wen
Deleting a Row from SQL Table Using EJB
Deleting a Row from SQL Table Using EJB   ... to delete a row from the SQL Table. Find out the steps given below that describes how to delete a particular row from the database table using EJB. The steps
image
image  how to add the image in servlet code
What?s the maximum size of a row in SQL table?
What?s the maximum size of a row in SQL table?  What?s the maximum size of a row in SQL table?   Hi, The maximum Row Size is 8060 Bytes in a sql table. Thanks
Mysql Alter Add Multiple Columns
;    Mysql Alter Add Multiple Columns is used to modify the table and add multiple columns to the specified table. Understand with Example... into that add the records or rows to the table . mysql>insert
Add values of drop down menu( select option) to mysql table
Add values of drop down menu( select option) to mysql table   Here is my code <?php echo $row['valveName'].'<td>'.$row['valveId'].'<td>'; echo '<select name="onoff">'; echo '<
Deleting row and column from a table
Deleting row and column from a table  In this program ,we delete row and column of a table. First we create connection to a database using connection interface and java driver. After it we can delete row using "delete
JavaScript generate dynamic row
JavaScript generate dynamic row In this section, you will learn how to generate dynamic row using JavaScript. Here a row contain 3 fields(2 textfields,1 text area). Every time if the user click add button, a new row will get added
Mysql Alter Add Column
; Mysql Alter Add Column is used to define the existing Table and add...;); Query to insert data into Table named employees: The insert into add..., 1 row affected (0.02 sec) Query to view data of  Table named
Mysql add primary key
table employees is created .The insert into keyword add the records... in set (0.00 sec) Query to add primary key into the Table named employees: The Query Alter is used to redefine the table 'employees' and add
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  There is a table containing 20 fields and 2 of those are empty. The administrator... into the table. For this all the rows displayed and two rows with empty text boxes, he
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  There is a table containing 20 fields and 2 of those are empty. The administrator... into the table. For this all the rows displayed and two rows with empty text boxes, he
mysql alter table add column
mysql alter table add column  Hi, What is the syntax of mysql alter table add column? Thanks   Hi, Here is mysql alter table add column example: ALTER TABLE employee ADD address VARCHAR(50); Read more at MySQL Add
delete row
into the html table. Along each table row there is a checkbox consists of id of table. When the user selects the particular checkbox, that row will get deleted...delete row  how to delete row using checkbox and button in php
Dynamic row genertion in javascript? - JSP-Servlet
Dynamic row genertion in javascript?  Hi roseindia, I want coding in javascript to add a dynamic row in jsp..This row contain 3 fields(2 textfields,1 textarea).Every time if i click add button have to add dynamically
image on div or cell of table
image on div or cell of table  I am using ms access database and I have stored the image in access database and I have a code to display image but it display on browser but I want to display on inside the div tag or table tag pls
image on div or cell of table
image on div or cell of table  I am using ms access database and I have stored the image in access database and I have a code to display image but it display on browser but I want to display on inside the div tag or table tag pls
image on div or cell of table
image on div or cell of table  I am using ms access database and I have stored the image in access database and I have a code to display image but it display on browser but I want to display on inside the div tag or table tag pls
image on div or cell of table
image on div or cell of table  I am using ms access database and I have stored the image in access database and I have a code to display image but it display on browser but I want to display on inside the div tag or table tag pls
image on div or cell of table
image on div or cell of table  I am using ms access database and I have stored the image in access database and I have a code to display image but it display on browser but I want to display on inside the div tag or table tag pls
image on div or cell of table
image on div or cell of table  I am using ms access database and I have stored the image in access database and I have a code to display image but it display on browser but I want to display on inside the div tag or table tag pls
Jmagick how to add image on an existing image
Jmagick how to add image on an existing image  hi, I am using Jmagick library in my swing application I want to add an image (say logo... can use the following code to add image on an existing image You can give one
Table's row elimination based on option choosen
Table's row elimination based on option choosen  I have a drop down with yes and no option.if i select yes in a table 2 new rows are shown and if i select no another question in row appears but the space occupied by the question
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery(hql); //error when executing above code CONTACT is not mapped
iphone Table View
how to add object to table view, will add or insert the object into the Table... data item. Users can select a row in a table and, as a result, be presented... table view. Will add two ViewController to the Project and the Project is Based
table?
table?  Hi, how could i make a table in javascript, which would look like this: AA CODON Number /1000 Fraction .. (this row... can't figure out, how to construct a table,with two fixed columns, one that reads
how update JTable after adding a row into database
how update JTable after adding a row into database  J have two classes, listed below, one is table model, and second show data from database in JTable, and it's OK, but after adding a row into database table does't update. How
Remove JTable row that read txt file records
Remove JTable row that read txt file records  Hi every one. i have a jtable that correctly read data frome file and show them in own. I want to add a "Delete" button that when select a row and clicked button, row must deleted
HTML Table in javascript
HTML Table in javascript  hi all, how to add last row with sum in table using javascript
How to add a column in a table
How to add a column in a table   ... gets changed and you have asked to modify the structure of the table... should know how you can modify the structure of the table. The problem is that we
Dynamically added Row is Invisible in another javascript function..?
Dynamically added Row is Invisible in another javascript function..?  I have table as below, I need to create 5 default rows, ( this is fine with below code)..but when add row its creating row in a table, but the created row
JDBC Delete Row In Table Example
JDBC Delete Row In Table Example : In this tutorial we will learn how delete specific row from the table use mysql JDBC driver.This tutorial defined how one or more specific  row delete from table that follow any given condition
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary large object in the database table's row. Blob object contains a logical

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.