• We just launched and are currently in beta. Join us as we build and grow the community.

CD Rental Colasaw

jd0g3252

Event Loop Designer
J Rep
0
0
0
Rep
0
J Vouches
0
0
0
Vouches
0
Posts
170
Likes
138
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 700 XP
  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. public

    class

    CDGui extends

    JFrame

    {

  10. private

    JTextField

    txtCDNo, txtCDTitle, txtCDArtist, txtCDType, txtCDStatus;
  11. private

    JLabel

    CDNo, CDTitle, CDType, CDStatus, CDArtist, lblTitle;
  12. private

    JButton

    btnNew,btnSave,btnSearch,btnClose, btnDelete;
  13. private

    BufferedReader

    br;
  14. private

    FileReader

    frs;

  15. String

    DataFile=

    "CDData.txt"

    ;
  16. CD CDRecord=

    new

    CD(

    DataFile)

    ;





  17. //===================

  18. public

    CDGui(

    )
  19. {


  20. super

    (

    "GUI CD"

    )

    ;
  21. Container

    CDCont =

    getContentPane(

    )

    ;
  22. CDCont.setLayout

    (

    null

    )

    ;


  23. lblTitle =

    new

    JLabel

    (

    "CD REGISTRATION"

    )

    ;
  24. CDNo =

    new

    JLabel

    (

    "CD No:"

    )

    ;
  25. CDTitle =

    new

    JLabel

    (

    "Title:"

    )

    ;
  26. CDArtist =

    new

    JLabel

    (

    "Artist:"

    )

    ;
  27. CDType =

    new

    JLabel

    (

    "Type:"

    )

    ;
  28. CDStatus =

    new

    JLabel

    (

    "Status:"

    )

    ;

  29. txtCDNo =

    new

    JTextField

    (

    10

    )

    ;
  30. txtCDTitle =

    new

    JTextField

    (

    10

    )

    ;
  31. txtCDArtist =

    new

    JTextField

    (

    10

    )

    ;
  32. txtCDType =

    new

    JTextField

    (

    10

    )

    ;
  33. txtCDStatus =

    new

    JTextField

    (

    10

    )

    ;
  34. txtCDNo.setEditable

    (

    false

    )

    ;

  35. txtCDStatus.setText

    (

    "available"

    )

    ;


  36. btnSave =

    new

    JButton

    (

    "Save"

    )

    ;
  37. btnNew =

    new

    JButton

    (

    "New"

    )

    ;
  38. btnSearch =

    new

    JButton

    (

    "Search"

    )

    ;
  39. btnDelete =

    new

    JButton

    (

    "Delete"

    )

    ;
  40. btnClose =

    new

    JButton

    (

    "Close"

    )

    ;


  41. CDCont.add

    (

    lblTitle)

    ;

    lblTitle.setBounds

    (

    150

    ,10

    ,200

    ,30

    )

    ;
  42. CDCont.add

    (

    CDNo)

    ;

    CDNo.setBounds

    (

    20

    ,50

    ,50

    ,30

    )

    ;
  43. CDCont.add

    (

    txtCDNo)

    ;

    txtCDNo.setBounds

    (

    70

    ,50

    ,100

    ,30

    )

    ;
  44. CDCont.add

    (

    CDTitle)

    ;

    CDTitle.setBounds

    (

    20

    ,90

    ,100

    ,30

    )

    ;
  45. CDCont.add

    (

    txtCDTitle)

    ;

    txtCDTitle.setBounds

    (

    70

    ,90

    ,300

    ,30

    )

    ;
  46. CDCont.add

    (

    CDArtist)

    ;

    CDArtist.setBounds

    (

    20

    ,130

    ,100

    ,30

    )

    ;
  47. CDCont.add

    (

    txtCDArtist)

    ;

    txtCDArtist.setBounds

    (

    70

    ,130

    ,300

    ,30

    )

    ;
  48. CDCont.add

    (

    CDType)

    ;

    CDType.setBounds

    (

    20

    ,170

    ,100

    ,30

    )

    ;
  49. CDCont.add

    (

    txtCDType)

    ;

    txtCDType.setBounds

    (

    70

    ,170

    ,300

    ,30

    )

    ;
  50. CDCont.add

    (

    CDStatus)

    ;

    CDStatus.setBounds

    (

    20

    ,210

    ,100

    ,30

    )

    ;
  51. CDCont.add

    (

    txtCDStatus)

    ;

    txtCDStatus.setBounds

    (

    70

    ,210

    ,300

    ,30

    )

    ;


  52. CDCont.add

    (

    btnNew)

    ;

    btnNew.setBounds

    (

    5

    ,270

    , 70

    , 30

    )

    ;
  53. CDCont.add

    (

    btnSave)

    ;

    btnSave.setBounds

    (

    80

    ,270

    , 70

    , 30

    )

    ;
  54. CDCont.add

    (

    btnSearch)

    ;

    btnSearch.setBounds

    (

    155

    ,270

    , 80

    , 30

    )

    ;
  55. CDCont.add

    (

    btnDelete)

    ;

    btnDelete.setBounds

    (

    240

    ,270

    , 70

    , 30

    )

    ;
  56. CDCont.add

    (

    btnClose)

    ;

    btnClose.setBounds

    (

    315

    ,270

    , 70

    , 30

    )

    ;

  57. btnSave.addActionListener

    (

    new

    ActionListener

    (

    )
  58. {

    public

    void

    actionPerformed(

    ActionEvent

    e)
  59. {

  60. CDRecord.setCDNumber

    (

    txtCDNo.getText

    (

    )

    )

    ;
  61. CDRecord.setCDTitle

    (

    txtCDTitle.getText

    (

    )

    )

    ;
  62. CDRecord.setCDArtist

    (

    txtCDArtist.getText

    (

    )

    )

    ;
  63. CDRecord.setCDType

    (

    txtCDType.getText

    (

    )

    )

    ;
  64. CDRecord.setCDStatus

    (

    txtCDStatus.getText

    (

    )

    )

    ;
  65. CDRecord.Save

    (

    )

    ;
  66. JOptionPane

    .showMessageDialog

    (

    null

    ,"Current Cd Record is Already Saved!!"

    )

    ;

    }

    }

    )

    ;

  67. btnNew.addActionListener

    (

    new

    ActionListener

    (

    )
  68. {

    public

    void

    actionPerformed(

    ActionEvent

    e)
  69. {

    txtCDNo.setText

    (

    CDRecord.GetNew_CDNumber

    (

    )

    )

    ;
  70. txtCDTitle.setText

    (

    ""

    )

    ;
  71. txtCDArtist.setText

    (

    ""

    )

    ;
  72. txtCDType.setText

    (

    ""

    )

    ;
  73. txtCDStatus.setText

    (

    "available"

    )

    ;

    }

    }

    )

    ;

  74. btnSearch.addActionListener

    (

    new

    ActionListener

    (

    )
  75. {

    public

    void

    actionPerformed(

    ActionEvent

    e)
  76. {

    String

    CDNumber=

    JOptionPane

    .showInputDialog

    (

    "Input Cd Number to Search:"

    )

    ;
  77. txtCDNo.setText

    (

    CDNumber)

    ;
  78. CDRecord.Search

    (

    CDNumber)

    ;
  79. txtCDNo.setText

    (

    CDRecord.getCDNumber

    (

    )

    )

    ;
  80. txtCDTitle.setText

    (

    CDRecord.getCDTitle

    (

    )

    )

    ;
  81. txtCDArtist.setText

    (

    CDRecord.getCDArtist

    (

    )

    )

    ;
  82. txtCDType.setText

    (

    CDRecord.getCDType

    (

    )

    )

    ;
  83. txtCDStatus.setText

    (

    CDRecord.getCDStatus

    (

    )

    )

    ;

  84. if

    (

    Integer

    .parseInt

    (

    txtCDNo.getText

    (

    )

    )

    ==

    0

    )
  85. {

    txtCDNo.setText

    (

    " "

    )

    ;
  86. JOptionPane

    .showMessageDialog

    (

    null

    ,"Cd Record Not Found!!!"

    )

    ;

    }

    }

    }

    )

    ;


  87. btnDelete.addActionListener

    (

    new

    ActionListener

    (

    )
  88. {

    public

    void

    actionPerformed(

    ActionEvent

    e)
  89. {

    String

    CDNumber=

    JOptionPane

    .showInputDialog

    (

    "Input Cd Number to Remove:"

    )

    ;
  90. txtCDNo.setText

    (

    CDNumber)

    ;
  91. CDRecord.Search

    (

    CDNumber)

    ;
  92. txtCDNo.setText

    (

    CDRecord.getCDNumber

    (

    )

    )

    ;
  93. txtCDTitle.setText

    (

    CDRecord.getCDTitle

    (

    )

    )

    ;
  94. txtCDArtist.setText

    (

    CDRecord.getCDArtist

    (

    )

    )

    ;
  95. txtCDType.setText

    (

    CDRecord.getCDType

    (

    )

    )

    ;
  96. txtCDStatus.setText

    (

    CDRecord.getCDStatus

    (

    )

    )

    ;

  97. if

    (

    Integer

    .parseInt

    (

    txtCDNo.getText

    (

    )

    )

    ==

    0

    )
  98. {

    txtCDNo.setText

    (

    " "

    )

    ;
  99. txtCDStatus.setText

    (

    "available"

    )

    ;
  100. JOptionPane

    .showMessageDialog

    (

    null

    ,"Cd Record Not Found!!!"

    )

    ;

    }
  101. else
  102. {

    CDRecord.Remove

    (

    CDNumber)

    ;
  103. JOptionPane

    .showMessageDialog

    (

    null

    ,"Selected Cd Record is already Removed!!!"

    )

    ;
  104. txtCDNo.setText

    (

    ""

    )

    ;
  105. txtCDTitle.setText

    (

    ""

    )

    ;
  106. txtCDArtist.setText

    (

    ""

    )

    ;
  107. txtCDType.setText

    (

    ""

    )

    ;
  108. txtCDStatus.setText

    (

    "available"

    )

    ;;
  109. }

    }

    }

    )

    ;

  110. btnClose.addActionListener

    (

    new

    ActionListener

    (

    )
  111. {

    public

    void

    actionPerformed(

    ActionEvent

    e)
  112. {
  113. setVisible(

    false

    )

    ;
  114. MenuGui app =

    new

    MenuGui(

    )

    ;
  115. app.setResizable

    (

    true

    )

    ;
  116. app.setLocation

    (

    410

    ,200

    )

    ;
  117. }

    }

    )

    ;


  118. setSize(

    400

    ,350

    )

    ;
  119. show(

    )

    ;
  120. }


  121. }

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.

 

442,401

317,942

317,951

Top