Loading

CD Rental Colasaw

Submitted by: 
Language: 
Visitors have accessed this post 8974 times.


  1. import javax.swing.*;
  2. import java.awt.event.*;
  3. import java.awt.*;
  4. import java.text.*;
  5. import java.util.*;
  6. import java.io.*;
  7. import java.io.BufferedReader;
  8. import java.lang.*;
  9.  
  10. public class CDGui extends JFrame{
  11.  
  12. private JTextField txtCDNo, txtCDTitle, txtCDArtist, txtCDType, txtCDStatus;
  13. private JLabel CDNo, CDTitle, CDType, CDStatus, CDArtist, lblTitle;
  14. private JButton btnNew,btnSave,btnSearch,btnClose, btnDelete;
  15. private BufferedReader br;
  16. private FileReader frs;
  17.  
  18. String DataFile="CDData.txt";
  19. CD CDRecord=new CD(DataFile);
  20.  
  21.  
  22.  
  23.  
  24.  
  25. //===================
  26.  
  27. public CDGui()
  28. {
  29.  
  30.  
  31. super("GUI CD");
  32. Container CDCont = getContentPane();
  33. CDCont.setLayout(null);
  34.  
  35.  
  36. lblTitle = new JLabel ("CD REGISTRATION");
  37. CDNo = new JLabel("CD No:");
  38. CDTitle = new JLabel("Title:");
  39. CDArtist = new JLabel ("Artist:");
  40. CDType = new JLabel("Type:");
  41. CDStatus = new JLabel("Status:");
  42.  
  43. txtCDNo = new JTextField(10);
  44. txtCDTitle = new JTextField(10);
  45. txtCDArtist = new JTextField(10);
  46. txtCDType = new JTextField(10);
  47. txtCDStatus = new JTextField(10);
  48. txtCDNo.setEditable(false);
  49.  
  50. txtCDStatus.setText("available");
  51.  
  52.  
  53. btnSave = new JButton("Save");
  54. btnNew = new JButton("New");
  55. btnSearch = new JButton("Search");
  56. btnDelete = new JButton("Delete");
  57. btnClose = new JButton("Close");
  58.  
  59.  
  60. CDCont.add(lblTitle); lblTitle.setBounds(150,10,200,30);
  61. CDCont.add(CDNo); CDNo.setBounds(20,50,50,30);
  62. CDCont.add(txtCDNo); txtCDNo.setBounds(70,50,100,30);
  63. CDCont.add(CDTitle); CDTitle.setBounds(20,90,100,30);
  64. CDCont.add(txtCDTitle);txtCDTitle.setBounds(70,90,300,30);
  65. CDCont.add(CDArtist); CDArtist.setBounds(20,130,100,30);
  66. CDCont.add(txtCDArtist);txtCDArtist.setBounds(70,130,300,30);
  67. CDCont.add(CDType); CDType.setBounds(20,170,100,30);
  68. CDCont.add(txtCDType);txtCDType.setBounds(70,170,300,30);
  69. CDCont.add(CDStatus);CDStatus.setBounds(20,210,100,30);
  70. CDCont.add(txtCDStatus);txtCDStatus.setBounds(70,210,300,30);
  71.  
  72.  
  73. CDCont.add(btnNew); btnNew.setBounds(5,270, 70, 30);
  74. CDCont.add(btnSave); btnSave.setBounds(80,270, 70, 30);
  75. CDCont.add(btnSearch); btnSearch.setBounds(155,270, 80, 30);
  76. CDCont.add(btnDelete); btnDelete.setBounds(240,270, 70, 30);
  77. CDCont.add(btnClose); btnClose.setBounds(315,270, 70, 30);
  78.  
  79. btnSave.addActionListener ( new ActionListener()
  80. {public void actionPerformed(ActionEvent e)
  81. {
  82.  
  83. CDRecord.setCDNumber(txtCDNo.getText());
  84. CDRecord.setCDTitle(txtCDTitle.getText());
  85. CDRecord.setCDArtist(txtCDArtist.getText());
  86. CDRecord.setCDType(txtCDType.getText());
  87. CDRecord.setCDStatus(txtCDStatus.getText());
  88. CDRecord.Save();
  89. JOptionPane.showMessageDialog(null,"Current Cd Record is Already Saved!!");} });
  90.  
  91. btnNew.addActionListener ( new ActionListener()
  92. {public void actionPerformed(ActionEvent e)
  93. { txtCDNo.setText(CDRecord.GetNew_CDNumber());
  94. txtCDTitle.setText("");
  95. txtCDArtist.setText("");
  96. txtCDType.setText("");
  97. txtCDStatus.setText("available");}} );
  98.  
  99. btnSearch.addActionListener ( new ActionListener()
  100. { public void actionPerformed(ActionEvent e)
  101. { String CDNumber= JOptionPane.showInputDialog("Input Cd Number to Search:");
  102. txtCDNo.setText(CDNumber);
  103. CDRecord.Search(CDNumber);
  104. txtCDNo.setText(CDRecord.getCDNumber());
  105. txtCDTitle.setText(CDRecord.getCDTitle());
  106. txtCDArtist.setText(CDRecord.getCDArtist());
  107. txtCDType.setText(CDRecord.getCDType());
  108. txtCDStatus.setText(CDRecord.getCDStatus());
  109.  
  110. if (Integer.parseInt(txtCDNo.getText())==0)
  111. { txtCDNo.setText(" ");
  112. JOptionPane.showMessageDialog(null,"Cd Record Not Found!!!");} }} );
  113.  
  114.  
  115. btnDelete.addActionListener ( new ActionListener()
  116. { public void actionPerformed(ActionEvent e)
  117. { String CDNumber= JOptionPane.showInputDialog("Input Cd Number to Remove:");
  118. txtCDNo.setText(CDNumber);
  119. CDRecord.Search(CDNumber);
  120. txtCDNo.setText(CDRecord.getCDNumber());
  121. txtCDTitle.setText(CDRecord.getCDTitle());
  122. txtCDArtist.setText(CDRecord.getCDArtist());
  123. txtCDType.setText(CDRecord.getCDType());
  124. txtCDStatus.setText(CDRecord.getCDStatus());
  125.  
  126. if (Integer.parseInt(txtCDNo.getText())==0)
  127. { txtCDNo.setText(" ");
  128. txtCDStatus.setText("available");
  129. JOptionPane.showMessageDialog(null,"Cd Record Not Found!!!");}
  130. else
  131. { CDRecord.Remove(CDNumber);
  132. JOptionPane.showMessageDialog(null,"Selected Cd Record is already Removed!!!");
  133. txtCDNo.setText("");
  134. txtCDTitle.setText("");
  135. txtCDArtist.setText("");
  136. txtCDType.setText("");
  137. txtCDStatus.setText("available");;
  138. } }} );
  139.  
  140. btnClose.addActionListener ( new ActionListener()
  141. {public void actionPerformed(ActionEvent e)
  142. {
  143. setVisible(false);
  144. MenuGui app = new MenuGui();
  145. app.setResizable(true);
  146. app.setLocation(410,200);
  147. }} );
  148.  
  149.  
  150. setSize(400,350);
  151. show();
  152. }
  153.  
  154.  
  155. }



Tags: 

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.

Comments

tnx,,,,

ngekz..! why empty pag extract q!

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.