You are on page 1of 57

Q Search

Downloa

import the packages for using the classes in thes inio the progrom

import java.awt.ovent.Actionl istener

import java sql.Connection

import java sql DriverManager

import java. sql.PreparedStatement

public class AddBooks extends JInternmalFrame

for creating the North Punel

privatc JP'anel northPanel new JPancl)

for creaing the North Label

private JLabel northlabel new JLabel"BOOK INFORMATION"

for creating the Center Panel

private JPanel centerPanel new JPanel

for creating an Internal Panel in the center panel

private JPanel informationLabelPanel new JPanelO

for creating an array of JLabel

private JLabell] informationL abel - new JLabel 10

private JLabel lblShelNo new JLabel(" Shelf No")

private JTextField txtshelfNo new JTexlFieldo

for creating an array of String

private String[] İnbmalonSt ring-;

Prepared by Samiha Antara d Hiha Fathima.Ca XI-X

The book subject: "" The book title

e Authon s): "

The name of the Publisher"

The number of Pages

apyright for the book "The cdition number

ISBN for the book . " The mumber copics


dition number: "

er of copics. " " The namo of the Library "

ling an Internal Panel in the center panel

ancl informationTex FieldPanel new JPanc)

private JPancl informationl

or creating an array of ITextField

pritate JTexaFieldl) information TexiField -new JTe

for creating an Intcrnal Panel in the center pane

private JPanel insertlnformationButtonPancl -ne

/for creating a button

private JButton

new JTextField 10

imserlinformationButon new JButton"Insert the Infomation")

for creating South Panel

private JPanel southPanel new JPanel)

if HinformationTextielil getTexi.cquast

information TexiFieldil gerfext)

datali

) else t

return false

return tnie

for setting thc array of JTextField to smpty

public void clearTextField) t

for (int i

0informationTextField.length: 4)t

information TextFieldjil setToxt (ull)

txtShelfNo setTextnull)

constructor of addBooks
public AddBooks

for setting the title for the internal frame

super(" Add Books", false, true, false, true)

/for setting the icon

setFramelcontnew ImagelecontClassl.oader getSysemResouret'Timages/ Addi6 gif)

/for getting the graphical user interface components display area

Container ep getContentPane()

Prpand by Samia Antara el. Hiba Fathina....Class XII-

Sennned h

adhng the label in the North Pan

for akling the noeth pandl to the coatainse

rad North", northPanel)x

for setting the layout

centeePancl.setl.ayout new Borderlayoul

for setting the border to the panel

centerPanelsetBondert Bordef atory crvate TdedBoket Add a mew book

fior sctting the layout

informationl abelPanel setLayout nen GiridL ayootl. t. I. I

inomationLabelPanel addk informationL abell]

new ILabelkinformatioa Stringft))

informationLabelD] setFontnew Fon Tahoma" Fomt BOLD 1

centerPanel add"West", infornationL abelPane

//for setting the layout

information TextFieldPanel sctLayoulnew GridL ayout 11, 1. 1, 1m

for (int i-0 i

informationTextField length: i)

IblShelNeo

informationLabeIPansl aldeIblShellNo

tushelfNosetFont(new Font."Tahoma.". Font i,LAIN. I)):


o setF onu new Font"Tahoma" Font BOLD. I1

centerPaneladde East", informationTextFieldP'ane!)

insertInforn

ormation ButtonPanel sctLayoutnew FlowLayout(FlowLayout.RIGHT)

n Information Buiton setFontinew Fonu"Tahoma", Font BOLD.

insert InformationButionPanel.add(insertInformationButton·

centerPancl.add South" insertinformationButtonPanely

cp add("Center", centerPanel)

southPanel setl ayoutnew FlowLayoutl Flow Layout RIGHT))

OK Burton setFon" new Font( "Tahona". Fon·BOLD, l 1))

southPanel.addtOKButton):

southPanel setBordert BorderFactory createEtchedBorder)

cp.add("South", southPanel)

insertInformation Button. addActionListenertnew ActionL istener)

public void actionPerformed( ActionEvent ae)

/for checking if there is a missing information

if (isCorrecto)

Thread runner new Thread)

public void runt)

book new Books0:

//for checking if there is no double information in the database

Q Search

nteger. parse Intrdita

ps setlnte9, Integer parseIntedatals

ps, set li,"10 Intcgerparsc Int'daigB]))

ps setString I I, datal'9])

ps.setBooleant 12. availble)

ps setlnt( 13, Integer parselnt txtShelfNo.getText)

ps exeeuteUndate)
calch Esception ex)

JOptionPane shuwMlesiige Dialog(mill、ex 'ošinngi ))

String sql- INSERT INTO Books

Subjeet. TitleAuthor Publisher.Copyright."

Edition.Pages ISBN. NumberofBooks. NumberOfAvailble Books L ibrary. Availble,SheltfNo)

VALUES(

datal9]+ availble +".ttSheliNo gelText)+y

book update(sql)

JOptionPanc showMessage Dialog(null, sql)

Scanned bu

String ISBN bok geusuNe

if (%1atal 71 equals IgnoreCasalSBN" t

String s4l--INSERT INTO Boeks

Subject. Titlc.Author Publisher Copyright

Edhtion Pages ISBN NumbsrOBooks NumberotAvailble HooksI ibrary Aailble: ShelINe)

String url jdh mysq ocalhost 3306

String dbName "ImsDb

String driver "com mysql jdbe Driver"

String user Nameroot

String password

Class forNamet"con mysql jdbc Diver'

Conneclion

con- Driver Manager getConnection "ilbc mysql:/localhost 3306 jlibraryrot "patl1

/Class forName('sun.jlbc odbc IdhcOdbe Driver")

Connoction

con-DriverManager geConnection("jdbc odbe JLibrary")

PreparedStatement ps-con prepareStatementísql)

ps setStringt1, data[O
ps.selString(2, datalI

ps selString(3, datal2))

Scanned

Download

packages for using the classes in them into the program

import javaawt.event ActionEvent

import javaawt.event ActionListener

for creating the North Panel

or creaing the North Label

private JLabel northLabel new JLabel("MEMBER INFORMATION

private JPanel centerPanel new JPanel)

/for creating an Internal Panel in the center panel

private JPanel informationLabelPanel new JPanelo

for creating an array of JLabel

privale JLabelL] informationL abel new JLabel7)

for creating an array of String

private Stringl] informaionString "Member ID: "The Password: " Rewrite the

password"

//for creating an Intemal Panel in the center panel

private JPanel informationTextFieldPanel new JPanel0

Scanned hu

Q Search

for selting the array of JTextl ield to empty

1Optonpane show Message Dialogtnul. Ths book is in the library" "Ero

JOptionPanc ERROR MESSAGE)

3 /t there is a missing data, then display Message Dialog

JoptionPanc showMessugeDialogtoull. Plerse complete the information"

"Warning JOptionPane WARNING MESSAGE

for adding the action listener for the button to dispose the frame
OK Button addActionListenerinew ActionL istener

public void actionPerformed ActionEvent ac) t

disposct)

for setting the visible to true

