SlideShare a Scribd company logo
1 of 7
Download to read offline
Create a Code that will add an Add, Edi, and Delete button to the GUI like bellow.
public class Student {
private String studentID;
private String studentEmail;
private String studentFirstName;
private String studentLastName;
/**
* @param studentID
* @param studentEmail
* @param studentFirstName
* @param studentLastName
*/
public Student(String studentID, String studentEmail, String studentFirstName,
String studentLastName) {
this.studentID = studentID;
this.studentEmail = studentEmail;
this.studentFirstName = studentFirstName;
this.studentLastName = studentLastName;
}
/**
* @return the studentID
*/
public String getStudentID() {
return studentID;
}
/**
* @param studentID
* the studentID to set
*/
public void setStudentID(String studentID) {
this.studentID = studentID;
}
/**
* @return the studentEmail
*/
public String getStudentEmail() {
return studentEmail;
}
/**
* @param studentEmail
* the studentEmail to set
*/
public void setStudentEmail(String studentEmail) {
this.studentEmail = studentEmail;
}
/**
* @return the studentFirstName
*/
public String getStudentFirstName() {
return studentFirstName;
}
/**
* @param studentFirstName
* the studentFirstName to set
*/
public void setStudentFirstName(String studentFirstName) {
this.studentFirstName = studentFirstName;
}
/**
* @return the studentLastName
*/
public String getStudentLastName() {
return studentLastName;
}
/**
* @param studentLastName
* the studentLastName to set
*/
public void setStudentLastName(String studentLastName) {
this.studentLastName = studentLastName;
}
}
------------------------------------------------------------------------------------------------------
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
public class JTableExample extends JFrame {
public JTableExample() {
// headers for the table
String[] columns = new String[] { "Email", "First Name", "Last Name" };
Student[] students = {
new Student("S123", "sri3(AT).com", "Srinu", "Vasu"),
new Student("S124", "sri4(AT).com", "Rajesh", "Kumar"),
new Student("S125", "sri5(AT).com", "Kumar", "Suresh"),
new Student("S126", "sri6(AT).com", "Balaji", "kumar") };
// actual data for the table in a 2d array
Object[][] data = new Object[students.length][3];
for (int i = 0; i < data.length; i++) {
data[i][0] = students[i].getStudentEmail();
data[i][1] = students[i].getStudentFirstName();
data[i][2] = students[i].getStudentLastName();
}
// create table with data
JTable table = new JTable(data, columns);
// add the table to the frame
this.add(new JScrollPane(table));
this.setTitle("Student Manager");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new JTableExample();
}
});
}
} Student Manager Email sri3@gmail.com sri4@gmail.com sri5@gmail.com sri6@gmail com
Last Name First Name Srinu Vasu Rajesh Kumar Suresh Kumar Balaji kumar Add Edit Delete
Solution
program import Database.DatabaseOperations;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
import javax.xml.crypto.Data;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.*;
import java.util.Vector;
import static java.awt.Color.*;
public class K_EditUserPanel extends JFrame{
private JPanel pOuter;
private CustTable table;
{
Vector columnNames = new Vector();
Vector data = new Vector();
try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:oracle:thin:HR/pmagee@localhost:1521:XE";
String userid = "system";
String password = "db08Sep95";
Class.forName( driver );
Connection connection = DriverManager.getConnection(url, userid, password);
String sql = "Select * from Customer";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++)
{
columnNames.addElement( md.getColumnName(i) );
}
while (rs.next())
{
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
{
row.addElement( rs.getObject(i) );
}
data.addElement( row );
}
rs.close();
stmt.close();
connection.close();
}
catch(Exception e)
{
System.out.println( e );
}
DefaultTableModel model = new DefaultTableModel(data, columnNames)
{
public Class getColumnClass(int column)
{
for (int row = 0; row < getRowCount(); row++)
{
Object o = getValueAt(row, column);
if (o != null)
{
return o.getClass();
}
}
return Object.class;
}
};
JTable table = new JTable( model );
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add(scrollPane);
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
}
public static void main(String[] args)
{
TableFromDatabase frame = new TableFromDatabase();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
}
public K_EditUserPanel()
{
pOuter = new JPanel();
pOuter.setPreferredSize(new Dimension(575, 498));
pOuter.setOpaque(true);
pOuter.setBackground(darkGray);
pOuter.setLayout(new GridBagLayout());
}
public JPanel getUserPanel()
{
pOuter.removeAll();
try
{
pOuter = updateUserPanel(pOuter);
}
catch(SQLException e)
{
System.out.println();
}
pOuter.revalidate();
pOuter.repaint();
return pOuter;
}
public JPanel updateUserPanel(JPanel jPanel) throws SQLException {
jPanel.removeAll();
JPanel inner = new JPanel();
inner.setPreferredSize(new Dimension(575, 498));
inner.setOpaque(true);
inner.setBackground(darkGray);
inner.setLayout(new GridBagLayout());
jPanel.add(inner);
inner.setSize(300,300);
inner.add(new JScrollPane());
inner.setVisible(true);
inner.revalidate();
inner.repaint();
setSize(450,500);
setVisible(true);
return inner;
}
}

