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

Ayush Practical No 8

This document contains code to create a JTable in Java. It includes: 1) Code to generate a simple JTable with 3 columns and 3 rows of sample data. 2) An exercise asking to create a JTable to display the name, percentage, and grade of 10 students. 3) The code provided to generate this JTable, including the data, column names, and setup of the JTable, JScrollPane, and JFrame.

Uploaded by

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

Ayush Practical No 8

This document contains code to create a JTable in Java. It includes: 1) Code to generate a simple JTable with 3 columns and 3 rows of sample data. 2) An exercise asking to create a JTable to display the name, percentage, and grade of 10 students. 3) The code provided to generate this JTable, including the data, column names, and setup of the JTable, JScrollPane, and JFrame.

Uploaded by

nstrnsdtn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ADVANCE JAVA PROGRAMMING

Name :- Ayush Maroti wadje Class : - CO5I

Roll No :-76

Practical No 8 :- Write a Program To Create a JTable.

X. ---------- ?

1. Write a Program Code To Generate The Following Output.

Code :-

import javax.swing.*;
public class JTableEx {
JFrame F;
JTableEx() {
F=new JFrame();
String rows[][]={{"101","Amit","670000"},
{"102","Jai","780000"},
{"101", "Sachin","700000"}};
String columns[]={"ID","NAME","SALARY"};
JTable JT=new JTable(rows,columns);
JT.setBounds(30,40,200,300);
JScrollPane AW=new JScrollPane(JT);
F.setSize(300,450);
F.setVisible(true);
F.add(AW);

}
public static void main(String args[]) {
new JTableEx();
}
}}
Output :-
XIII. Exercise.

1. Write a Java Program To Create a Table Of Name Of Student, Percentage


And Grade Of 10 Students Using JTable.

Code :-

import javax.swing.*;
public class JTableEx1 {
JFrame f;
JTableEx1() {
f = new JFrame();
String rows[][] = {{"Ayush Wadje","90","A+"},
{"Vaibhav Pawar", "78", "B+"},
{"sarthak Pathak", "89", "A+"},
{"Avinash Ranvir", "81", "A+"},
{"Prathmesh Kannalwar", "88", "A+"},
{"Abhishek Bukatare", "80", "A+"},
{"Ashish Khillare", "88", "A+"},
{"Samarth Bondhare", "75", "B+"},
{"Atharv joshi", "72", "C+"},
{"kalpe Desai", "89", "A+"},
{"Piush Darake", "70", "D"}};
String columns[] = {"NAME OF STUDENTS", "PERCENTAGE", "GRADE"};
JTable jt = new JTable(rows, columns);
jt.setBounds(40, 40, 200, 300);
JScrollPane sp = new JScrollPane(jt)
f.setSize(500, 500);
f.setVisible(true);
f.add(sp);

}
public static void main(String args[]) {
new JTableEx1();
}
}
}
Output :-

You might also like