setVisible(true

/ishow the intemal frame

pack

Scanned hu Ca

Search

Download

/for creating an array of ITeuFielul

private JTextl ietdl information TextField new TextFieldl 5)

for creating an array of IPasswordField

private JPasswordFickll]) informationlasswordField new JPassvordFieldl 2)

for creating an Internal Panel in the center panel

private JP'anel insertinformationButtonPanel new JPaneio.

/for creating a button

private JBulton insertinformationButton new JButtont "Insert the Information)

/for creating the South Pancl

private JPanel southPanel new JPanelo

for creating a button

private JButton OK Button new JButtont"Exit"

create objects from another elasses for using them in the ActionListener

private Members mesber

/for creating an array of string to store the data

private Stringl] daia

for checking the password

public boolean isPasswordConect)

if
(informationPasswordField[0) getText) equalst informationPasswordField[ 1] getTextl)

datal 1]- informationPasswordFicld| I] getTexto

clse if

finformationPasswordField oJ getText) equalstinformationPasswordField IJ getText()

return false

Ppared by Samiha Anlara et Hiba Fathin... Clas XaI-x

Scanned hu

earch

Download

return truc

//for checking the information fron the text field

public boolean isCorrect) t

data - new Stringt&

for (int i 0, iinformation .abel length: i)

if (i0)

if ('informationTextFieldi] gefTextl) equalst

datali] - informationTextFieldlil getText)

else

return false

if (informationPasswordFicldli- 11getTextl) equalst

return false

ift , in formationText Field|-2] getTextOequals("*)

data[i-1)-

informationTextFieldli 2] getTexi)

else

return false

Preparedby Samiha Aniara d Risa Fathima --dassm-к

SCRIBD

Q Search
Download

puhlic void clearTexField

informotion TextFicldij se Textmulk

2)

InformationPasswordFiekļļi- l] setTest(nuli)

informationTextFieldli 21 setlestunull)

//constnuctor of addMembers

public AddMemberst)

for setting the title for the internal frame

supert" Add Members", false, tnue. false, true)

for setting the icon

setFramelcon(new

ImagelcontClassl oader getSystemResource"'images Add16 gif)m

for gatting the graphical user interface components display area

Container cp gelContentPanel)

for setting the layout

northPanel setLayout(new FlowLayoulFlowLayout CENTER)

/for setting the font

Prepared by Samha Antara l.nba Fathima...Class aux

Scanned h

BOLD 14):

for adding the labct to the puacl

northPanel addi northl abel))

centerPanel setL ayoult new Borderlayout))

for setting the border to the punc l

centerP ancl setBorden BorderFactory creatcTitledBordert" Add a

for setting the layout

informationLabelPanel setLayouttnew GridLayout(7, l. 1,1)).

for setting the layout


informalsonTextFieldPanel sell ayout(new CrdLayout(7 ·1 ).

for (ini-o; i , informationLabel length, i㈠ ) :

informationLabelPanel addtinformationLabelli]- new

JLabeltinfonnaionStringli])

informationl abeli stl ont new Fon

Tahoma".Font BOLD.11)

/for adding the panel to the centerPancl

contcrPancl add"West". informationL abell'anel)

for (int i o: i s informationLabel length, it)

if 111i2)

informationTextFieldPancladdlinformationPasswordFieldli- 1]

new JPasswordField( 25)

informationPasswordFickli- 11 setFont(new Font( Tahoma"

Font PLAIN. 11D

Prepared by Samuha Antara ผู ้ Miba Fatima . . .dass XI

SCRIBD

Search

Download

Texthield 35m

Tont PLAIN, 11

Toxt iokl(25)

Font PLAIN, I

centerPanel.ad d Est infonation TexlF ieldPanelh

insertinformationDuttonPanel selLayoullnew FlowLayouttFlowl ayout RIGHT)

centetPanel adde South insertinformationButtonPanel)

cp.addf Center", centerPanely

soulhPanel setLayout(new FlowLayont(Flow Layout RIGHT))

OK Button setF onttnew Font Tahoma", Fost BOLD, 11)


southP'unel add(OKButton):

southPanel.setBorder BorderFactory createEtehedBordert)

cp. addf South", southPanel)

insertinformationButton.addActionl istener(new ActionListener) t

publie void actionPerformedf(ActionEvent ae) (

Prparnd by Samiia Antara e ba Fathima.Clas 301-x

SSCRIBD @) ㄇ

Download

Q Search

Thread runner -new Thread) t

public void run) f

member new Members):

/for check ing if there is no same

information in the database

member.conacctiont"SELECT

in! ID member getIDo

if (Integer parse Int(datalO) ID)

FROM Members WHERE ID- data|0D

member updatc INSERT

INTO Members ( ID. Password-Name EMaiLMajer Expr cd ) vAL UES

/for setting the array of

else

OptionPane show MessageDialog null Member is in the Library", "Eror

JOptionPanc.ERROR MESSAGE)

Scanned hv C

SCRIBD

aA
Search

Download

iif the password is wrong

clse

JOptionPane.show MessageDiologt null. "the

rassowrd is wTong". "Emor. JOptionPane ERROR MESSAGEx

if thers is a missing data, then display Message Dialog

else

OptionPane show MessageDialoginull "Please, complete

the information", "Warming". JOptionPane WARNING MESSAGEN

public void actionPerfonmelActionEvent ac) t

disposet

for setting the visible to true

setVisiblet truek

packo

Books Jaya

Sconned h

/import the packages for using the classes in them into the program

import java.sql+

public class Books t

private Conncction connection null

private Statement statement null

private ResultSet resultSet null:

private int book ID

privatc String subject

private String title

private String author

private String publisher

private int copyright


private int edition

private int pages

private String ISBN

private int numberOfBeoks:

private int numberOfAvailble Books

private int numberOfBorrowedBooks

private String library

private hoolean availble:

private String URL "jdbe mysql/Mocalhost:3306glibrary

public Books0 i

public int getBookIDO t

return bookID

rpared by Samiha Antara d. Hids Fathima Clas I-

Sra

a Search

Do

public Sring gotSubje t)t

return stubject

public String gotilet

return titl

public String getAuthort)

return author

public String getPublisher)

return publisher

public int getCopyright) t

return copyright

public int getEdition) t

return edition
public int getPages) t

return pages

public String getlSBNO

return ISBN:

Prepared by Samina Antara Hiba Fatkima....Cass X

Downloa

public int getNumber)hookso t

return numburDfBooks

public int getNumberofAvailbleBooks)

seturn numberOfAvailble Books

public int getNumberOfBorrowedBooks)t

return numbeiOfBonrowedBooks:

public String getLibrary)

return library

public boolean getAvailble)

return availbl

public void connectiont String Query) t

try

Class. forNamel"com.mysql.jdbc Driver")

catch (ClassNotFoundException enfe) (

System.out printin"Books.java n" +cnfe.toString)

catch (Exception e)

System.out printin("Books.javain" c.toString))

6d Fathima.

Preparuf 6y Samiha Antara

Scanned

Search

Download
iry 1

connection DriverManager gett

resuliSet statement.eseculeQuerytQuery h

while (resultSet.next

bookID resuliSet getInll

subject resultSet getString(2

title - resuliSet get Stringl3)

publisher resullSet getStringl 5)

