Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6868673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:27:47+00:00 2026-05-27T03:27:47+00:00

package loan; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class loan extends JApplet {

  • 0
package loan;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class loan extends JApplet {

    JLabel interestLabel = new JLabel("Interest Rate (e.g. 5.5 for 5.5%)");
    JLabel yearsLabel = new JLabel("Years");
    JLabel amountLabel = new JLabel("Loan Amount");
    JLabel monthlyLabel = new JLabel("Monthly Payment");
    JLabel totalLabel = new JLabel("Total Payment");
    JTextField jtfInterest = new JTextField(10);
    JTextField jtfYears = new JTextField(10);
    JTextField jtfAmount = new JTextField(10);
    JTextField jtfMonthly = new JTextField(10);
    JTextField jtfTotal = new JTextField(10);
    JButton jbtCompute = new JButton("Compute Payment");

    public loan() {

    JPanel panel1 = new JPanel(new GridLayout());
    panel1.setLayout(new GridLayout(5, 2, 5, 5));
    panel1.add(interestLabel);
    panel1.add(jtfInterest);
    panel1.add(yearsLabel);
    panel1.add(jtfYears);
    panel1.add(amountLabel);
    panel1.add(jtfAmount);
    panel1.add(monthlyLabel);
    panel1.add(jtfMonthly);
    panel1.add(totalLabel);
    panel1.add(jtfTotal);

    JPanel panel2 = new JPanel(new BorderLayout());
    panel2.add(jbtCompute, BorderLayout.EAST);

    add(panel1, BorderLayout.NORTH);
    add(panel2, BorderLayout.SOUTH);

    jbtCompute.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                compute();
            }
        });
    }

    private void compute(){
        double monthlyInterestRate = Double.parseDouble(jtfInterest.getText()) / 1200;
        double monthlyPayment = Double.parseDouble(jtfAmount.getText()) * monthlyInterestRate /
                (1 - (Math.pow(1 / (1 + monthlyInterestRate), Double.parseDouble(jtfYears.getText()) * 12)));
        double totalPayment = monthlyPayment * 12;

        jtfMonthly.setText("" + monthlyPayment);
        jtfTotal.setText("" + totalPayment);


    }

    public static void main (String args[]) {
        JFrame frame = new JFrame();
        loan applet = new loan();
        frame.add(applet, BorderLayout.CENTER);
        frame.setSize(300, 300);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

}

I need to turn this into an applet that can be run on a web page.
I am having issues with the html file, but that is another story.
What would I need to do to modify this so it can be run on both a web page, and as an applet in a frame?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:27:47+00:00Added an answer on May 27, 2026 at 3:27 am

    Do this:

    jtfInterest.getText()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package test; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.*; public class
package Sartre.Connect4; import javax.swing.*; public class ChatGUI extends JDialog { public ChatGUI(){ setTitle(Chat); }
package jtextareatest; import java.io.FileInputStream; import java.io.IOException; import javax.swing.*; public class Jtextareatest { public static
package classes.events { import flash.events.Event; public class ASSEvent extends Event { public static const
package vaannila; import java.util.ArrayList; import com.opensymphony.xwork2.ActionSupport; public class RegisterAction extends ActionSupport { private String
package { import flash.display.Sprite; import flash.events.Event; import flash.events.KeyboardEvent; import flash.ui.Keyboard; public class helloworld extends
package samples.flexstore { import flash.events.Event; public class ProductThumbEvent extends Event { public static const
package { import mx.controls.LinkButton; import flash.text.TextLineMetrics; public class multiLineLinkButton extends LinkButton { override protected
package com.example.android.home; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class HomeActivity extends
package org.apache.wicket.examples.guestbook; import java.util.Date; import org.apache.wicket.IClusterable; public class Comment implements IClusterable { private String

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.