Java/PHP Developer

Java/PHP Developer

please help me to bring cell values of jtable to a text file....................

View Answers

November 17, 2011 at 1:19 PM

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

public class JTableToTextFile{
JTable table;
JButton button;
public static void main(String[] args) {
new JTableToTextFile();
}

public JTableToTextFile(){
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("Submit");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
int index=1;
int count=table.getRowCount();

try{
for(int i=0;i<count;i++){
Object obj1 = GetData(table, i, 0);
Object obj2 = GetData(table, i, 1);
String value1=obj1.toString();
String value2=obj2.toString();

System.out.println(value1);
System.out.println(value2);
BufferedWriter bw=new BufferedWriter(new FileWriter("data.txt",true));
bw.write(value1+" "+value2);
bw.newLine();
bw.close();
index++;
}
}
catch(Exception e){}
}
});
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 Object GetData(JTable table, int row_index, int col_index){
return table.getModel().getValueAt(row_index, col_index);
}
}









Related Tutorials/Questions & Answers:
Java/PHP Developer
Java/PHP Developer  help me with passing data from jframe to text file please
Java/PHP Developer
Java/PHP Developer  please help me to bring cell values of jtable to a text file
Advertisements
Java/PHP Developer
Java/PHP Developer  how to remove and add a new contentpane on same frame do we have any methods
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box
Java/PHP Developer
Java/PHP Developer  Hi, I need a cloak embedded in java swing frame or panel..And it should not change when system time is changed ..please
Java/PHP Developer
Java/PHP Developer  Hi, can u help me to embedd time on java frame and it should be independent of operating system time..if we change system time it should'nt be changed.. Thank you sir
Java/PHP Developer
Java/PHP Developer  how can we get words seperated by delimeters in text file can be imported in jframe like one word for one line
Java/PHP Developer
Java/PHP Developer  Hi, how to create radio buttons on one pannel and should change when pressed ok... can u help me htrough this sooner... THANK U
Java/PHP Developer
Java/PHP Developer  Hi, can u please help me with this, I have a text file with 3 sentences separated by delimiters and i want to get each sentence in different JFrames when press ok button on first frame it should close
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box..... like a text file containing questions and another text file containing answer of 3 r 4 options,each one
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box..... like a text file containing questions and another text file containing answer of 3 r 4 options,each one
Java/PHP Developer
Java/PHP Developer  Hi, I have a textfile(notepad1.txt) with 1 question and another textfile(notepad2.txt) with answers(4 options like multiple choice),question is imported from first text file to jframe and 4 options with check
Java/PHP Developer
Java/PHP Developer  Hello sir, Am working on playing audio file in jframe and im not able to import javax.media into the code.. the code.../java/javase/download-142937.html After downloading, put the jar file under the lib
Java/PHP Developer
Java/PHP Developer  HI, I want to know how can we place a link in one jframe to open a videopanel. import java.net.MalformedURLException; import... } // end MediaPanel constructor } // end class MediaPanel   Java create
plsql developer
plsql developer  how did plsql developer provided the information to the frent end people when ever they contact plsql developer and how plsql developer tck the data from the database
Java Developer
Java Developer  Hi, I am engineering student. I want to make career in as Java Developer. How to become a Java Developer? What programming languages... an expert Java Developer? Thanks
App Developer
App Developer  Hi, Who is App Developer? Thanks   Hi, App Developer is the term used for the programmers or companies developing mobile applications. Mobile application or simply app is the hot trend there days
ModuleNotFoundError: No module named 'developer'
ModuleNotFoundError: No module named 'developer'  Hi, My Python... 'developer' How to remove the ModuleNotFoundError: No module named 'developer' error? Thanks   Hi, In your python environment you
Developer Files - Development process
Developer Files  Hi, I dont have real time experience. can u tell as a j2ee developer should i edit struts properties files or not . like wise changes in any other properties file. Thanks Prakash
Developer discussion forums
Developer discussion forums  Hi, What is discussion forums? Is there any good forum for discussion programming technologies? Thanks... managed and spam protected. You can check LiveTechTalk.com - Developer discussion
Hire iPhone developer
Hire iPhone developer - Hire iPhone developers in India Apple?s iPhone... few efficient developer in this field. If you want to develop any outstanding... programmer or hire iPhone app developer who can develop an iPhone application
ai developer course
ai developer course  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: ai developer course... the topic "ai developer course". Also tell me which is the good training
iPhone apps developer
iPhone apps developer With the launch of Apple's innovative product iPhone that comprises three advanced products in it-a smart mobile, a faster internet connection and advanced multimedia devices with touch screen and virtual
Version of merlin-developer>merlin-developer-core dependency
List of Version of merlin-developer>merlin-developer-core dependency
Mozilla Developer Center
Mozilla Developer Center       Great site to get a first look at AJAX. Read full DescriptionADS_TO_REPLACE_1
Artifacts of merlin-developer
List of Artifacts of merlin-developer maven depenency
Artifacts of com.ns-developer
List of Artifacts of com.ns-developer maven depenency
Maven Repository/Dependency: merlin-developer | merlin-developer-core
Maven Repository/Dependency of Group ID merlin-developer and Artifact ID merlin-developer-core. Latest version of merlin-developer:merlin-developer-core dependencies. # Version Release Date
What skills are required to be a Hadoop developer?
What skills are required to be a Hadoop developer?  Hi, How to become a good Hadoop Developer? What skills are required to be a Hadoop developer? Thanks
What are job role of Hadoop Developer?
What are job role of Hadoop Developer?  Hi, I am planning to get the the job in Hadoop Development as Hadoop Developer. What are the roles of a Hadoop Developer? Thanks
ModuleNotFoundError: No module named 'developer-tools'
ModuleNotFoundError: No module named 'developer-tools'  Hi, My... named 'developer-tools' How to remove the ModuleNotFoundError: No module named 'developer-tools' error? Thanks   Hi, In your python
Looking to Hire Magento Website Developer?
Looking to Hire Magento Website Developer?  Are you searching for Magento ecommerce development solution? Then you have arrived on the right place... at reasonable prices. You can hire Magento ecommerce developer from us
google developer machine learning bootcamp
google developer machine learning bootcamp  Hi, I am beginner... to learn: google developer machine learning bootcamp Try to provide me good examples or tutorials links so that I can learn the topic "google developer
What is the salary of Python developer in India?
What is the salary of Python developer in India?  Hi, I am beginner... to learn: What is the salary of Python developer in India? Try to provide me... is the salary of Python developer in India?". Also tell me which is the good
Searching Mobile developer for image recognition
Searching Mobile developer for image recognition  Hi, I have an idea for an application that requires image recognition. I have decided to use... of calling web services. Developer should have at least 5 years of experience
software developer
software developer
Software Developer
Software Developer  what is the java code to turn off my pc
java developer
java developer  i didnt get the correct ANSWER PLZ EXECUTE THE FOOLWING SERVLET BY USING DATABASE USERLOGIN TABLE VALUES. //validate login.html <html> <body> <body bgcolor="wheat"> <center>
Java Developer
Java Developer  What is scenario where i use interface and where use interface
Java Developer
Java Developer  where we should use interface and where we should use abstract class
Version of com.ns-developer>tagcloudview dependency
How to become a PHP Developer?
PHP developer. This explains you all the technologies you have to learn to become a PHP Developer. You will definitely find this step-by-step tutorial very.... To become a PHP developer following the following steps:ADS_TO_REPLACE_1 How
PHP Application Developer in India
PHP Application Developer in India We offer PHP Application Developer in India... using PHP language. Roseindia, a leading PHP developer India has a strong... in Application development in PHP framework. PHP is a very powerful open source
PHP Application Developer in India
PHP Application Developer in India We offer PHP Application Developer in India... using PHP language. Roseindia, a leading PHP developer India has a strong... in Application development in PHP framework. PHP is a very powerful open source
PHP Application Developer in India
PHP Application Developer in India We offer PHP Application Developer in India... using PHP language. Roseindia, a leading PHP developer India has a strong... in Application development in PHP framework. PHP is a very powerful open source
PHP Application Developer in India
PHP Application Developer in India We offer PHP Application Developer in India... developer India has a strong network of PHP professionals that can develop... in Application development in PHP framework. PHP is a very powerful open source
Perl Developer
Perl Developer       Position Vacant: Perl Developer Job Description  We... Experience: 1- 6 Years  Keywords: Perl, Developer, Unix
ModuleNotFoundError: No module named 'example-pkg-Developer-EC'
ModuleNotFoundError: No module named 'example-pkg-Developer-EC'  Hi...: No module named 'example-pkg-Developer-EC' How to remove the ModuleNotFoundError: No module named 'example-pkg-Developer-EC' error? Thanks  
ModuleNotFoundError: No module named 'watson-developer-cloud'
ModuleNotFoundError: No module named 'watson-developer-cloud'  Hi...: No module named 'watson-developer-cloud' How to remove the ModuleNotFoundError: No module named 'watson-developer-cloud' error? Thanks   Hi

Ads