copyright resultSet getint6)

edition resultSet getint7)

pagcs resultSet.getinl)

ISHN resultSet.geiStringt9

numberOlBooks resultSet getlnic 10)

number norTow edBooks-resultSet yetlnU 1 2x

library resuliSet getString( 13)

availble resultSet getBooleant I4)

resuliSet.closet):

statement close)

connection closet):

catch (SQLException SQLe) f

Prpad by Saha Antara d iba Fathima... Class X11-x

Scanned hv

Download

System.out.printin"Booksjava n sQLc toString))

public void updatet String Query):

try l

Class for Namel"com.mysql.jdbe. Driver')

catch (Class NotFoundException enfe) t

System.out.println"Books java n" + enfe.toString())


catch (Exception e)t

System out.println"Books java n

e toString):

try

/connection DriverManager.getConnection( jdbe odbc:JLibrary2")

connection DriverManager getConnection( URL, "root" "pat 23")

statement connection createStatement)

statement.executeUpdalc(Query):

statement.close)

connection.close():

catch (SQLException SQLe)t

System.out.println( Books java nError:"+ SQLe.toSiring():

Scanned hv am

Q Search

Horrow.iaa

import the packages for using the classes in them into the program

import java.sql."

publie class Bosrow

prwate Connection connection null

private Statement statement null

private ResultSet resuliSet- nul

private int bookID

private Date dayOfBorrowed

private Date dayOfReturn

prvate String URL "jdbe: mysql:/localhost:3306 jlibrary"

publie Borrow

public int getBookIDO t

return bookID

public int getMemberlDO


return memberlD

public Date getDayOBorrowed)

return dayOfBorrowed

public Date getDayOfRctumo

Download

try t

Class for Namnet"com.mysql jdbe Driver

System.out printint"Berow java n" + enfe t

eatch tException et

System.out printin Borow java n"+ e toString

try t

connection-Driver Manager getC

statement connection createStatementO

resuliSct statement.executeQuery("SELECT FROM Borrow"):

while (resultSet.next) t

bookID resultSet getlnti I)

memberlD resuliSet getlnt(2)

dayOfBorrowed resultSel.getDate 3)

dayOfReturn resuliSet getDate(4)x

resultSet.closet)

statement.closc)

Scanned hy

2 Search

Download

catch (SOLException SOLc) I

System out printin "Boow java n

SQLe toStringt)

public void update( String Query) t

try
Class forNamel"com.mysql jdhe Driver")

catch (ClassNotFoundException cnfe)

System out printlnt"Bornow java'n + enfe toStringo)

catch (Exception c)

System.out.primtin Bonow java n" c toStringo)

connection DriverManager getC onnection(URL "root" "pal123"

statement connection createStatement

statement executeU pdate(Query)

statement.close():

connection closc):

catch (SQLException SQLe)t

System.out printin"Borow.java n"+sQLe.toStringo)

Prpad by Sama Antara l fiba Fathima... .Clas XII-K

Scanned hu (

Q Search

Download

puhlic class login extends javax wing IFrame t

public logino t

initComponenis)

Suppress Warnings "unchecked")

/editor-fold defaultstate "colbpsed dess enetated Cade GEN

BEGIN initComponents

ptivate voolini!Components() เ

jLabel2 new javax. swing JLabel

jTextFieldl new javax swing JTextFicldt)

jButtonInew javax swing JHutton

jPasswordFkld new javax swing JPusswordFieldo)

efaultC loscOperationjavax swing WindowConstants.EXIT ON CLOSE)

setTitlel"LOGIN):
jLabell setText USERNAME

jL abel2 setTex"PASSWORD

jTexFieldl addActionL istcnertnew javaawt.cvent Action istencr) t

publie void actionP'crformedjava.awt.event.ActionEvent evt)

Scanned h

Download

jButlonl setTes LOGIN

Buttonl addActionl istenertnew java awi.event Acuonl istencr)t

public void actionPerformed java.awt event ActionEvent evt)

was swing tinitiplayout layout-new max swing Group Layounget onlcnt Pango》

getContentP anc) setlayoutlayout):

layout setHorizontalCroupt

layout crcateParalleliroup(javax swing GroupL ayout Alignment LEADING)

ad dGroupt layout creatc SequentialGroup)

addGroupt layout createParallelGroupjav as swing GroupLayout Alignment LEADING

addGroup(layout createSequentialiroupl)

addCap/78, 78, 78)

.addGrouptlayout create Paralle kGaroupjav.ax.swing CiroupLayout.Alignment.LEADING, false)

javax.swing GroupLayout DEFAULT SIZE, Short MAX VALUE)

javax swing GroupL ayout DEFAULT_SIZE, Short MAX VALUE)

addComponentGLabel2. javas.swing Grouplayout DEFAULT SIZE

addComponenitcjLabel I javax.swing GroupLayout DEFAULT sız

SIZE

addGroupflayout createP'aralelGroupljavax.swing Groupl ayout Alignment LEADING.

Prpard by Samina Antara dMiba Fathima...Class X

xii-x

Scanned hv

Download
addC emponeauTestFieldl javax.swing GroupLayout DEFN

DEFAULT SIZE 124

addGrouptlayoutl.createSequentialoroupt)

addoapt 1 36, 136, 136)

addComponeniButton!

jav as swing GroupL ayOuL PREFERRED SIZE)

Groupl ayot PREFERRED SIZE, 9

avax swing

layout setVorticaliroup

layout createParalleliroupejavas swing Groupl ayout Alignment LEADING)

addGrouptlayout createSequentialGroup

auklGapt 115, 113, 115

addirouptlayout createParalle lGrouptjavax swing GiroupLayout Alignment BASEI

javax swing GroupLayout PREFERRED SIZE)

javax. swing GiroupLayout DEFAULT SIZE, javas. swing GroupLayo

addComponentGLabell, javax swing GroupLayout PREFERRED

F. 25

addCo

componeniTextFieldI, javax swing GroupLayout PREFERRED SIZE

ut PREFERRED SIZED

addCiapt 1 8. 18, 18)

addCiroup layout crealcParalleliroup(javax.swing GrouplLayouL Alignment LEADING)

addComponent(jLabel2)

addGrouplayoul createSequentialGroup)

addComponen1(jPassword Field i .

javax swing GiroupL ayout PREFERRED SIZE javax swing Groupl ayout DEFAULT SIZE

javax swing GroupLayOUt PREFERRED SIZE)

addGap( 18, 18, 18)

Seanned hu
Download

Q Search

ompunenteiButionl)m

addc entainertiapses1, Sshort MAX VALUE

pack

elitor-fold/GEN-END InlComponents

private void jTexiFieldl ActionP'erform

FIRST:evcnt TextFieldlAction

ITecrFichul ActionPerkirm djn a awi event ActionE vent evt

ctionPerformed

/TODO add your handhng cods here

GEN-LAST:event jTexiFicldi Action

Performed

FIRST evenl jButonl ActionPerformed

utton lActionPerformed java.awt event ActionEvent ev) UiGEN

Il gctText) equols"admin") && jPasswordFieldl getText) equalst"admin"

캐 ew Maln(this);

