SlideShare a Scribd company logo
Objective:
Create a graphical database for a library IN JAVA. It should display the information of every
book in the library system. Each book should have the following information:
Name
Author(s)
Year published
Publisher
ISBN
Page Count
The system should be able to perform the following operations:
Display books in alphabetical order
Either all books or the books that met a search criteria noted below
Add a book
Remove a book
Search books based on
Name
Author
Year
Publisher
ISBN
Load a library database file
Save a library database file
Solution
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JFileChooser;
import javax.swing.table.DefaultTableModel;
public class Library extends javax.swing.JFrame {
public Library() {
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
table = new javax.swing.JTable();
name = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
author = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
year = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
publisher = new javax.swing.JTextField();
add = new javax.swing.JButton();
Delete = new javax.swing.JButton();
Edit = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
isbn = new javax.swing.JTextField();
Search = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
pageCount = new javax.swing.JTextField();
select = new javax.swing.JComboBox();
searchMessage = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
load = new javax.swing.JMenuItem();
save = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null}
},
new String [] {
"Name", "Author", "Year Published", "Publisher", "ISBN", "Page Count"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class,
java.lang.String.class, java.lang.Object.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, true, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(table);
jLabel1.setText("Name:");
jLabel2.setText("Author:");
jLabel3.setText("Year:");
jLabel4.setText("Publisher:");
add.setText("Add");
add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addActionPerformed(evt);
}
});
Delete.setText("Delete");
Delete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DeleteActionPerformed(evt);
}
});
Edit.setText("Edit");
Edit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
EditActionPerformed(evt);
}
});
jLabel5.setText("ISBN:");
Search.setText("Search");
Search.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SearchActionPerformed(evt);
}
});
jLabel6.setText("Page Count:");
select.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Name", "Author",
"Year", "Publisher", "ISBN" }));
searchMessage.setText(" ");
jMenu1.setText("File");
load.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
java.awt.event.InputEvent.CTRL_MASK));
load.setText("Load Database");
load.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loadActionPerformed(evt);
}
});
jMenu1.add(load);
save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
save.setText("Save Database");
save.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveActionPerformed(evt);
}
});
jMenu1.add(save);
jMenuBar1.add(jMenu1);
jMenu2.setText("Help");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(publisher, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(isbn, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(212, 212, 212)
.addComponent(add)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Delete)
.addGap(18, 18, 18)
.addComponent(Edit)
.addGap(18, 18, 18)
.addComponent(select, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(Search)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30,
Short.MAX_VALUE)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pageCount, javax.swing.GroupLayout.PREFERRED_SIZE, 84,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(searchMessage, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 914, Short.MAX_VALUE))
.addContainerGap(32, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(searchMessage)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(publisher, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(isbn, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(pageCount, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Delete)
.addComponent(Edit)
.addComponent(select, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Search)
.addComponent(add))
.addGap(25, 25, 25))
);
pack();
}
private void addActionPerformed(java.awt.event.ActionEvent evt) {
if(table.getRowCount() == i)
{
DefaultTableModel dtm = (DefaultTableModel) table.getModel();
dtm.addRow(new Object[]{"","","","","",""});
}
table.setValueAt(name.getText(), i, 0 );
table.setValueAt(author.getText(), i, 1 );
table.setValueAt(year.getText(), i, 2 );
table.setValueAt(publisher.getText(), i, 3 );
table.setValueAt(isbn.getText(), i, 4 );
table.setValueAt(pageCount.getText(), i, 5 );
i++;
}
private void DeleteActionPerformed(java.awt.event.ActionEvent evt) {
for(int j=0;j

More Related Content

PDF
Functional Java 8 in everyday life
PDF
Java Collections Tutorials
PPTX
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
DOCX
in java(netbeans) create a javaFX GUI that can open and display the co.docx
PDF
Important java programs(collection+file)
PPTX
Java Swing Presentation made by aarav patel
PPT
Java
Functional Java 8 in everyday life
Java Collections Tutorials
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
in java(netbeans) create a javaFX GUI that can open and display the co.docx
Important java programs(collection+file)
Java Swing Presentation made by aarav patel
Java

Similar to ObjectiveCreate a graphical database for a library IN JAVA. It sh.pdf (20)

PPTX
Unit 4_1.pptx JDBC AND GUI FOR CLIENT SERVER
PDF
JavaParser - A tool to generate, analyze and refactor Java code
PDF
A Scala tutorial
PPSX
Java session4
PPT
Bean Intro
PDF
The Django Book chapter 5 Models
DOC
CS2309 JAVA LAB MANUAL
PDF
DSJ_Unit III.pdf
PPTX
Java swing
PDF
import javaawt import javaxswing import javaxswing.pdf
PDF
ODP
PDF
JUG Berlin Brandenburg: What's new in Java EE 7?
PPT
Presentation to java
PPT
Java căn bản - Chapter2
PPT
Chapter 2 - Getting Started with Java
PDF
In Java Write a GUI application to simulate writing out a check. The.pdf
PPTX
Class and Object.pptx from nit patna ece department
PDF
correct the error import javaxswingJFrame import javaxs.pdf
Unit 4_1.pptx JDBC AND GUI FOR CLIENT SERVER
JavaParser - A tool to generate, analyze and refactor Java code
A Scala tutorial
Java session4
Bean Intro
The Django Book chapter 5 Models
CS2309 JAVA LAB MANUAL
DSJ_Unit III.pdf
Java swing
import javaawt import javaxswing import javaxswing.pdf
JUG Berlin Brandenburg: What's new in Java EE 7?
Presentation to java
Java căn bản - Chapter2
Chapter 2 - Getting Started with Java
In Java Write a GUI application to simulate writing out a check. The.pdf
Class and Object.pptx from nit patna ece department
correct the error import javaxswingJFrame import javaxs.pdf
Ad

More from ezzi97 (20)

PDF
Explain why multiple processes cannot share data easilySolution.pdf
PDF
executive summary for law enforcement using dronesSolutionUse .pdf
PDF
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
PDF
create a narrative budget blueprint for a local unit of government. .pdf
PDF
define three types of kernal-mode to user mode transfersSolution.pdf
PDF
Arrange the steps of DNA replication in the order that they occur. D.pdf
PDF
C++You will design a program to play a simplified version of war, .pdf
PDF
(c) After conducting several measurements, the Beijing Municipal Env.pdf
PDF
1. Which of the following statements would correctly print out t.pdf
PDF
2.How important is it to involve physicians in financial improvement.pdf
PDF
Write one page essay to explain how you relate signals and systems t.pdf
PDF
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
PDF
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
PDF
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
PDF
Who are stakeholders Define who they are and then please share what.pdf
PDF
What was the biggest problem with the Articles of Confederation They.pdf
PDF
What is UWIN and what does it doSolutionUWin is a software .pdf
PDF
What sort of archaeological remains have been discovered on the site.pdf
PDF
Link to assignment that I need help with is below httpweb.cse..pdf
PDF
The Food Stamp Program is Americas first line of defense against hu.pdf
Explain why multiple processes cannot share data easilySolution.pdf
executive summary for law enforcement using dronesSolutionUse .pdf
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
create a narrative budget blueprint for a local unit of government. .pdf
define three types of kernal-mode to user mode transfersSolution.pdf
Arrange the steps of DNA replication in the order that they occur. D.pdf
C++You will design a program to play a simplified version of war, .pdf
(c) After conducting several measurements, the Beijing Municipal Env.pdf
1. Which of the following statements would correctly print out t.pdf
2.How important is it to involve physicians in financial improvement.pdf
Write one page essay to explain how you relate signals and systems t.pdf
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
Who are stakeholders Define who they are and then please share what.pdf
What was the biggest problem with the Articles of Confederation They.pdf
What is UWIN and what does it doSolutionUWin is a software .pdf
What sort of archaeological remains have been discovered on the site.pdf
Link to assignment that I need help with is below httpweb.cse..pdf
The Food Stamp Program is Americas first line of defense against hu.pdf
Ad

Recently uploaded (20)

PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Pharma ospi slides which help in ospi learning
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
master seminar digital applications in india
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
RMMM.pdf make it easy to upload and study
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
GDM (1) (1).pptx small presentation for students
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pharma ospi slides which help in ospi learning
Anesthesia in Laparoscopic Surgery in India
102 student loan defaulters named and shamed – Is someone you know on the list?
Institutional Correction lecture only . . .
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
O7-L3 Supply Chain Operations - ICLT Program
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
master seminar digital applications in india
A systematic review of self-coping strategies used by university students to ...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
human mycosis Human fungal infections are called human mycosis..pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
RMMM.pdf make it easy to upload and study

ObjectiveCreate a graphical database for a library IN JAVA. It sh.pdf

  • 1. Objective: Create a graphical database for a library IN JAVA. It should display the information of every book in the library system. Each book should have the following information: Name Author(s) Year published Publisher ISBN Page Count The system should be able to perform the following operations: Display books in alphabetical order Either all books or the books that met a search criteria noted below Add a book Remove a book Search books based on Name Author Year Publisher ISBN Load a library database file Save a library database file Solution import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import javax.swing.JFileChooser; import javax.swing.table.DefaultTableModel; public class Library extends javax.swing.JFrame {
  • 2. public Library() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); name = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); author = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); year = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); publisher = new javax.swing.JTextField(); add = new javax.swing.JButton(); Delete = new javax.swing.JButton(); Edit = new javax.swing.JButton(); jLabel5 = new javax.swing.JLabel(); isbn = new javax.swing.JTextField(); Search = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); pageCount = new javax.swing.JTextField(); select = new javax.swing.JComboBox(); searchMessage = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); load = new javax.swing.JMenuItem(); save = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); table.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null, null}, {null, null, null, null, null, null},
  • 3. {null, null, null, null, null, null}, {null, null, null, null, null, null} }, new String [] { "Name", "Author", "Year Published", "Publisher", "ISBN", "Page Count" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class }; boolean[] canEdit = new boolean [] { false, false, false, false, true, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jScrollPane1.setViewportView(table); jLabel1.setText("Name:"); jLabel2.setText("Author:"); jLabel3.setText("Year:"); jLabel4.setText("Publisher:"); add.setText("Add"); add.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addActionPerformed(evt); } }); Delete.setText("Delete"); Delete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteActionPerformed(evt);
  • 4. } }); Edit.setText("Edit"); Edit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditActionPerformed(evt); } }); jLabel5.setText("ISBN:"); Search.setText("Search"); Search.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SearchActionPerformed(evt); } }); jLabel6.setText("Page Count:"); select.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Name", "Author", "Year", "Publisher", "ISBN" })); searchMessage.setText(" "); jMenu1.setText("File"); load.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); load.setText("Load Database"); load.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { loadActionPerformed(evt); } }); jMenu1.add(load); save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); save.setText("Save Database"); save.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveActionPerformed(evt); }
  • 5. }); jMenu1.add(save); jMenuBar1.add(jMenu1); jMenu2.setText("Help"); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(18, 18, 18) .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel3) .addGap(18, 18, 18) .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel4) .addGap(18, 18, 18) .addComponent(publisher, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel5) .addGap(18, 18, 18)
  • 6. .addComponent(isbn, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(212, 212, 212) .addComponent(add) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(Delete) .addGap(18, 18, 18) .addComponent(Edit) .addGap(18, 18, 18) .addComponent(select, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(Search))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pageCount, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18)) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(searchMessage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 914, Short.MAX_VALUE)) .addContainerGap(32, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(27, 27, 27) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113,
  • 7. javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(27, 27, 27) .addComponent(searchMessage) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1) .addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(publisher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(isbn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addComponent(pageCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addGap(35, 35, 35) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Delete) .addComponent(Edit) .addComponent(select, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Search) .addComponent(add)) .addGap(25, 25, 25)) ); pack(); } private void addActionPerformed(java.awt.event.ActionEvent evt) {
  • 8. if(table.getRowCount() == i) { DefaultTableModel dtm = (DefaultTableModel) table.getModel(); dtm.addRow(new Object[]{"","","","","",""}); } table.setValueAt(name.getText(), i, 0 ); table.setValueAt(author.getText(), i, 1 ); table.setValueAt(year.getText(), i, 2 ); table.setValueAt(publisher.getText(), i, 3 ); table.setValueAt(isbn.getText(), i, 4 ); table.setValueAt(pageCount.getText(), i, 5 ); i++; } private void DeleteActionPerformed(java.awt.event.ActionEvent evt) { for(int j=0;j