0% found this document useful (0 votes)
11 views4 pages

Java Practical8

Uploaded by

Priyanka Thadke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Java Practical8

Uploaded by

Priyanka Thadke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name:- Priyanka Khandu Thadke

Class:-A(CO5I) Roll no:- 60


Practical no:-08 Write a java to Create a JTable.
Program code:-
Q.1Develop a Program to demonstrate the use of JTable.

import java.awt.*;

import javax.swing.*;

class JTableprg

public static void main(String args[]) {

JFrame jf=new JFrame();

jf.setVisible(true);

jf.setSize(400,400);

jf.setTitle("Program to demostrate JTable");

String[] col={"s_id","s_name","DOB"};

String[] [] row={{"101","Priyaka","13/09/2006"},{"102","Ankita","16/09/2009"},
{"103","Pranali","31/05/2013"},{"104","Sayali","30/10/2017"}};

JTable jt=new JTable(row,col);

jf.add(jt);

}}

Output:-

Q.2 write a Program code to generae following output.


import java.awt.*;

import javax.swing.*;

class JTableprg1

public static void main(String args[])

JFrame jf1=new JFrame();

jf1.setVisible(true);

jf1.setSize(400,400);

jf1.setTitle("Program to demostrate JTable");

String[] col={"s_id","s_name","Salary"};

String[] [] row={{"ID","Name","Salary"},{"101","Amit","670000"},{"102","Jai","780000"},
{"103","Sachin","700000"}};

JTable jt1=new JTable(row,col);

jf1.add(jt1);

}
}
Output:-

Exercise:-
Q.1) Write a java program to create a table of Name of Student ,Percentage and Grade of 10
students using JTable.
import java.awt.*;

import javax.swing.*;

class JTableprg2

public static void main(String args[])

JFrame jf2=new JFrame();

jf2.setVisible(true);

jf2.setSize(400,400);

jf2.setTitle("Program to demostrate JTable");

String[] col={"s_name","s_Perentage","Grade"};

String[] [] row={{"Name","Percentage","Grade"},

{"Priyaka","82.40","A"},

{"Pooja","67.87","B"},

{"Vaishnvi","80.00","A"},

{"Sanika","65.97","B"},

{"Neha","64.67","B"},

{"Tanvi","77.67","A"},

{"Sakshi","77.87","B"},

{"Mayuri","81.87","A"},

{"Samiksha","72.67","B"},

{"Sankruti","73.67","B"},

};
JTable jt2=new JTable(row,col);

jf2.add(jt2);

}
}
Output:-

You might also like