i setVisiblettruc)

EventQueuc invokeL atertnew Maintnew JL ibraryOn

V/GEN-LAST event jButtonl Actionl'erformed

public static void main String args)

Iry

for (javax swing UIManuger LookAndFcellnfo info

javax swing UIManager getInstalledL.ookAndFeels)

if ("Nimbus"equalstinfo getNamc)) t

javax. swing UIManager.setl.ookAndF cellinfo getClassName)

Prepand by Samiha Antara l Hiba Fathima....Class X11-X

Scanned
Search

Download

null ex)

null, ex)

java ntil logging Logger getloggert login class getNamet) logtjava util.l

null, ex)

1 catch (Gav ax.swing Unsupportell.ook AndFeelF xception ex) B

java util logging Logger getloggerlogin clss getNamst) Lbgtjava util loging Level SEVERE

null, ex)

cieditor-fold-

* Create and display the form

java awt.EventQucue invokelaterinew Rumnable)

public void run)t

now login() setVisiblet true

Sranned hv

Downlo

Q Search

s delaration do rot modify GEN BEGIN o

private jva

private

private javasx.swing JLabel jLab:l2

private javax.swing JPassw ordFicld jPasswordFieldi

private javax swing Il extf icld jTextField

End of variables dec laration GEN-END:vanables

MainJava

umgort the packages fot using the classes in them into the program

import java awt EventQueuc

import java awt Frame

import javax swing JDialog


public class Main implements Runnable j

public Maun Frame i ratne) ;

this frame frame

public void runt)

frame show

public static void maint Stringt] args)

JDialog setDe faultl ookAndFeelDecoratedí truc)

Prapand by Samiha Antara d. Wiba FathimaCla xr-x

Sca

Downloa

Q Search

Throw a niec little title puge up on the screen lirst

nety Splash0 show Splash 3000)

new login) setVisible(truc

EventQueue invoke Laterfnew Maintnew JLibrary)

Members.iav

import the packages for using the classes in them into the program

import java.sql ":

public class Members t

private Connection connection - null

private Statement slatement nulb

private ResuliSet resultSet nulb

private int memberlD

private int ID

private String password

private String name

private String email

private String major

private int numberOfBooks


private int mony

private Date expired;

private String URL "jdbe mysql:ilocalhost 3306 jlibrary".

public Members)

Prepared by Samiha Antars &Hiba Fathima... Clas XI-K

Scanne

Download

String major

snt ID, String password, String nomme. String email

int numberOlBooks, iunt mony. Dale sxp

red) 1

this memberID memberlD

this ID- ID

this password- password:

this name- name;

this email cmail:

this major-major

this.numberOflBooks- numberOfBooks

this mony mony

this.cspired expired

l-

public im getMemberlDO

return memberID

publie int getIDO

retum ID

public String getPasswordo

return password

public Siring gelNamet) t

rel
um name

Prepard Sy Samiha Aniara d Hiba Fathims...Class 201-X

Scanned

Search

Download

public String getEmailt) t

relurn email

public String getMajort) t

returm major

public int geNumberOlBooks)

return nunberOfBooks

public int getMonyO

return mony:

public Date getExpired)

return expired

public void connectiont String Query)

try

Class forNamel"com.mysql jdbe Driver"

catch (ClassNotFoundException cnfe)

System.out.println("Mcmbers java'n" cnfe lo String

catch (Exception c)

System.out prinin"Membersjavain" + c.to String):

Papared by Samia Antar d Hiba Fathim.. .Class -X

Scanned h

aW

Search

Download

URI "

roor pat 123")


connecti

statement

resultSet statement cxccuteQuery(Query )

while (result Set nextt

on -DriverManager.gctC onnectiont

memberlD resultSet getlnt T

ID resuliSet.getInt(2):

password resulitSet getStringi 3)

name - resultSet geiString()

email resuliSet.getSiring(5):

major = resultSet gctStringi

numberO1Books resulkSet getintt 7):

mony resuliSct.getint(8):

expired resultSet getDate(9)%

resultSet.close)

stalement close)

connection close()

catch (SQLException SQLe)

System.out printin"Members.java'n" SQLc loString)

Prepared by Semha Antara dHiba Fathim....Class aI-x

Scanned hu (

Download

public void updatet String Query)

try t

Claes ferNunet-corn. mysq.jdbc Driver"

catch (ClassNotFoundException enfe) f

System out printlnl"Memhersjava'n" enfe toString

catch (Exception

System out printlni Members java'n" c toString))


try t

connection DriverManuger geiConnection URL"roui1)

statement connection createStatement()

statement exccuteUpdatet Query)

statement.closel)

connection close(

catch (SQLException SOLe)

System out, printin("Membersjava n" SOLe.loString)

Snlash.jaya

Wimport the packages for using the classes in them into the program

import javax. swing

Prepand by Samia Antant d. ha Fathima....Clats X1-x

SCRIBD

Q Search

Downlo

import lavu a xt

public class Splash

A simple ltle method to show a title screcn in the

// eenter of the screen for a given

public void show Splasht int duration)

JWindow splash new JWindow r

anel content (UPanel) splash getContentl'anet

W set the window's bounds, centering the window

int width-354

int height 268

Dimension screen Toolkit getDefaultToolkit) getScreenSize)

int x iscreen.width width) /2

int y (screen height - height) 2

splash.setBoundsix y, width, heighi)


// build the splash screen

JLabel label new JLabel(new

ImagelcontC lassl oader getSystemResourcf"images'splash JPG"m

JLabel copyrt-new JLabeJLabel CENTER)

copyrl sctFontnew Font "Tahoma". Font BOLD, 10w

/copyrt setBordert BorderF actory createEtchedBorderf)

content setBackground Color LIGHT GRAY

/content setBack groundf new Colort232, 232,228)

content.add(label. BorderLayout CENTER)

content.addf(copyrt, BorderLayout.SOUTH):

nt setBordertBorderFactory createL ine BorderntColor BLACK, 2)

Prepared Sy Samifia Antara 幌 Hisd Fathina-..dass XII-1

Srann

Download

display it

splash.setVesablet truek

Wait a lile while, maybe while loading resources

Thread sleept duration):

1 catch (Exception e) t

splash setVisiblet false

import the packages for using the classes in them into the program

import java.awLevent KeyEvent

import javay management.JMException

public class Menuhar extends JMcnuBar

for creating the JMenu for the program

public JMenu filk:Menu, bookMenu, memberMenu, searelhMenu. loanMenu, reservekt

helpMenu

//for creating the JMenultem for JMenu


public JMenultem priniBook. exit, addBook. listBook, listA vailble Book

public JMenultem edi Book, removeBook, bookInformation, addMember. list Member

public JMenultem removeMember, memberinformation, scarchBooks AndMembers.

list BorrowedBook

borrowBook, returnBook

Prepared by Samiha Antara d. iha Fethima. Clas XI-x

Scanned bu

Downloa

Q Search

nswelbiooks.reservotlook, help aho

publie ImagelcontI cos

public

images/Helpl6 gif, "images About 16.gi

public Menubar t

for adding book, member, search, loan&help Menus to the menu har

this addi filc Menu new JMenul" File)):

