Create a GUI interface for a currency converter - Dollar-to-Euro. It should look something like the following: Have the user enter the amount of dollars to convert and the conversion rate. When the button is clicked, the amount of Euros should be displayed.Also include a Clear button that clears the input fields.

Asked Nov 1, 2019

 Create a GUI interface for a currency converter - Dollar-to-Euro. It should look something like the following:


Have the user enter the amount of dollars to convert and the conversion rate. When the button is clicked, the amount of Euros should be displayed.

Also include a Clear button that clears the input fields.


Expert Answer

Step 1

To create a GUI converter that converts the currency from dollar to euro below is the approach and java code is given:


  • Using libraries javax.swing 
  • Using action listeners and event listeners.
  • Creating class converter.
  • Inside the converter class, a constructor is declared.
  • Inside constructor labels and text fields are declared as per the requirement.
  • Code to provide the actions performed by buttons as per the requirement. Clear button and converter buttons are used.
  • Setting up the alignment.
  • Declaring the main method.
  • Invoke the runnable function.
  • Inside the main method run method is defined which sets the visibility as true.

Variables are declared inside the main method as per the requirement.

Step 2

Code: -

public class Converter extends javax.swing.JFrame {


     * Design a form Converter


    public Converter() {



    //Constructor that holds the JComponents

    private void initComponents() {

        //jbutton1 used for the conversion

        jButton1 = new javax.swing.JButton();

        //jbutton2 used for the clear

        jButton2 = new javax.swing.JButton();

        //jlabel1 used for the dollar tag

        jLabel1 = new javax.swing.JLabel();

        //jlabel2 used for the euro tag

        jLabel2 = new javax.swing.JLabel();

        //jTextField1 used to prompt user to enter the dollar value

        jTextField1 = new javax.swing.JTextField();

        //jTextField2 used to display the conversion of the dollar value into euro

        jTextField2 = new javax.swing.JTextField();


        jLabel3 = new javax.swing.JLabel();


        //Action performance


        //Create the action listener the event for button 1 and button 2



        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {






        jButton2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {




        //setting the label the names



        //setting the label for header

        jLabel3.setFont(new java.awt.Font("Comic Sans MS", 3, 12)); // NOI18N

        // Alignment =>don't modify  


        jLabel3.setText("Dollar to Euro");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());





                .addGap(52, 52, 52)

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)

                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

                .addGap(18, 18, 18)




                .addGap(192, 192, 192))

            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)


                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()


                        .addGap(98, 98, 98))

                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()



Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in


Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: Using MIPS assembly language can someone help me write a program that does .. Write a program to fin...

A: Program Instructions:Ask the user for number of integers and get those integers.Load the array, redu...


Q: 4. Given the for loop, rewrite the code so that it executes exactly the same but uses a while loop f...

A: For-loop syntax:             for(initialization ; condition ; updation)                             ...


Q: A double-ended queue or deque is a generalization of a stack and a queue that supports adding and re...

A: Program descriptionThe answer for part-1 cannot be attempted as interface and skeleton has not been ...


Q: c. Outline an algorithm for finding the largest key in a B-tree.

A: B-tree is a data structure tree that sorts the data, allows insertion and deletion, searching, and s...


Q: In a large organization, how do you typically request permission to perform a network change?

A: Make the necessary management decisions regarding the changes.


Q: Write a C++ program: you are now working for an accounting firm. Your employer is interested in dete...

A: This program accepts the number of hours and pay rate of an employee as input.For 40 regular hours a...


Q: Blood alcohol content (BAC) is a measure of how much alcohol is in someone’s blood. It is usually me...

A: Program AlgorithmDeclare the required variables in the main().Get the input from the user for option...


Q: (check all that are necessary) Which Oracle server parameters do you need to know in order toset up ...

A: Oracle server parameters required for the client to connect to the server are:Host name or the IP ad...


Q: Write the MIPS assembly code that corresponds to the pseudo codebelow. Assume that the address for i...

A: MIPS instruction:The full form of MIPS is Million Instructions Per Second.The speed of computer’s pr...