private void JButton_Cryptocurrency_chart_EnterMouseClicked
(java.
awt.
event.
MouseEvent evt
) {
if (JComboBox_select_cryptocurrency.getSelectedIndex() == 0)
{
JOptionPane.
showMessageDialog(null,
"Please select a CryptoCurrency from the Combobox",
"Error",
JOptionPane.
ERROR_MESSAGE);
System.
out.
println("Please select a CryptoCurrency from the Combobox");
}
else if (JComboBox_select_cryptocurrency.getSelectedIndex() != 0)
{
try
{
String Jcombobox_selected_crypto_value
= JComboBox_select_cryptocurrency.
getSelectedItem().
toString();
if (Jcombobox_selected_crypto_value == "Bitcoin (BTC)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/bitcoin/");
}
else if (Jcombobox_selected_crypto_value == "Ethereum (ETH)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/ethereum/");
}
else if (Jcombobox_selected_crypto_value == "Ripple (XRP)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/ripple/");
}
else if (Jcombobox_selected_crypto_value == "Cardano (ADA)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/cardano/");
}
else if (Jcombobox_selected_crypto_value == "Stellar (XLM)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/stellar/");
}
else if (Jcombobox_selected_crypto_value == "IOTA (MIOTA)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/iota/");
}
else if (Jcombobox_selected_crypto_value == "TRON (TRX)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/tron/");
}
else if (Jcombobox_selected_crypto_value == "VeChain (VEN)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/vechain/");
}
else if (Jcombobox_selected_crypto_value == "OmiseGO (OMG)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/omisego/");
}
else if (Jcombobox_selected_crypto_value == "Verge (XVG)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/verge/");
}
else if (Jcombobox_selected_crypto_value == "KuCoin Shares (KCS)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/kucoin-shares/");
}
else if (Jcombobox_selected_crypto_value == "UTRUST (UTK)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/utrust/");
}
else if (Jcombobox_selected_crypto_value == "Bread (BRD)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/bread/");
}
else if (Jcombobox_selected_crypto_value == "AppCoins (APPC)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/appcoins/");
}
else if (Jcombobox_selected_crypto_value == "Substratum (SUB)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/substratum/");
}
else if (Jcombobox_selected_crypto_value == "carVertical (CV)")
{
url_crypto
= new URL("https://api.coinmarketcap.com/v1/ticker/carvertical/");
}
//Continue with the execution
GetURLContent obj_url_content = new GetURLContent();
crypto_coins_array_data = obj_url_content.GetURLContent(url_crypto);
JLabel_id_cryptocurrency.setVisible(true);
JLabel_name_cryptocurrency.setVisible(true);
JLabel_symbol_cryptocurrency.setVisible(true);
JLabel_rank_cryptocurrency.setVisible(true);
JLabel_price_usd_cryptocurrency.setVisible(true);
JLabel_price_btc_cryptocurrency.setVisible(true);
JLabel_24hr_volume_cryptocurrency.setVisible(true);
JLabel_market_cap_usd_cryptocurrency.setVisible(true);
JLabel_available_supply_cryptocurrency.setVisible(true);
JLabel_total_supply_cryptocurrency.setVisible(true);
JLabel_max_supply_cryptocurrency.setVisible(true);
JLabel_percentage_change_1hr_cryptocurrency.setVisible(true);
JLabel_percentage_change_24hr_cryptocurrency.setVisible(true);
JLabel_percentage_change_7d_cryptocurrency.setVisible(true);
JLabel_last_updated_cryptocurrency.setVisible(true);
JLabel_id_of_cryptocurrency_value.setVisible(true);
JLabel_name_cryptocurrency_value.setVisible(true);
JLabel_symbol_cryptocurrency_value.setVisible(true);
JLabel_rank_cryptocurrency_value.setVisible(true);
JLabel_price_usd_cryptocurrency_value.setVisible(true);
JLabel_price_btc_cryptocurrency_value.setVisible(true);
JLabel_24hr_volume_cryptocurrency_value.setVisible(true);
JLabel_market_cap_usd_cryptocurrency_value.setVisible(true);
JLabel_available_supply_cryptocurrency_value.setVisible(true);
JLabel_total_supply_cryptocurrency_value.setVisible(true);
JLabel_max_supply_cryptocurrency_value.setVisible(true);
JLabel_percentage_change_1hr_cryptocurrency_value.setVisible(true);
JLabel_percentage_change_24hr_cryptocurrency_value.setVisible(true);
JLabel_percentage_change_7d_cryptocurrency_value.setVisible(true);
JLabel_last_updated_cryptocurrency_value.setVisible(true);
int I_counter;
for (I_counter = 0; I_counter<15; I_counter++)
{
if (crypto_coins_array_data[I_counter] == null || crypto_coins_array_data[I_counter].trim().length() == 0)
{
crypto_coins_array_data[I_counter] = "___";
}
}
for (int k_counter = 11; k_counter<14; k_counter++)
if (crypto_coins_array_data[k_counter]== null || crypto_coins_array_data[k_counter]=="___")
{
crypto_coins_array_data[k_counter] = "<html><font color='orange'>___</font></html>";
}
else
{
double d
= Double.
parseDouble(crypto_coins_array_data
[k_counter
]);
if (d < 1)
{
crypto_coins_array_data[k_counter] = "<html><font color='green'>" + d + "</font></html>";
}
else
{
crypto_coins_array_data[k_counter] = "<html><font color='red'>" + d + "</font></html>";
}
}
}
JLabel_id_of_cryptocurrency_value.setText(crypto_coins_array_data[0]);
JLabel_name_cryptocurrency_value.setText(crypto_coins_array_data[1]);
JLabel_symbol_cryptocurrency_value.setText(crypto_coins_array_data[2]);
JLabel_rank_cryptocurrency_value.setText(crypto_coins_array_data[3]);
JLabel_price_usd_cryptocurrency_value.setText(crypto_coins_array_data[4]);
JLabel_price_btc_cryptocurrency_value.setText(crypto_coins_array_data[5]);
JLabel_24hr_volume_cryptocurrency_value.setText(crypto_coins_array_data[6]);
JLabel_market_cap_usd_cryptocurrency_value.setText(crypto_coins_array_data[7]);
JLabel_available_supply_cryptocurrency_value.setText(crypto_coins_array_data[8]);
JLabel_total_supply_cryptocurrency_value.setText(crypto_coins_array_data[9]);
JLabel_max_supply_cryptocurrency_value.setText(crypto_coins_array_data[10]);
JLabel_percentage_change_1hr_cryptocurrency_value.setText(crypto_coins_array_data[11]);
JLabel_percentage_change_24hr_cryptocurrency_value.setText(crypto_coins_array_data[12]);
JLabel_percentage_change_7d_cryptocurrency_value.setText(crypto_coins_array_data[13]);
JLabel_last_updated_cryptocurrency_value.setText(crypto_coins_array_data[14]);