this add(bookMenu new JMenut"Books))

this add memberMenu new IMenu(" Members"))

this add searchMenu new JMenu("Search")

this.add(loan Menu new JMenut"Loan)):

this add reserveMenu new JMenu" Reserve")

this add(belpMenu new JMemot"Help")

fileMenu setMnemonicr)

book Menu setMnemonict'b')

memberMenu.setMnemonic('m'):

searchMenu setMncmonict's)

loanMenu.setMnemonic();

Prrpand ty Samha Antara e.niba Fathima... Class X71-X

Scanned 1
Download

Q Search

rserveMenu.setMnemonict'r

helpMcnu.setMnemoniceh

for setting the image icons

icons new Imagelcon 12)

for (int i0: I imageName l6 length:i-

iconsli] new ImagelcontClass Loader getsystemResouectimogeNue 16i))

for adding print books & exit

fileMcnu.adJtprinBook new JMenultemt Print Books", iconslo])

fileMenu add(exit new JMcnultem Exit",cons ))

for adding add list, listAvailble, listBorrowed. edit&remove Books and book information

to the bookMenu

hookMenu.add(addBook new JMenultem( Add Book", icons(21))

book Menu add listBook-new JMenulteml("List All Books". İconspm

bookMenu add(listAvailbleBook new JMenultem"Lst Availble Books" icons[3]m

book Menu add( listBorrowedBook new JMenuliem List Borrowed Books", iconst3]))

book Menu.addicdit Book- new JMenultem("Edit Books", icons(4]);

bookMenu addtremoveBook - new JMenulten("Renve Book", icons 5])

/bookMenu.add(bookinformation new JMenultemt Book Informatian" icons[6])

/for adding add, list, edit& remove Members and member information to the memberMenu

memberMenu. add(addMember new JMcnultent Add Member", icons(2):

memberMenu add(listMember - new JMenultem( "List All Members". iconst3])

member Menu.add(cditMember - new JMenultem("Edit Members", iconsl-4])

memberMenu.add(removeMember new JMenultem("Remove Member". icons 5D):

memberMenu.addmemberInformation- new JMenultem("Member Information".

ieons(6])

Prepared by Samihia Aniaral iba Fathima....lass Xi-X

Scanned hv
Download

/for adding ald, list & remove N

ooksAndMembors new JMcultemt"Scarch" icons17)

w a Book" icons[8)))

cturn a Book". i

anen add listksucubooks new JMenultemt Issusd book detailsicons3D

new JMenultem( Reserve n Rouk", icons| I0])

mu addtreservelBook

or adding help& about to the helpMenu

helpiMenu addholp new JMenultem"Help" icans( 10)

for setling the shortcrnt

priai Book: setAccelerator(KeyStroke get KeyStrek efkeyEveni VK P

ActionEvent(TRL MASK)).

exitsetAccelerstort KeyStroke getkeyStrokerKeyEvent. VK F

ActionEveCL ALT MASK)

searchBooksAndMembers.setAcecleratort KeyStroke getKey Strokc(KeyEvent VK S

ActionEvent.CTRIMASKİ

addBook setAccelerator KeyStroke getKcyStroko(KeyEvent. VK A

listBook setAcceleratontKeyStroke gotKey Stroke(KeyEvent VK L

cdilBook setAccelerator(KeyStroke getKey Stroke(KeyEvent VK E

remove Book sctAcceleratort KeyStroke-Ee1KcyStroke(KeyEvent VK V.

addMember sctAcceleralort KeyStroke gcikcyStroketKeyEvent VK M

ActionEvent CTRI MASK)

ActionEvent CTRL MASK))

ActionEvent CTRI MASK))

ActionEvent CTRL MASK))

ActionE venl.CTRI MASK));

Prepared y Semiha Antaraeiba Fathimd...Class Xai-x


Scanned hv a

Download

Q Search

list Member set Acceleraton KeyStnake getkcy StroketKey Eveni VN

ActionE ventCTRI MASK)

Event VK D

ActionE vent CTRI MASK)

removeMember setAcceleratort Key Stroke getkeyStroketKey Event VK, R

Acceleralor(K

ActionEvent.CTRI MASK)),

return

ActionEvenL CTRL MASK))

CTRI

MASK))

help sctAceeleratorfKeyStroke getKeyStroket "FI)

about.sctAcceleratort Key Stroke.getkeyStroket KeyEvent VK T

ActionEvent.CTRL MASK)

Prin Booksiava

import the packages for using the classes in them into the program

import jovax swing"

import java awt

import java.awt print PageFormat

import java.awt print Printable

import javo.awLprint Printer Execption

import java.sql.

import java.util String Tokenizur

import java.util Vector

Samiha Antara dha Fathima.Cla

XTI-X
Download

Search

public class Printing Bocks exiends Jlntemalh

privale Connection connection nu

private Statement statement- nulb

privale ResuliSet resuliset null

pmvate Siring URL "jdbe mysql/localhost:1306 jlibrary"

for creating the text area

privale JTextArea textArea-new JTestAreal):

for creating the vector to use it in the prinl

private Vector lines

public static final int TAB SIZE 5.

//constructor of JLibrary

public Printing Books(String query)

supert"Printing Books", false, true. false, true)

for getting the graphical user interface components display arca

Container cp gelContentPunet

for setting the font

textArea setFont(new Fontl Tahoma", Font PLAIN. 9)

/for adding the textarea to the container

cp.add(lextArea);

Class, forNamet"com.mysql jdbc.Driver")

catch (ClassNolFoundException ea)

Prparta Sy Samiha Antara Hiba Fathima....Clas Xi-x

Scanned hu

earch

LIBRARTY MANAGEMENT SISYTEM

System out println(ca toStringl:

catch (Exception )
ystcm out prinin e toString

try

connection-DriverManager gotConnection)U/RLF

stalcment connection create Statement)

n"y:

while (resultset.nestn 1

textArea append"Subjectresultset getString"Subject")+ n

Authors resultset getSuringl Author)+n"+

Copyright:"resultset.getStringl"Copyright)n

Editionresultset getštringl Editioo)+n

Library:resultset getStringt"L brary"

textArea.append

Books Information

resultset.closc )

statement.close()

connectioncloset)

Prepared by Samiha Antara dl Hidd FathiClass di-x

Downloa

Q Search

System out printin SQLc tostring0):

lor setting the visible to true

setVisible(true

to show the frame

pack)

public int print(Graphies pg. PageFormat pageFormat, int pagelndex) throws

pg translatet(int) pageFormat.getlmageableXO. int)

pageFormat getlmageableYO

int wPage (int) pageFormat getlmageable Width)

int hPage (int) pageFormat getlmageablelleight)


pg setClip(o, 0, wPage, hPage

py setColorttextArea geiBackground)

pg fillRect(0. 0, wPage, hPage

pg.setColorttextArca getForeground)

Font font textArea getFont)

pg.sctFont(font):

FontMetrics fm pg getFontMelrics)

int hLine fm.getHeighl)

if lines null)

lines getl ines(fm, wPage)

int numLines lines.size)):

Prepared by Samiha Antara &Hiba Fathima....Class 0I-X

Sranne

Download

-mull

