Results 1 to 2 of 2
  1. #1
    chopstick is offline Member
    Join Date
    Aug 2015
    Posts
    1
    Rep Power
    0

    Default console to Jframe Gui

    How can I out put this on Jframe with JLabels,
    JScrollPane for currency selection and JTextField for in put.
    (Am new pardon me if I did it wrong)
    Java Code:
    import java.io.BufferedReader;
    
    import java.io.InputStreamReader;
    
    import java.net.URL;
    
    
    
        public classJavaCurrencyConversionExample {
         public static void main(String args[]) {
            // converting 1000 Euro to US Dollar
            System.out.println("Euro/US Dollar: "+ 
              findExchangeRateAndConvert("EUR","USD", 1000));
            // converting 1000 US Dollar to Euro
            System.out.println("US Dollar/Euro: "+ 
              findExchangeRateAndConvert("USD","EUR", 1000));
            // converting 1000 US Dollar to Indian Rupee
            System.out.println("US Dollar/Indian Rupee: " + 
              findExchangeRateAndConvert("USD","INR", 1000));
            // converting 1000 Indian Rupee to US Dollar
            System.out.println("Indian Rupee/US Dollar: " + 
              findExchangeRateAndConvert("INR","USD", 1000));
            }
         private static Double 
         findExchangeRateAndConvert(String from, String to, int amount) {
           try {
            //Yahoo Finance API
            URL url = new URL("http://finance.yahoo.com/d/quotes.csv?f=l1&s="+
                      from + to + "=X");
            BufferedReader reader = newBufferedReader(newInputStreamReader(url.openStream()));
            String line = reader.readLine();
            if (line.length() > 0) {
                return Double.parseDouble(line)* amount;
            }
            reader.close();
          } catch (Exception e) {
         System.out.println(e.getMessage());
        }
        return null;
         }
        }
    Last edited by JosAH; 08-15-2015 at 10:56 AM. Reason: added [code] ... [/code] tags

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: console to Jframe Gui

    Start here: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    Your question implies that you have not yet learned to create a GUI. Your time might be better invested in learning JavaFX, which is slated to replace Swing as the mainstream GUI for Java: 1 JavaFX Overview (Release 8)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 09-09-2014, 07:41 PM
  2. Click in JFrame Titlebar sets the JFrame Opaque
    By tim8w in forum AWT / Swing
    Replies: 1
    Last Post: 02-02-2013, 07:29 AM
  3. Opening a console with my jframe
    By Alkor in forum New To Java
    Replies: 2
    Last Post: 02-29-2012, 11:03 PM
  4. Replies: 5
    Last Post: 06-14-2010, 06:10 PM
  5. Replies: 4
    Last Post: 04-22-2009, 11:02 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •