Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA, how to save the data of the Jtable on a txt.file? and any changes made on execution are also made on the txt file

JAVA, how to save the data of the Jtable on a txt.file? and any changes made on execution are also made on the txt file and updated later.

import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable;

public class JTableExamples { // frame JFrame f; // Table JTable j;

// Constructor JTableExamples() { // Frame initiallization f = new JFrame();

// Frame Title f.setTitle("JTable Example");

// Data to be displayed in the JTable String[][] data = { { "Kundan Kumar Jha", "4031", "CSE" }, { "Anand Jha", "6014", "IT" } };

// Column Names String[] columnNames = { "Name", "Roll Number", "Department" };

// Initializing the JTable j = new JTable(data, columnNames); j.setBounds(30, 40, 200, 300);

// adding it to JScrollPane JScrollPane sp = new JScrollPane(j); f.add(sp); // Frame Size f.setSize(500, 200); // Frame Visible = true f.setVisible(true); }

// Driver method public static void main(String[] args) { new JTableExamples(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions