JTABLE SCROLL PANE
The scrollpane for a image in Jtable is only showing but not working ....here is the code i am doing please suggest something...
import java.awt.Component;
import java.io.FileReader;
import java.util.StringTokenizer;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
public class TableImage extends javax.swing.JFrame {
/**
* Creates new form TableImage
*/
public TableImage() {
initComponents();
}
private void initComponents() {
jFileChooser1 = new javax.swing.JFileChooser();
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("BROWSE");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextField1.setText("jTextField1");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null},
{null, null, null},
{null, null, null}
},
new String [] {
"NAME", "CITY", "Title 3"
}
));
jTable1.setRowHeight(150);
jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(128, 128, 128)
.addComponent(jButton1)
.addGap(181, 181, 181))
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
jFileChooser1.showOpenDialog(this);
String path=jFileChooser1.getSelectedFile().getAbsolutePath();
//txtname.setText(path);
FileReader file=new FileReader(path);
String header[]={"NAME","Address","Contact","Email","IMAGE"};
Object[][] data=new Object[50][5];
String record="";
for(int i=file.read();i!=-1;i=file.read())
record+= (char)i;
StringTokenizer stt=new StringTokenizer(record,"\n");
for(int i=0;stt.hasMoreTokens();i++){
StringTokenizer st=new StringTokenizer(stt.nextToken(),"\t");
jTable1.setValueAt(st.nextToken(), i, 0);
jTable1.setValueAt(st.nextToken(), i, 1);
// jTable1.setValueAt(st.nextToken(), i, 2);
jTable1.setValueAt(new ImageIcon(st.nextToken().trim()),i,2);
jTable1.getColumnModel().getColumn(2).setCellRenderer(new TableCellRender());
}}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e,"file not Saved",JOptionPane.ERROR_MESSAGE);
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TableImage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TableImage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TableImage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TableImage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new TableImage().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
class TableCellRender extends DefaultTableCellRenderer
{
JLabel lbl=new JLabel();
JLabel lbl1=new JLabel();
private Icon Imageicon;
@Override
public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasfocus,int row,int col)
{
lbl.setIcon((ImageIcon)value);
JScrollPane pane =new JScrollPane(lbl);
return pane;
}
}
}
View Answers
Related Tutorials/Questions & Answers:
JTABLE SCROLL PANEJTABLE SCROLL PANE The scrollpane for a image in
Jtable is only showing but not working ....here is the code i am doing please suggest something...
import java.awt.Component;
import java.io.FileReader;
import
JTABLE SCROLL PANEJTABLE SCROLL PANE The scrollpane for a image in
Jtable is only showing but not working ....here is the code i am doing please suggest something...
import java.awt.Component;
import java.io.FileReader;
import
Advertisements
Java scroll pane-java GUIJava
scroll pane-java GUI Dear friends.. Very Good morning.
I have a doubt in my gui application.
Take ex:- My gui application has 1 Jscrollpane of height 600 and width 400. normally it is showing 200 height and 400 width
Create a Scroll Pane Container in Java Create a
Scroll Pane Container in Java
... to create a
scroll
pane container in Java Swing. When you simply create a Text Area... a
scroll pane for the given text
area. The following methods and APIs used
JTable"};
JTable table=new
JTable(data,labels);
JScrollPane
pane=new JScrollPane(table);
frame.add(
pane);
frame.setVisible(true... to rewrite my program so you can
scroll and data exists in more than one line
JTableJTable Values to be displayed in JTextfield when Clicked on
JTable Cells
JTableJTable i want to delete record from
JTable using a MenuItem DELETE. and values of
JTable are fetched from database....please reply soon
JTable JTable how to select a definite cell which containing a similar text containg to the one which the user entering from a
jtable at runtime in java
JTableJTable need to add values to a
JTable having 4 coloumns ,2 of them are comboboxes
JTableJTable Hello, i cannot display data from my table in the database to the cells of my
JTable. please help me
jtablejtable how to get the values from database into
jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
jtablejtable hi
Sir
i am working netbeans IDE,I have a
jtable when i insert values in
jtable
then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values
then , i am getting output
jtablejtable hey i have build a form and i m also able to add data from database to
jtable along with checkbox.the only problem is that if i select multiple checkboxes the data doesnt get inserted into new database and if only one
JTableJTable Hi
I have problems in setting values to a cell in
Jtable which is in a jFrame which implements TableModelListener which has a abstract method
tableChanged(TableModelEvent e) .
I'll be loading values from data base when
Scroll ImagesUIScrollViewScroll ImagesUIScrollView Hi, Can anyone please suggest me how to
scroll images in UIScrollView in iPad?
THanks
problem Scrolling jTable in scrollpaneproblem Scrolling
jTable in scrollpane hi i get into a problem of scrolling
jtable in scrollpane.Only horizontal
scroll is working, vertical
scroll...));
tableModel =new DefaultTableModel(rowdata, colname);
table = new
JTable problem Scrolling jTable in scrollpaneproblem Scrolling
jTable in scrollpane hi i get into a problem of scrolling
jtable in scrollpane.Only horizontal
scroll is working, vertical
scroll...));
tableModel =new DefaultTableModel(rowdata, colname);
table = new
JTable Scroll in JPanelScroll in JPanel Hello sir, Hi Friend,
You can use the following code:
import java.awt.*;
import javax.swing.*;
class
scroll
{
public static void main(String[] args)
{
Frame f = new Frame ("Demo");
JPanel p = new
jtable with table headers - Swing AWTjtable with table headers give me java code to create
jtable with table headers
and by which i can
scroll jtable and can retrieve height and width of the table
accordion pane - Ajaxaccordion pane Is it possible to change the content of an accordion
pane promgramatically?
I wrote :
function modif_pane1(){
dijit.layout.byId("pane1").content="string";
}
but that's don't work
ModuleNotFoundError: No module named 'Scroll'ModuleNotFoundError: No module named '
Scroll' Hi,
My Python... '
Scroll'
How to remove the ModuleNotFoundError: No module named '
Scroll'... to install padas library.
You can install
Scroll python with following command
javascript set scroll heightjavascript set
scroll height How to set
scroll height in JavaScript?
CSS
Scroll Method
div
{
width:150px;
height:150px;
overflow:
scroll;
}
JavaScript ScrollTo method
<script type="text/javascript">
JTable - Swing AWTJTable Hi Deepak,
i want to display the
Jtable data... how could i show
jtable data on the console.
Thanks,
Prashant
Hi...*;
public class JTableToConsole extends JFrame {
public Object GetData(
JTable Horizontal scroll bar?Horizontal
scroll bar? Hi all,
I have a HTTP Servlet... this.
While the browser window automatically creates a vertical
scroll bar, it does not automatically create a horizontal
scroll bar when the data written exceeds
Regarding Scroll Bar - CVSRegarding
Scroll Bar HI all, i have a Text Message box which i have incorporated in my code which goes something like
JTABLE OF JAVAJTABLE OF JAVA i have a
jtable in java,i have used checkbox in
jtable.
now i want to add(submit) only those records that i have checked by checkbox how?
i want small example with coding
Jtable-JavaJtable-Java Hi all,I have a
Jtable And i need to clear the data in the table .I only Need to remove the data in the table.not the rows.Please help me
Swings JTableSwings JTable add values to
JTable with four coloums,two of them are comboboxes
sum in JTablesum in JTable how to calculate sum from
JTable's one field like total
JTABLE IssueJTABLE Issue Hi Eveyone,
I am developing a small application on Swing-AWT. I have used
JTABLE to show data. There is "input field" and "search... on basis of input data provided in input field. For
JTABLE is on some other
jtable queryjtable query I need a syntax...where i could fetch the whole data from the database once i click the cell in
jtable...and that must be displayed in the nearby text field which i have set in the same frame
java jtablejava jtable Hello Sir, I am developing a desktop application in which i have to display database records in
jtable .now I want to read only... that in
jtable.
plz help me with the code
regarding jtable...regarding
jtable... sir,
im working with jtables. i wanted to populate a
jtable from the database and when i click any row it should add a container... a container on the
jtable.
kindly help me sir.
thanks in advance
regards,
rajahari
ABOUT JtableABOUT Jtable My Project is Exsice Management in java swing Desktop Application.
I M Use Netbeans & Mysql .
How can retrive Data in
Jtable from Mysql Database in Net Beans
how add tabs at the left side of a panehow add tabs at the left side of a pane sir
i have added the tabs at the top left corner of the
pane, but i am unable to add it at the left side of the
pane, so please help me
jtable insert row swingjtable insert row swing How to insert and refresh row in
JTable?
Inserting Rows in a
JTable example
Connecting JTable to database - JDBCConnecting
JTable to database Hi..
I am doing a project on Project... to store this
JTable content in my database table..
This is a very important... InsertJTableDatabase{
JTable table;
JButton button;
public static void main(String
REPORT WITH JTABLE(Exception e){}
JTable table = new
JTable(data, columnNames);
JScrollPane scrollPane
JTable - JDBCJTable
Hello.....
I have
Jtable with four rows and columns and i have also entered some records in MsSql database. i want to increase
Jtable's...
{
JFrame f;
JPanel p;
JLabel l;
JTextField tf;
JButton btn;
JTable tb