Thanateros

Untitled

Apr 29th, 2015
211
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. creditsLabel = new JLabel("Credits");
  2. creditsLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 18));
  3. creditsLabel.setHorizontalAlignment(SwingConstants.CENTER);
  4. creditsLabel.setBounds(40,532,84,36);
  5. contentPane.add(creditsLabel);
  6.  
  7. try
  8. {
  9. iStream = new DataInputStream(new FileInputStream("BlackJackCredits.txt"));
  10. credits = iStream.readInt();
  11. String stringDate = iStream.readUTF();
  12. JOptionPane.showMessageDialog(null, "Date saved: " + stringDate +"\nCredits saved: " + credits, "Credits", JOptionPane.INFORMATION_MESSAGE);
  13. }
  14. catch(IOException ex)
  15. {
  16. JOptionPane.showMessageDialog(null, "There were no credits saved. You will start with 100.", "Credits", JOptionPane.WARNING_MESSAGE);
  17. }
  18.  
  19.  
  20. moneyLabel = new JLabel(Integer.toString(credits));
  21. moneyLabel.setForeground(Color.red);
  22. moneyLabel.setFont(new Font("Impact", Font.BOLD, 20));
  23. moneyLabel.setHorizontalAlignment(SwingConstants.CENTER);
  24. moneyLabel.setBounds(169,532,90,36);
  25. contentPane.add(moneyLabel);
  26.  
  27.  
  28. addWindowListener(
  29. new WindowAdapter()
  30. {
  31. public void windowClosing(WindowEvent e)
  32. {
  33. JOptionPane.showMessageDialog(null, Integer.toString(credits) + " credits will be saved for the next player.", "Saving Credits", JOptionPane.INFORMATION_MESSAGE);
  34. try
  35. {
  36. oStream = new DataOutputStream(new FileOutputStream("BlackJackCredits.txt"));
  37. String stringDate = dateFormat.format(new Date());
  38. oStream.writeInt(credits);
  39. oStream.writeUTF(stringDate);
  40. JOptionPane.showMessageDialog(null, "Credits saved", "Success", JOptionPane.INFORMATION_MESSAGE);
  41. }
  42. catch(IOException ex)
  43. {
  44. JOptionPane.showMessageDialog(null, "There was an error saving the credits", "Saving Error", JOptionPane.ERROR_MESSAGE);
  45. }
  46. dispose();
  47. System.exit(0);
  48. }
  49. }
  50. );
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×