More Related Content

Similar to Create a Code that will add an Add, Edi, and Delete button to the GU.pdf

Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student PortalPeeyush Ranjan
 
Android Testing
Android TestingAndroid Testing
Android TestingEvan Lin
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docxajoy21
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScripttaobao.com
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、GaelykでハンズオンTsuyoshi Yamamoto
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data ModelKros Huang
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfAnkitchhabra28
 
Exercises of java tutoring -version1
Exercises of java tutoring -version1Exercises of java tutoring -version1
Exercises of java tutoring -version1Uday Sharma
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfanwarsadath111
 
Code to copy Person.java .pdf
Code to copy Person.java .pdfCode to copy Person.java .pdf
Code to copy Person.java .pdfanokhijew
 
Design patterns
Design patternsDesign patterns
Design patternsBa Tran
 
Tested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfTested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfanupamagarud8
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 

Similar to Create a Code that will add an Add, Edi, and Delete button to the GU.pdf (20)

Library system project file
Library system project fileLibrary system project file
Library system project file
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student Portal
 
Android Testing
Android TestingAndroid Testing
Android Testing
 
Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 
Exercises of java tutoring -version1
Exercises of java tutoring -version1Exercises of java tutoring -version1
Exercises of java tutoring -version1
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdf
 
Code to copy Person.java .pdf
Code to copy Person.java .pdfCode to copy Person.java .pdf
Code to copy Person.java .pdf
 
Java2
Java2Java2
Java2
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
Tested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdfTested on EclipseBoth class should be in same package.pdf
Tested on EclipseBoth class should be in same package.pdf
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 

More from lakshmijewellery

Write a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdfWrite a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdflakshmijewellery
 
Why did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdfWhy did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdflakshmijewellery
 
What were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdfWhat were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdflakshmijewellery
 
What process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdfWhat process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdflakshmijewellery
 
What is OBDC , Is it a program and what is the difference between .pdf
What is OBDC , Is it a program  and what is the difference between .pdfWhat is OBDC , Is it a program  and what is the difference between .pdf
What is OBDC , Is it a program and what is the difference between .pdflakshmijewellery
 
This Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdfThis Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdflakshmijewellery
 
What are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdfWhat are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdflakshmijewellery
 
We live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdfWe live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdflakshmijewellery
 
What are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdfWhat are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdflakshmijewellery
 
True or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdfTrue or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdflakshmijewellery
 
This level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdfThis level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdflakshmijewellery
 
Throughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdfThroughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdflakshmijewellery
 
The term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdfThe term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdflakshmijewellery
 
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdfThe methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdflakshmijewellery
 
The lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdfThe lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdflakshmijewellery
 
The files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdfThe files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdflakshmijewellery
 
The dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdfThe dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdflakshmijewellery
 
The chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdfThe chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdflakshmijewellery
 
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdfRead the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdflakshmijewellery
 
Q4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdfQ4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdflakshmijewellery
 

More from lakshmijewellery (20)

Write a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdfWrite a shell command to substitute the first Nick to John in report.pdf
Write a shell command to substitute the first Nick to John in report.pdf
 
Why did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdfWhy did the European empires in the Americas have such an enormously.pdf
Why did the European empires in the Americas have such an enormously.pdf
 
