jd0g3252
Event Loop Designer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
700 XP
- import
javax.swing.*
;
- import
java.awt.event.*
;
- import
java.awt.*
;
- import
java.text.*
;
- import
java.util.*
;
- import
java.io.*
;
- import
java.io.BufferedReader
;
- import
java.lang.*
;
- public
class
CDGui extends
JFrame
{
- private
JTextField
txtCDNo, txtCDTitle, txtCDArtist, txtCDType, txtCDStatus;
- private
JLabel
CDNo, CDTitle, CDType, CDStatus, CDArtist, lblTitle;
- private
JButton
btnNew,btnSave,btnSearch,btnClose, btnDelete;
- private
BufferedReader
br;
- private
FileReader
frs;
- String
DataFile=
"CDData.txt"
;
- CD CDRecord=
new
CD(
DataFile)
;
- //===================
- public
CDGui(
)
- {
- super
(
"GUI CD"
)
;
- Container
CDCont =
getContentPane(
)
;
- CDCont.setLayout
(
null
)
;
- lblTitle =
new
JLabel
(
"CD REGISTRATION"
)
;
- CDNo =
new
JLabel
(
"CD No:"
)
;
- CDTitle =
new
JLabel
(
"Title:"
)
;
- CDArtist =
new
JLabel
(
"Artist:"
)
;
- CDType =
new
JLabel
(
"Type:"
)
;
- CDStatus =
new
JLabel
(
"Status:"
)
;
- txtCDNo =
new
JTextField
(
10
)
;
- txtCDTitle =
new
JTextField
(
10
)
;
- txtCDArtist =
new
JTextField
(
10
)
;
- txtCDType =
new
JTextField
(
10
)
;
- txtCDStatus =
new
JTextField
(
10
)
;
- txtCDNo.setEditable
(
false
)
;
- txtCDStatus.setText
(
"available"
)
;
- btnSave =
new
JButton
(
"Save"
)
;
- btnNew =
new
JButton
(
"New"
)
;
- btnSearch =
new
JButton
(
"Search"
)
;
- btnDelete =
new
JButton
(
"Delete"
)
;
- btnClose =
new
JButton
(
"Close"
)
;
- CDCont.add
(
lblTitle)
;
lblTitle.setBounds
(
150
,10
,200
,30
)
;
- CDCont.add
(
CDNo)
;
CDNo.setBounds
(
20
,50
,50
,30
)
;
- CDCont.add
(
txtCDNo)
;
txtCDNo.setBounds
(
70
,50
,100
,30
)
;
- CDCont.add
(
CDTitle)
;
CDTitle.setBounds
(
20
,90
,100
,30
)
;
- CDCont.add
(
txtCDTitle)
;
txtCDTitle.setBounds
(
70
,90
,300
,30
)
;
- CDCont.add
(
CDArtist)
;
CDArtist.setBounds
(
20
,130
,100
,30
)
;
- CDCont.add
(
txtCDArtist)
;
txtCDArtist.setBounds
(
70
,130
,300
,30
)
;
- CDCont.add
(
CDType)
;
CDType.setBounds
(
20
,170
,100
,30
)
;
- CDCont.add
(
txtCDType)
;
txtCDType.setBounds
(
70
,170
,300
,30
)
;
- CDCont.add
(
CDStatus)
;
CDStatus.setBounds
(
20
,210
,100
,30
)
;
- CDCont.add
(
txtCDStatus)
;
txtCDStatus.setBounds
(
70
,210
,300
,30
)
;
- CDCont.add
(
btnNew)
;
btnNew.setBounds
(
5
,270
, 70
, 30
)
;
- CDCont.add
(
btnSave)
;
btnSave.setBounds
(
80
,270
, 70
, 30
)
;
- CDCont.add
(
btnSearch)
;
btnSearch.setBounds
(
155
,270
, 80
, 30
)
;
- CDCont.add
(
btnDelete)
;
btnDelete.setBounds
(
240
,270
, 70
, 30
)
;
- CDCont.add
(
btnClose)
;
btnClose.setBounds
(
315
,270
, 70
, 30
)
;
- btnSave.addActionListener
(
new
ActionListener
(
)
- {
public
void
actionPerformed(
ActionEvent
e)
- {
- CDRecord.setCDNumber
(
txtCDNo.getText
(
)
)
;
- CDRecord.setCDTitle
(
txtCDTitle.getText
(
)
)
;
- CDRecord.setCDArtist
(
txtCDArtist.getText
(
)
)
;
- CDRecord.setCDType
(
txtCDType.getText
(
)
)
;
- CDRecord.setCDStatus
(
txtCDStatus.getText
(
)
)
;
- CDRecord.Save
(
)
;
- JOptionPane
.showMessageDialog
(
null
,"Current Cd Record is Already Saved!!"
)
;
}
}
)
;
- btnNew.addActionListener
(
new
ActionListener
(
)
- {
public
void
actionPerformed(
ActionEvent
e)
- {
txtCDNo.setText
(
CDRecord.GetNew_CDNumber
(
)
)
;
- txtCDTitle.setText
(
""
)
;
- txtCDArtist.setText
(
""
)
;
- txtCDType.setText
(
""
)
;
- txtCDStatus.setText
(
"available"
)
;
}
}
)
;
- btnSearch.addActionListener
(
new
ActionListener
(
)
- {
public
void
actionPerformed(
ActionEvent
e)
- {
String
CDNumber=
JOptionPane
.showInputDialog
(
"Input Cd Number to Search:"
)
;
- txtCDNo.setText
(
CDNumber)
;
- CDRecord.Search
(
CDNumber)
;
- txtCDNo.setText
(
CDRecord.getCDNumber
(
)
)
;
- txtCDTitle.setText
(
CDRecord.getCDTitle
(
)
)
;
- txtCDArtist.setText
(
CDRecord.getCDArtist
(
)
)
;
- txtCDType.setText
(
CDRecord.getCDType
(
)
)
;
- txtCDStatus.setText
(
CDRecord.getCDStatus
(
)
)
;
- if
(
Integer
.parseInt
(
txtCDNo.getText
(
)
)
==
0
)
- {
txtCDNo.setText
(
" "
)
;
- JOptionPane
.showMessageDialog
(
null
,"Cd Record Not Found!!!"
)
;
}
}
}
)
;
- btnDelete.addActionListener
(
new
ActionListener
(
)
- {
public
void
actionPerformed(
ActionEvent
e)
- {
String
CDNumber=
JOptionPane
.showInputDialog
(
"Input Cd Number to Remove:"
)
;
- txtCDNo.setText
(
CDNumber)
;
- CDRecord.Search
(
CDNumber)
;
- txtCDNo.setText
(
CDRecord.getCDNumber
(
)
)
;
- txtCDTitle.setText
(
CDRecord.getCDTitle
(
)
)
;
- txtCDArtist.setText
(
CDRecord.getCDArtist
(
)
)
;
- txtCDType.setText
(
CDRecord.getCDType
(
)
)
;
- txtCDStatus.setText
(
CDRecord.getCDStatus
(
)
)
;
- if
(
Integer
.parseInt
(
txtCDNo.getText
(
)
)
==
0
)
- {
txtCDNo.setText
(
" "
)
;
- txtCDStatus.setText
(
"available"
)
;
- JOptionPane
.showMessageDialog
(
null
,"Cd Record Not Found!!!"
)
;
}
- else
- {
CDRecord.Remove
(
CDNumber)
;
- JOptionPane
.showMessageDialog
(
null
,"Selected Cd Record is already Removed!!!"
)
;
- txtCDNo.setText
(
""
)
;
- txtCDTitle.setText
(
""
)
;
- txtCDArtist.setText
(
""
)
;
- txtCDType.setText
(
""
)
;
- txtCDStatus.setText
(
"available"
)
;;
- }
}
}
)
;
- btnClose.addActionListener
(
new
ActionListener
(
)
- {
public
void
actionPerformed(
ActionEvent
e)
- {
- setVisible(
false
)
;
- MenuGui app =
new
MenuGui(
)
;
- app.setResizable
(
true
)
;
- app.setLocation
(
410
,200
)
;
- }
}
)
;
- setSize(
400
,350
)
;
- show(
)
;
- }
- }
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.