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.
September 3, 2011 at 11:00 AM
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
public class RemoveDataFromTable{
JTable table;
JButton button;
public static void main(String[] args){
new RemoveDataFromTable();
}
public RemoveDataFromTable(){
JFrame frame = new JFrame("Getting Cell Values in JTable");
JPanel panel = new JPanel();
String data[][] = {{"Angelina","Mumbai"},{"Martina","Delhi"}};
String col[] = {"Name","Address"};
DefaultTableModel model = new DefaultTableModel(data, col);
table = new JTable(model);
JScrollPane pane = new JScrollPane(table);
button=new JButton("Remove Data");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
int index=1;
int count=table.getRowCount();
for(int i=0;i<count;i++){
SetData("",i, 0);
SetData("",i, 1);
}
}
});
panel.add(pane);
panel.add(button);
frame.add(panel);
frame.setSize(500,500);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void SetData(Object obj, int row_index, int col_index){
table.getModel().setValueAt(obj,row_index,col_index);
}
}
Related Tutorials/Questions & Answers:
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 in java swingjtable in
java swing hai friends...
i am creating 1 GUI having 1 table, that table contain 3 fields(columns) and 10 rows..
user can enter values in the first 2 columns. The 3rd column is the concatenation of first 2 column
Advertisements
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
JTable in java - Java BeginnersJTable in java Sir , I have created an application with a
JTable showing the records of an MS Access database table. On the same frame I have... given one ,
JTable table; ....... .... table.print(); Here the error
update a JTable - Java Beginnersupdate a
JTable i have tried your advice as how to update a
JTable... main(String args[])
{
JTable table;
Connection con = null...");
ResultSetTableModel model = new ResultSetTableModel(rs);
table = new
JTable(model
update a JTable - Java Beginnersupdate a
JTable how to update a
JTable with Mysql data through user... in an updatable
JTable
You would create the table as follows:
conn... = new ResultSetTableModel(rs);
table = new
JTable(model
JTable - Java BeginnersJTable Search Filter Hi,i wanted to add a search filter in my
JTable application.Thanks in Advance!! i'means using database access,when...=============================================================================i press the enter button into
JTable cell and focus
JTable - Java Beginners want my
JTable on the panel. and i also want to increase height and width... back. thank you very much sir for your help. i am new to
java and your help...);
}
res2.close();
stat3.close();
JTable table = new
JTable(data
JTable - Java Beginners();
stat3.close();
JTable table = new
JTable(data, columnNames... the following links:
http://www.roseindia.net/
java/example/
java/swing/CellGap.shtml
http://www.roseindia.net/
java/example/
java/swing
JTable - Java BeginnersJTable Hi, I have some problem with
JTable. On show All button hit....
my problem is with
Jtable, sometimes it is visible and sometimes it is not. when...();
JTable table = new
JTable(data, columnNames);
sp=new JScrollPane(table
JTable - Java BeginnersJTable search example I've problem about
JTable, i wan to search records when i types words in
JTable cell,can u give the source code.I'm Beginner and i start begins learning
java programming.Please send the example into my
Creating a JTable Component of
JTable and it's components.
JTable: The JTabel
component is more flexible
Java... programming tutorial we are going to implement the
simple
JTable on the
java swing frame with the help of some
java
methods. To create a
JTable component, you need
About java About
java how we insert our database data into the
jTable in
java
or
how we show database content into the
JTable in
java
Hi Friend,ADS_TO_REPLACE_1
Try the following code:
import
Add XML to JTableAdd XML to
JTable
In this section, you will learn how to access the contents or data of xml document and display its information into the
jtable.
Java... all the xml file data into the
JTable .ADS_TO_REPLACE_1
Here is the person.xml
Getting Cell Values in a JTable
Getting Cell Values in a
JTable
...
values in a
JTable component. It is a same as setting the cell values in
a
JTable...
This program helps you to get the cell values in a
JTable.
This program creates a
JTable search filter and JTable my question is:
how can i make search data in
JTable of
java?
i wan to search records in table or textfield but the data display in
JTable.
Note: i dont...","Contact No","Email"};
JTable table=new
JTable(data,labels
Sitemap Core Java Tutorial Section JTable |
Java JRE Downloads |
Java JAR Files |
Java Jar File |
Java...
Map | Business Software
Services India
Java Tutorial Section
Core
Java... |
JDK 6 Tutorial |
Java UDP Tutorial
|
Java Threading
Tutorial |
Java 5
Java Swing Tutorials;
Setting
the Height and Width of Rows and columns in
JTable
In this
java... in
the previous
Java section. Now, you will be able to do the shading rows in
JTable...;
Inserting a Column
in
JTable
In this
Java programming tutorial, you