NO SUCH PA

intx0

int linclodex linesPerPage pagelndes

while (lineIndex < lincssze0&& y < hPage);

String str (String) lincs gctilincIndes)

linelndes

return PAGE EXISTS

protected Vector getLinest FontMetrics fin, int wPage)

String text textArea.gelTexto

String prev Token

StringTokenizer st-now String Tokenizerttext, "n'r", ruc),

while (st hasMoreTokens() (

String line -st nestToken):

Prepared by Samha Antara &. Nids Fathim.ClassXI-1x


Sranned hu (

Download

continue

ore empty lines, so it's a bit tricky to get them

tline.equals && prevToken equals"n")

prev Token line

" ( line equals n" ,)

continue

Stringlokenizt st2 new String Tokenizertline. "1". true)

while (st2 hasMoreTokenst t

String token 12 nexiToken )

if ttoken equals1

int numSpoces-TAB SIZE-line2length0%

TAB SIZE

token-n":

foken

int lineLength fm siring Width(line2 + token)

if tlinelength> wPage &&linc2 length) o)

v addfline2)

line2 token trim);

continue

Scanned hv

Search

IBRARY MANAGEMENT SYSYIE

line2 +token:

v.add(line2)

return v

Download

import javas sw ing tabble. AbstractTable Mode


import java.sql

public class Result Set TableMtodel estends Abtrnct TabieMu

private Connection connection

private Statement statement

private ResuliSct resultSet

private ResultSctMetaData metaData

private int numberOtRows

keep track of database connection status

private boolean connoctedToDalabase- false

initialize resultset and obtain its meta data ohjest

determine number of rows

public ResultSetTable Model( Si İng driver. Siring uri, string query) เ|rows

SQLException, Class NotFoundException t

Class for Nameldriver); load daiahase driver class

connection DriverManager.getC onnection url,"root" "pat123"),/connect

/create Statement to query database

statement

to

database

connection.createStatement ResultSet.TYPE SCROLL INSENSITIVE

ResuliSet CONCUR READ ONLY)

connected ToDatabase te:/ update database connection status

sctQuery(query)./ sct query and exccute it

// get class that represents column type

Sranned

Download

/ ensure datahase connection is availabla

Databasc

// delermine Jova class of column


try 1

String class Name metaData getColumnC LassName(column+ 1:

return С lass forNanot className); elum Class chce hat represents

class Name

catch SQOLExceptions and ClassNotFoundExceptions

catch (Exception exeeption) t

exception priniStackTrace:

/ il problems occur above, assume tyne Objcet

return Objeet.class

get number of columns in Resuli Set

public int get ColumnCoun:0 throws lllegal State Excep"on 1

/ ensure database connection is available

if (IconnectedToDatabase) throw new IllegalStateException"Not Connected to

Dalabase")

determine number of columns

try t

returm meta Data getColumnCount(0

Scanned hu (

Download

esteh SOLEtceptions and print error miesage

eatch (SQLEsception sqlfE xception) t

sqlEtception print StuckTrace)

if problems occur above, return o I

return 0,

get name of perticu

a perticular column in ResuliSet

public String geColomaNamstini columin) hs IlegalState E seeption

ensure database connection is available

if C'connectedToDalabase) throw new IllegalStateExseption"Not Connected to


Database"

determine column name

return motaData getColumn Name(column

11

catch SOL Exceptions and print error message

catch (SOLException sqlException)

sqlException printStackTrace()

/ if problems, return cmpty string for column name

return

/ return number of rows in Resuliset

Scanned h

DT

Download

ted to

if (SeonnectelTeDatabase) throw new IlegatSt

ateExceptiond Not

W ohtain value in particular row and column

public Object getValuc Att int row, int column) throws IlegalStateException

ensure database connection is available

if ('conner tedToDalabase) throw new IllegalStoteE xceptionf Net Connes

Database)

7obtain a value at specified Resultset row and column

try t

tesuliSet absolute row + 11

retun resultSet getbjcetcolumn+ 1

/ catch SQLExceptions and print crror message

cateh (SOLException sqlException) t

sqlException priniStackTracet)

if problems, return empty string object


return

/! set new database query string

public void setQuery(String query) throws SQLException, IlgalStateE xceptiont

Praparnd Sy SamaAntara

iba Fathima... . Clas X1-X

Scanned h

Download

is auailable

specily query and exocute it

resuliset statement executeQuerytquery

eblain meta data for ResultSct

netaDala nesultSet getMetaData)

resuliSet last():/move to last row

number

fire TableStnuctureC

noify JTable that model has changed

turechangedo

close Statement and Connection

public void disconnectFromDatabase)

/close Statement and Connectiorn

try t

statement close)

connection closet)

catch SOLExceptions and print crror message

catch (SQLException sqlException)

sqlException printStackTracc)

/ update dalabase connection status

finally

mpared by Saria Antara afisa fatima .


Cass.Ui-X.

Scanned

//mlpert the packages fin using ilw elasses i" ililil İnli..

import javas swing

impost java.awt.ovent Actionl vont

import java awtevent Actionl istener

/for creating the North Panel

private JPanel northPane new Ianelh

//tor creaing the North Label

private JLabel morthLabel-new JLabel("MEMBER INI ORMATION");

/for creating the Center Panel

private JPanel center Panel new JPanel)

for creating the edit Panel

private JPanel memberlDPanel new JPanel

/for creating the edit information Panel

private JPonel memberlDInformationPanel new JPanel)

/for creating the edit label panel

private JPanel memberlDInformationl abelPanel new JPanel;

/for creating the edit textField panel

private JPanel memberlDInformation TextF ieldPanel -new JPanel)x

//for creating the edit button panel

Scann

od

Search

Download

for creating the label

private JLabel

for creating the textField

tmwemberlDL abel Label"MemberID


exiField memberiDTexiField new JTesifieldk2s)

/for ereating the button

private JButt

Tor creating the information Panl

private JPanel informationPancl new JPanel

for creating an Internal Panel in the center pame

private JPanel informationL.abelPanel-new JPanelh

//for crealing an army o Label

private JLisbell I niranatJCM1 Label-new JLubell 71:

/for creating an array of String

n menn

The Pasword

Rewrite the

private Stringll informionSiring " Member ID

password: "

The Name:E-MAIL

Major". Expired: "

for creating an Internal Panel in the center panel

private JPanel informationTextFieldPanel new JPanel)

//for creating an aray of JTextField

private JTextField[] informationTextField-new JTextFivldls)

//for creating an array of JPasswordField

private JPasswordFiekl] informationPusswordField - mew JPasswordField|21

for creating an Internal Panel in the center panci

private JPanel InformationButtonPanel new JPanelo)

Seanned h

Search

tor creatung a button

for creating the South Panel


private JP'anel southl'ancl new JPaneltx

private JButton exitButon new JBullont Exit"y

ercate objects from another classes for using them in the ActionListener

private Members member.

/for ereating an array of string to store the data

private String[] data:

for checking the password

public boolcan isl'asswordCorreet) t

tinformationPasswordFieldoL gerTest) equals(informationPasswordField !1getTetm

else if

informationPasswordFicld[0l gefTextl) equalstinformationPasswordField II getTe)m