What were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdfWhat were the unintended consequences of the Cuban Missile Crisis.pdf
What were the unintended consequences of the Cuban Missile Crisis.pdf
 
What process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdfWhat process occurs when bile is mixed with fats How does this proc.pdf
What process occurs when bile is mixed with fats How does this proc.pdf
 
What is OBDC , Is it a program and what is the difference between .pdf
What is OBDC , Is it a program  and what is the difference between .pdfWhat is OBDC , Is it a program  and what is the difference between .pdf
What is OBDC , Is it a program and what is the difference between .pdf
 
This Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdfThis Capital includes O A. mineral resources. O B. the money in one.pdf
This Capital includes O A. mineral resources. O B. the money in one.pdf
 
What are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdfWhat are the essential characteristics of cloud computingSolutio.pdf
What are the essential characteristics of cloud computingSolutio.pdf
 
We live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdfWe live in a very complex and culturally diverse society. When we br.pdf
We live in a very complex and culturally diverse society. When we br.pdf
 
What are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdfWhat are the values of the following expressions, assuming that n is.pdf
What are the values of the following expressions, assuming that n is.pdf
 
True or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdfTrue or FalseA budget variance is the difference between expected.pdf
True or FalseA budget variance is the difference between expected.pdf
 
This level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdfThis level of measurement includes continuous measures A. Nominal; .pdf
This level of measurement includes continuous measures A. Nominal; .pdf
 
Throughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdfThroughout the middle ages European philosophers believed in…a sci.pdf
Throughout the middle ages European philosophers believed in…a sci.pdf
 
The term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdfThe term intangible assets is used in accounting to denotea. suc.pdf
The term intangible assets is used in accounting to denotea. suc.pdf
 
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdfThe methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
The methyl-accepting chemotaxis proteins of bacteriaa) integrate m.pdf
 
The lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdfThe lagging strand is replicated with a series of Okazaki fragments .pdf
The lagging strand is replicated with a series of Okazaki fragments .pdf
 
The files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdfThe files etcpasswd and etcshadow can be manually edited. Why wo.pdf
The files etcpasswd and etcshadow can be manually edited. Why wo.pdf
 
The dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdfThe dividends received deduction Must exceed the applicable percentag.pdf
The dividends received deduction Must exceed the applicable percentag.pdf
 
The chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdfThe chordae tendinae of the AV valves are anchored to the ___ of the .pdf
The chordae tendinae of the AV valves are anchored to the ___ of the .pdf
 
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdfRead the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
Read the case Kenny An Effective Supervisor and in a 2-3 page p.pdf
 
Q4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdfQ4. How are automated tools used in the maintenance of information .pdf
Q4. How are automated tools used in the maintenance of information .pdf
 

Recently uploaded

Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 

Recently uploaded (20)

Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 

