Crypto Chart

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

A simple GUI that displays upto date data about Cryptocurrencies such as Bitcoin, IOTA, Ethereum and CarVertical. The program is written using NETBEANS IDE.

  1. private void JButton_Cryptocurrency_chart_EnterMouseClicked(java.awt.event.MouseEvent evt) {
  2. if (JComboBox_select_cryptocurrency.getSelectedIndex() == 0)
  3. {
  4. JOptionPane.showMessageDialog(null, "Please select a CryptoCurrency from the Combobox", "Error", JOptionPane.ERROR_MESSAGE);
  5. System.out.println("Please select a CryptoCurrency from the Combobox");
  6. }
  7. else if (JComboBox_select_cryptocurrency.getSelectedIndex() != 0)
  8. {
  9.  
  10. try
  11. {
  12. String Jcombobox_selected_crypto_value = JComboBox_select_cryptocurrency.getSelectedItem().toString();
  13. URL url_crypto = null;
  14.  
  15.  
  16. if (Jcombobox_selected_crypto_value == "Bitcoin (BTC)")
  17. {
  18. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/bitcoin/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/bitcoin/"</a>);
  19. }
  20.  
  21. else if (Jcombobox_selected_crypto_value == "Ethereum (ETH)")
  22. {
  23. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/ethereum/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/ethereum/"</a>);
  24. }
  25.  
  26. else if (Jcombobox_selected_crypto_value == "Ripple (XRP)")
  27. {
  28. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/ripple/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/ripple/"</a>);
  29. }
  30.  
  31. else if (Jcombobox_selected_crypto_value == "Cardano (ADA)")
  32. {
  33. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/cardano/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/cardano/"</a>);
  34. }
  35.  
  36. else if (Jcombobox_selected_crypto_value == "Stellar (XLM)")
  37. {
  38. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/stellar/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/stellar/"</a>);
  39. }
  40.  
  41. else if (Jcombobox_selected_crypto_value == "IOTA (MIOTA)")
  42. {
  43. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/iota/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/iota/"</a>);
  44. }
  45.  
  46. else if (Jcombobox_selected_crypto_value == "TRON (TRX)")
  47. {
  48. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/tron/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/tron/"</a>);
  49. }
  50.  
  51. else if (Jcombobox_selected_crypto_value == "VeChain (VEN)")
  52. {
  53. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/vechain/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/vechain/"</a>);
  54. }
  55.  
  56. else if (Jcombobox_selected_crypto_value == "OmiseGO (OMG)")
  57. {
  58. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/omisego/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/omisego/"</a>);
  59. }
  60.  
  61. else if (Jcombobox_selected_crypto_value == "Verge (XVG)")
  62. {
  63. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/verge/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/verge/"</a>);
  64. }
  65.  
  66. else if (Jcombobox_selected_crypto_value == "KuCoin Shares (KCS)")
  67. {
  68. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/kucoin-shares/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/kucoin-shares/"</a>);
  69. }
  70.  
  71. else if (Jcombobox_selected_crypto_value == "UTRUST (UTK)")
  72. {
  73. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/utrust/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/utrust/"</a>);
  74. }
  75.  
  76. else if (Jcombobox_selected_crypto_value == "Bread (BRD)")
  77. {
  78. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/bread/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/bread/"</a>);
  79. }
  80.  
  81. else if (Jcombobox_selected_crypto_value == "AppCoins (APPC)")
  82. {
  83. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/appcoins/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/appcoins/"</a>);
  84. }
  85.  
  86. else if (Jcombobox_selected_crypto_value == "Substratum (SUB)")
  87. {
  88. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/substratum/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/substratum/"</a>);
  89. }
  90.  
  91. else if (Jcombobox_selected_crypto_value == "carVertical (CV)")
  92. {
  93. url_crypto = new URL("<a href="https://api.coinmarketcap.com/v1/ticker/carvertical/"" rel="nofollow">https://api.coinmarketcap.com/v1/ticker/carvertical/"</a>);
  94. }
  95.  
  96. //Continue with the execution
  97. String[] crypto_coins_array_data = new String[15];
  98. GetURLContent obj_url_content = new GetURLContent();
  99. crypto_coins_array_data = obj_url_content.GetURLContent(url_crypto);
  100.  
  101. JLabel_id_cryptocurrency.setVisible(true);
  102. JLabel_name_cryptocurrency.setVisible(true);
  103. JLabel_symbol_cryptocurrency.setVisible(true);
  104. JLabel_rank_cryptocurrency.setVisible(true);
  105. JLabel_price_usd_cryptocurrency.setVisible(true);
  106. JLabel_price_btc_cryptocurrency.setVisible(true);
  107. JLabel_24hr_volume_cryptocurrency.setVisible(true);
  108. JLabel_market_cap_usd_cryptocurrency.setVisible(true);
  109. JLabel_available_supply_cryptocurrency.setVisible(true);
  110. JLabel_total_supply_cryptocurrency.setVisible(true);
  111. JLabel_max_supply_cryptocurrency.setVisible(true);
  112. JLabel_percentage_change_1hr_cryptocurrency.setVisible(true);
  113. JLabel_percentage_change_24hr_cryptocurrency.setVisible(true);
  114. JLabel_percentage_change_7d_cryptocurrency.setVisible(true);
  115. JLabel_last_updated_cryptocurrency.setVisible(true);
  116.  
  117. JLabel_id_of_cryptocurrency_value.setVisible(true);
  118. JLabel_name_cryptocurrency_value.setVisible(true);
  119. JLabel_symbol_cryptocurrency_value.setVisible(true);
  120. JLabel_rank_cryptocurrency_value.setVisible(true);
  121. JLabel_price_usd_cryptocurrency_value.setVisible(true);
  122. JLabel_price_btc_cryptocurrency_value.setVisible(true);
  123. JLabel_24hr_volume_cryptocurrency_value.setVisible(true);
  124. JLabel_market_cap_usd_cryptocurrency_value.setVisible(true);
  125. JLabel_available_supply_cryptocurrency_value.setVisible(true);
  126. JLabel_total_supply_cryptocurrency_value.setVisible(true);
  127. JLabel_max_supply_cryptocurrency_value.setVisible(true);
  128. JLabel_percentage_change_1hr_cryptocurrency_value.setVisible(true);
  129. JLabel_percentage_change_24hr_cryptocurrency_value.setVisible(true);
  130. JLabel_percentage_change_7d_cryptocurrency_value.setVisible(true);
  131. JLabel_last_updated_cryptocurrency_value.setVisible(true);
  132.  
  133. int I_counter;
  134. for (I_counter = 0; I_counter<15; I_counter++)
  135. {
  136. if (crypto_coins_array_data[I_counter] == null || crypto_coins_array_data[I_counter].trim().length() == 0)
  137. {
  138. crypto_coins_array_data[I_counter] = "___";
  139. }
  140. }
  141.  
  142. for (int k_counter = 11; k_counter<14; k_counter++)
  143. { String text_color;
  144.  
  145. if (crypto_coins_array_data[k_counter]== null || crypto_coins_array_data[k_counter]=="___")
  146. {
  147. crypto_coins_array_data[k_counter] = "<html><font color='orange'>___</font></html>";
  148. }
  149.  
  150. else
  151. {
  152. double d = Double.parseDouble(crypto_coins_array_data[k_counter]);
  153. if (d < 1)
  154. {
  155. crypto_coins_array_data[k_counter] = "<html><font color='green'>" + d + "</font></html>";
  156. }
  157. else
  158. {
  159. crypto_coins_array_data[k_counter] = "<html><font color='red'>" + d + "</font></html>";
  160. }
  161. }
  162. }
  163.  
  164. JLabel_id_of_cryptocurrency_value.setText(crypto_coins_array_data[0]);
  165. JLabel_name_cryptocurrency_value.setText(crypto_coins_array_data[1]);
  166. JLabel_symbol_cryptocurrency_value.setText(crypto_coins_array_data[2]);
  167. JLabel_rank_cryptocurrency_value.setText(crypto_coins_array_data[3]);
  168. JLabel_price_usd_cryptocurrency_value.setText(crypto_coins_array_data[4]);
  169. JLabel_price_btc_cryptocurrency_value.setText(crypto_coins_array_data[5]);
  170. JLabel_24hr_volume_cryptocurrency_value.setText(crypto_coins_array_data[6]);
  171. JLabel_market_cap_usd_cryptocurrency_value.setText(crypto_coins_array_data[7]);
  172. JLabel_available_supply_cryptocurrency_value.setText(crypto_coins_array_data[8]);
  173. JLabel_total_supply_cryptocurrency_value.setText(crypto_coins_array_data[9]);
  174. JLabel_max_supply_cryptocurrency_value.setText(crypto_coins_array_data[10]);
  175. JLabel_percentage_change_1hr_cryptocurrency_value.setText(crypto_coins_array_data[11]);
  176. JLabel_percentage_change_24hr_cryptocurrency_value.setText(crypto_coins_array_data[12]);
  177. JLabel_percentage_change_7d_cryptocurrency_value.setText(crypto_coins_array_data[13]);
  178. JLabel_last_updated_cryptocurrency_value.setText(crypto_coins_array_data[14]);

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

You posted any important post bro, but you didn't share your contacts info. How can I get you?

You can reach me through mail[at]davidwachira.com

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • 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.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.