return false

return Irue

//for checking the information from the texi field

public boolcan isComeet()

data- new Stringl6)

for ( int-0. İ

information Label length: im

if (0)

Prpard by Samiha Antara rba Fathima...Clas XTI -x

Scanned hu (

Download

dai fij information TexiFickdil getTexit

else

return false:

if (infon

returm falsc:

if linformationTexiFieldli-2l geTex) eq)

datali-11-unformationTextF ieldli 2)getfext)


else

retum false

return truc

for checking the information from the text field

public boolean isE ditCorrect) t

if (memberlDTextField getTexl) cqualst")

return false

retum true:

Scanned hv

/for sctting the array of JTestField & JPasswondField to null

public void clearTextFieldB

memberIDTesiField sctText(null

for (ini i 0: i < informationl abellength: )

if (i 0)

informationTextFicldosetText(null)

informationPasswordF ieli- 11 setTextnull)y

information TextFiekli 21 selTexttnull)

constructor of addMembers

public MembersInformation) t

/for setting the title for the internal frame

supert"Memhers Information". false, true, fals, tnie)

/for setting the icon

setFramelcon(new

ImagelcontClassLoader.getSystemResource("images/Information 6 gif)

//for getting the graphical user interface components display area

Container cp gelContentPanco

for setting the layou

northPanel setL ayout(new Flow Layoul(FlowLayouLCENTER)

//for setting the font


Frrpara by Samha Antara Hiba Fathima....Class I-x

Sranne

northl abel setl new Foni Tahona" Font OLD. 1A)

Wfor adding the label to the pancl

northPanel.adde northLabel)

for adding the panel to the container

//for setting the layout

centerP'anel setLayout(new BorderlayoulOx

/for setting the layouft

momberlDPanel setl ayoutltnew Borderl.ayout

/for setting the border to the panel

eriPanel seiBordert BorderFactery create TiakdBerder"MemberlD"

for setting the layout

memberlDInformationlanel setL ayout new BorderlLayout)

/for setting the layout

memberlDInformationl abelPanel.sctL.ayout(new GridLayoutI. I.I. I)

/for adding the label to the panel

memberlDInfarmationL abelPanel add(memberlDLabel)

//for setting the font to the label

memberlDLabel setf ont(new Fontt"Tahoma" Font BOLD, 11)

//for adding the editinformationLabellPanel to the editinformationLabel

memberlDInformationPanel.add"West", memberlDInfonnationLabelPanel)

/for setting the layout

memberiDInformationTextFieldPanel.setLayoulfnew Gridl ayout(l, 1, 1, 1))

//for adding the text Field lu te po nel

memberlDInformation TextFieldPanel add(memberiDTextFieldy

Prpared by Samiha Anlara d. Hiba Fathima...Cla I-x

Scanned hu

Download
fot setting thhe font to the tustField

emberlDTextl ield.setfFontin

teld.setFonttnew Fonll" Tahoma" Font PLAIN. II)

nformationTexiField to the cdhilnformationPancl

nformation Panel.add( East", member DinbrmationTextfFieldPanel)

/for adding the editinformation Text

for adding the editlnformation Pandl to the editPanel

inemberlDPanel add(" North". member ID Inform 10nPa

//for setting the layout

ationPanel)

memberlDBultonPanel serl ayoutnew Flow Layaut Flowl ayout RIGHT

/for adding the button to the pandel

memberIDBultlon Panel.addk memberIDButton)

or setting the fonr to the button

memberlDButton setFont new Foni"Tahoma" Font BOLD. 11

for adding the editlnformationButtonPanel to the editPancl

memberlDPanel add( Center" memberlDButtonl'anel)

/for adding the editPanel to the centerPanel

centerPaneladd"North", memberlDPanel)

for setting the layout

nformationPanel setLayout new BorderLayout)

/for setting the border to the panel

informationPanel setBordert BorderFactory create TitledBordert"Edit a member:

/for setting the layout

informationLabelPanel setlayoul(new GridLayou(7. 1. 1, 1))

//for setting the layou

informationTextFieldPanel setLayo new GrdLayout17. I. 1. i ));

Prepared by Samha Antara et Hiba Fathima....Cas X1- Commented [1]:

Download
JLabelenfomizionStringlin

informationL abelli) sctFonknew Fontt"Tahoma" Font BOLD.

for adding the panel to the centerPancl

for tini i-a: i «informationl abel length. ,++) t

informationTextFieldlanel.add informationPasswordFieldli-11

InforrnationPasswordFicklll- l] setFont(new Fonu" lahoma.

infonmationPasswordFiekji 11sctEnabled(false);

new JPassw ordFicld(25m

Font PLAIN, 11)

information TextFieldPanel addk informationTextFeld[i]

informationTextField[i] seiF ont(new Fontl"Tahoma"

informationTextFieklli setEditablet false)

new

JTextField(25))

Font PLAIN. 11))

informationTextFiekPanel add informationTextFieldi-21 new

informationTextFieldlt 2]setFonltinew Font("Tahoma"

informationTextFickfi 21.sctEditabletfalse

JTextField(25)

Font PLAIN, Ⅱ)):

Seanned hu a

Download

Search

information Panel add East" infomation TexiFicldPunel)

InformotionButtonP'anel setL ayout new FlowLayoutFlowLayout.RIGHT)

Button setl ontinew Fonte" Tahoma".Font BOLD, 11

infonnationPancL adde South", InformatienButton Panel);

centerPanel add Center", information Panel):


cp addi Center", centerPanc

southP'anel setLayoultnew Flow Layout Flow Layout.RIGHT)):

exitButton setFontínew Font" Tahoma", Font BOLD, I1)):

southPanel addtexitButton)

southPanel sctBordert BorderFactory createEtchedBorder0)

cp.addi South". southPanel)

for adding the action listener for the button to dispose the frame

exǐlBution addAction! İstenertnew Ac1ionListencr() {

public void actionPerformedt ActionEvent ac)

disposet)

1)

for setting the visible to true

setVisiblet true)

/show the internal frame

packO

Preparrd by Samha Antara et Hisa Fathim..Class XTI-X

Seanned hu Can

RemayeBooksJava

Vamport the packages for using the classes in them into the program

import javax swing

import java awt

import java awt eventActionEvent

import java awl.eveni ActionListener

/for creating the North Panel

private JPanel northPanel - new JPanelo

for creating the label

private JLabel title new JLabelt"BOOK INFORMATION")

/for creating the Center Panel

private JPanel centerPanel new JPanel)


for creating an Internal Panel in the center pane

private JPanel removePanel new JPandlo

for creating the label

private JLabel removel abel new JLabel Write the Book ID

/for creating the lext field

private JTextField removeTextField new JTexiFiceldo:

//for creating string to store the data

privale String data

/for creating an Internal Panel in the center panel

private JPanel removeMemberPanel - new JPanel)

/for crealing the buttorn

Prpared by Samiha Antara

Hiba Fathima....las XTI-x

Scam

Download

Search

private JBulton remo Buton new JButtont "Remove"l:

/for creating the South Panel

privote JPanel southl'ancl new JPanelo

/for adding the button

create objeets from another clusses for using them in the ActionL istener