Create a Code that will add an Add, Edi, and Delete button to the GU.pdf

  • 1. Create a Code that will add an Add, Edi, and Delete button to the GUI like bellow. public class Student { private String studentID; private String studentEmail; private String studentFirstName; private String studentLastName; /** * @param studentID * @param studentEmail * @param studentFirstName * @param studentLastName */ public Student(String studentID, String studentEmail, String studentFirstName, String studentLastName) { this.studentID = studentID; this.studentEmail = studentEmail; this.studentFirstName = studentFirstName; this.studentLastName = studentLastName; } /** * @return the studentID */ public String getStudentID() { return studentID; } /** * @param studentID * the studentID to set */ public void setStudentID(String studentID) { this.studentID = studentID; } /** * @return the studentEmail */
  • 2. public String getStudentEmail() { return studentEmail; } /** * @param studentEmail * the studentEmail to set */ public void setStudentEmail(String studentEmail) { this.studentEmail = studentEmail; } /** * @return the studentFirstName */ public String getStudentFirstName() { return studentFirstName; } /** * @param studentFirstName * the studentFirstName to set */ public void setStudentFirstName(String studentFirstName) { this.studentFirstName = studentFirstName; } /** * @return the studentLastName */ public String getStudentLastName() { return studentLastName; } /** * @param studentLastName * the studentLastName to set */ public void setStudentLastName(String studentLastName) { this.studentLastName = studentLastName; }
  • 3. } ------------------------------------------------------------------------------------------------------ import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; public class JTableExample extends JFrame { public JTableExample() { // headers for the table String[] columns = new String[] { "Email", "First Name", "Last Name" }; Student[] students = { new Student("S123", "sri3(AT).com", "Srinu", "Vasu"), new Student("S124", "sri4(AT).com", "Rajesh", "Kumar"), new Student("S125", "sri5(AT).com", "Kumar", "Suresh"), new Student("S126", "sri6(AT).com", "Balaji", "kumar") }; // actual data for the table in a 2d array Object[][] data = new Object[students.length][3]; for (int i = 0; i < data.length; i++) { data[i][0] = students[i].getStudentEmail(); data[i][1] = students[i].getStudentFirstName(); data[i][2] = students[i].getStudentLastName(); } // create table with data JTable table = new JTable(data, columns); // add the table to the frame this.add(new JScrollPane(table)); this.setTitle("Student Manager"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); this.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new JTableExample();
  • 4. } }); } } Student Manager Email sri3@gmail.com sri4@gmail.com sri5@gmail.com sri6@gmail com Last Name First Name Srinu Vasu Rajesh Kumar Suresh Kumar Balaji kumar Add Edit Delete Solution program import Database.DatabaseOperations; import javax.swing.*; import javax.swing.border.BevelBorder; import javax.swing.table.DefaultTableModel; import javax.xml.crypto.Data; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.sql.*; import java.util.Vector; import static java.awt.Color.*; public class K_EditUserPanel extends JFrame{ private JPanel pOuter; private CustTable table; { Vector columnNames = new Vector(); Vector data = new Vector(); try { String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String url = "jdbc:oracle:thin:HR/pmagee@localhost:1521:XE"; String userid = "system"; String password = "db08Sep95"; Class.forName( driver ); Connection connection = DriverManager.getConnection(url, userid, password); String sql = "Select * from Customer";
  • 5. Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery( sql ); ResultSetMetaData md = rs.getMetaData(); int columns = md.getColumnCount(); for (int i = 1; i <= columns; i++) { columnNames.addElement( md.getColumnName(i) ); } while (rs.next()) { Vector row = new Vector(columns); for (int i = 1; i <= columns; i++) { row.addElement( rs.getObject(i) ); } data.addElement( row ); } rs.close(); stmt.close(); connection.close(); } catch(Exception e) { System.out.println( e ); } DefaultTableModel model = new DefaultTableModel(data, columnNames) { public Class getColumnClass(int column) { for (int row = 0; row < getRowCount(); row++) { Object o = getValueAt(row, column); if (o != null) { return o.getClass();
  • 6. } } return Object.class; } }; JTable table = new JTable( model ); JScrollPane scrollPane = new JScrollPane( table ); getContentPane().add(scrollPane); JPanel buttonPanel = new JPanel(); getContentPane().add( buttonPanel, BorderLayout.SOUTH ); } public static void main(String[] args) { TableFromDatabase frame = new TableFromDatabase(); frame.setDefaultCloseOperation( EXIT_ON_CLOSE ); frame.pack(); frame.setVisible(true); } public K_EditUserPanel() { pOuter = new JPanel(); pOuter.setPreferredSize(new Dimension(575, 498)); pOuter.setOpaque(true); pOuter.setBackground(darkGray); pOuter.setLayout(new GridBagLayout()); } public JPanel getUserPanel() { pOuter.removeAll(); try { pOuter = updateUserPanel(pOuter); } catch(SQLException e) { System.out.println();
  • 7. } pOuter.revalidate(); pOuter.repaint(); return pOuter; } public JPanel updateUserPanel(JPanel jPanel) throws SQLException { jPanel.removeAll(); JPanel inner = new JPanel(); inner.setPreferredSize(new Dimension(575, 498)); inner.setOpaque(true); inner.setBackground(darkGray); inner.setLayout(new GridBagLayout()); jPanel.add(inner); inner.setSize(300,300); inner.add(new JScrollPane()); inner.setVisible(true); inner.revalidate(); inner.repaint(); setSize(450,500); setVisible(true); return inner; } }