private Books book:

for checking the information from the text field

public boolean isCorreci)

if (CremovcTexiF ield getText

cqualst)

data removeTextField get Text

ietum tuc

else
return falsc

/constructer of removeBooks

public RemoveBooks)

//for setting the title for the internal trame

supert Remove Books", false, true. false, true)

/for setting the icon

setFramclcon(new

ImagelcontClass Leader getSystemResourcot"images/Delete l6 gif)

/for getting the graphical user interface components display area

Prpand Sy Samiha Anters l iba Fathim.... Class 1-X

Scanned hu Carm

Downloa

Search

or setting the layout

/for setting the font

title.sctFontenew Font Tahoma". Font.BOLD, 14))

/for adding the label

northPancl.addtitle)

/lor adding the panel to the container

cp.add("North", northPanel)

//for setling the layout

centerPanel.setLayout new BorderLayout))

for setting the layout

removePanel setL ayout(new GridLayout 1. 2. 1. 1)

for adding the label

remove Panel add(removeLabel),

/for adding the text field

removel'anel addtremoveTexifField)

/for adding the internal panel to the panel


centerPanel.addl Center". removePanel):

for setting the layout

removeMemberP'anel setLayoutf new FlowLayout(FlowLayout RIGHT))

/for adding the button

removeMemberPancl.add(removeButton):

/for addint the internal panel to the center panel

ς,.smned hv (

Search

Download

centerPancl add Suuth,removeMembesPanel

for setting the border

centcrPunel sctBordertHordsrFactory create TiledBordert"Remove a book ")

for ndding the center panel to the containo

removeLahel.setFonl(new Fonit"Tahoma".Font BOLD. 11))

remove TextField setFontnew Font Tahoma". Font PLAIN, II))

eur Button sell onll new Font'-To homa", F ont 130 L D. I l ))

remơvc Bitlir1.selFo' "ew Ferm"Talloma", Font BOL D. I 1));

for setting the layout

southP'anel selLayoutacw Flow LayoutFlowLayout.RIGHT)

for adding thc butto'

southPanel addtexitBulon)

for setting the border

sothPanel selBordertBorderFactory create EtchedBorder)

for add the south panel to the container

p add South" southPanel):

removeButlon.addActionListener(new ActionL istener

publie void actionPerformedt ActionEvent ac) t

for checking if there is a missing information

Thread runner new Thread)


public void run)t

book new Books)

/for getting the information

Prpand by Samha Antara d. Hiba Fathim... Clas XAI-x

Scanned hu an

Download

beok get NumberOfBooks

if inumberOfBooks 1

book updatet DELETE

FROM Books wlIERE Book lD "" + data);

for se' 'ing Λ ext Field to null

removeTestFicld sct Textnull)

book update UPDATIE

Books SET NumberOfBooks+mumberOfBooks+" WHERE BookID

data)

for selting TextField to null

remove TextField set Text(null)

else

JOptionPane.show MessageDialoginull. "The BookID is wrong". "Error

JOptionPane ERROR MESSAGE

Search

runnet sfart

if there is a missing data, then display Message Dialog

JOptionPane show MessageDialogtnulL "Please. complete

for adding the action listener for the button to dispose the frame

cxitBution.addActionListenertnew Actionl istener)

public void actionPerformedt ActionEvent ac)

disposet

for setting the visible to truc


set Visiblet true);

Wshow the internal frame

packo

Vimport the packages for using the classes in them into the program

import javax.swing."

Prupard by SamiAars d.nhs Fathinma.. . ClauXI-

Scanned hu Ca

Download

import java.awt event Actionlistener

/for creating the North Panel

private JPanel northPanel new JPanel

for creating the label

private JLabel title new JLabel( MEMBER INFORMATION

/for creating the Center Panel

private JPanel centerPanel new JPanel)

private JPancl removePanel - new JPanelo

creating the label

private JLabel removelLabel new JLabel" Write the Member ID

private JTextField removeTextField

for crealing string to store the data

private String data

new ΛcxtField():

private JPanel removeMemberPanel new JPanel);

private JButton remov cButton

new JButt

for creating the South Panel

/for adding the button

private JButton exit Button new JButtont "Exit"x

/create objects from another classes for using them in the ActionListener
Scanne

load

Down

2 Search

private Members member

/for checking the information from the text field

public boolean isC orrect)

data removeTestField.getText)

retum true

else

return false

//constructor of removeMembers

public RemoveMembers

for setting the title for the internal frame

super"Remove Members", false, urue, false, true)

/for setting the icon

sctFramelcon(new

ImagelcontClassLoader getSystemResourcef images/ Delete16.gifm

for getling the graphical user interface components display area

Container cp - getContentPanet)

for setting the layout

northPanel sctlLayout new Flow Layout Flow Layout CENTER)

//for setting the font

title setFont(new Fontf"Tahoma", Font BOLD, 14)

//for adding the label

Scanned

Search

Download

north Panel add(titlk)


for adding the panel to the container

cp add "North", northPanel)

for setting the layout

centerPanelseLayoutnew BorderL ayout))

for sening the layout

removePanel sctLayoull new GridLayoutl 1. 2.1. ))

//for adding the lahel

removePanel addf removeL abel):

/for adding the text field

removePanel.add(removeTextFieldy

for adding the internal panel to the panel

/for setting the layout

removeMemberPanclsetL ayoult(new FlowLayout(FlowLayout RIGHTm

for adding the buton

removeMemberPanel.addtremoveButton):

/for addint the internal panel to the center panel

centerPanol.add"South", removeMemberPanel)

/for setting the border

centerPanel.setBordertBorderFactory createTaledBordert"Remove a member"

for adding the cenier panel to the conlainer

removeLabel setFont(new Fontt Tahoma". Font BOL D, 11))

removeTextFicld selFont(new Font Tahema". Foni. PLAIN, I1).

Scanned hv Cam

Q Search

for setting the layout

for setting the honlet

southlanelsetBordert BorderF actory creatcEtchedBordert)

for axld the south panel to the container

ep add "South" southPanel)


removeButton addActionListenerinew Actiontistenert) 1

public void actionPerformedl ActionE vent uc) t

for checking if there is a missing information

if (isCorree

Thread runner new Threado t

public vaid nunt) t

member new Memberso

member conncetion"SELECT FROM

Members WHERE MemberID "+ data)

for checking if the user borrowed any book

form the library

int numberOBooks-

member getNumberOnBooks)

member updatet "DELETE FROM

Members WHERE MemberlD+ data):

/for setting the ITextField to nu

Prapand by Samiha Antars

Hiba Fathina...CaXII-x

Scanned hu Cam

Download

с 156

JOptionPane show MessageDialkngin

al. Booki) borrowed hy the member", "Warning"

JOptionPane WARNING MESSAGE

if there is a missing data, then display Message Dialog

the information" "Warning" lOptionPone WARNING MESSAGEN

for adding the action listener for the button to dispose the frame

exitButton addActionL istcnert new ActionListenert)


public void actionPerformedt ActionEvent ac)

disposct):

Di

//for setting the visible to true

setVisible(truc)

show the internal frame

Scanned hv Ca

pack():

You might also like