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 8259503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:52:49+00:00 2026-06-08T02:52:49+00:00

The code follows, i want that whatever data is there in text field T1

  • 0

The code follows, i want that whatever data is there in text field T1 & T2 get subtracted and comes in T3 after we press the button…

import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class abc extends Applet implements ActionListener {
    TextField T1, T2, T3, T4, T5;
    Button B1;
    String ST1, ST2, ST3;
    double a;

    public void paint(Graphics g) {

    setLayout(null);
    setBackground(Color.pink);
    g.drawRect(0, 0, 600, 500);
    g.drawLine(0, 50, 600, 50);
    g.drawLine(0, 80, 600, 80);
    g.drawLine(150, 50, 150, 80);
    g.drawLine(300, 50, 300, 80);
    g.drawLine(0, 110, 600, 110);
    g.drawLine(120, 80, 120, 150);
    g.drawLine(240, 80, 240, 150);
    g.drawLine(360, 80, 360, 150);
    g.drawLine(480, 80, 480, 150);
    g.drawLine(0, 150, 600, 150);
    g.drawLine(230, 150, 230, 360);
    g.drawLine(300, 150, 300, 170);
    g.drawLine(370, 150, 370, 170);
    g.drawLine(460, 150, 460, 390);
    g.drawLine(230, 170, 460, 170);
    g.drawLine(0, 390, 600, 390);
    g.drawLine(0, 360, 460, 360);
    g.drawLine(345, 200, 345, 390);
    g.drawLine(0, 200, 345, 200);
    g.drawLine(0, 420, 600, 420);
    g.drawLine(0, 220, 230, 220);
    g.drawLine(0, 240, 230, 240);
    g.drawLine(0, 260, 230, 260);
    g.drawLine(0, 280, 230, 280);
    g.drawLine(0, 300, 230, 300);
    g.drawLine(0, 320, 230, 320);
    g.drawLine(0, 340, 230, 340);
    g.drawLine(140, 220, 140, 360);

    Label L1 = new Label("A COMPANY PVT.LTD.");
    L1.setBounds(150, 5, 440, 30);
    Font myFont = new Font("TimesRoman", Font.BOLD, 18);
    L1.setFont(myFont);
    Label L2 = new Label("Ph. :01222");
    L2.setBounds(200, 30, 250, 20);
    Label L3 = new Label("Date //___");
    L3.setBounds(470, 30, 120, 20);

    Label L4 = new Label("Vehicle No.");
    Label L5 = new Label("Colliery");
    Label L6 = new Label("Unloaded at:");
    L4.setBounds(5, 55, 120, 10);
    L5.setBounds(155, 55, 130, 15);
    L6.setBounds(315, 55, 120, 10);

    this.add(L1);
    this.add(L2);
    this.add(L3);
    this.add(L4);
    this.add(L5);
    this.add(L6);

    Label L7 = new Label("Desp.Wt.in MT");
    L7.setBounds(10, 84, 100, 25);
    this.add(L7);
    Label L8 = new Label("Recd.Wt.in MT");
    L8.setBounds(135, 84, 100, 25);
    this.add(L8);
    Label L9 = new Label("Shortage in MT");
    L9.setBounds(255, 84, 100, 25);
    this.add(L9);
    Label L10 = new Label("Freight Rate PMT");
    L10.setBounds(375, 84, 100, 25);
    this.add(L10);
    Label L11 = new Label("Advance Rs.");
    L11.setBounds(500, 84, 95, 25);
    this.add(L11);

    Font myFont1 = new Font("TimesRoman", Font.BOLD, 10);
    Label L12 = new Label("Weight X");
    L12.setBounds(240, 152, 55, 15);
    this.add(L12);
    L12.setFont(myFont1);
    Label L13 = new Label("Freight =");
    L13.setBounds(310, 152, 55, 15);
    this.add(L13);
    L13.setFont(myFont1);
    Label L14 = new Label("Amount");
    L14.setBounds(390, 152, 55, 15);
    this.add(L14);
    L14.setFont(myFont1);

    Font myFont2 = new Font("ArialBlack", Font.BOLD, 10);
    Label S1 = new Label("Particulars");
    S1.setBounds(15, 221, 30, 18);
    S1.setFont(myFont2);
    this.add(S1);
    Label S2 = new Label("Shortage");
    S2.setBounds(5, 241, 30, 18);
    S2.setFont(myFont2);
    this.add(S2);
    Label S3 = new Label("Advance");
    S3.setBounds(5, 261, 30, 18);
    S3.setFont(myFont2);
    this.add(S3);
    Label S4 = new Label("Commission");
    S4.setBounds(5, 281, 30, 18);
    S4.setFont(myFont2);
    this.add(S4);
    Label S5 = new Label("Munsiana");
    S5.setBounds(5, 301, 30, 18);
    S5.setFont(myFont2);
    this.add(S5);
    Label S6 = new Label("Other Deduction");
    S6.setBounds(5, 321, 30, 18);
    S6.setFont(myFont2);
    this.add(S6);
    Label S7 = new Label("Total");
    S7.setBounds(5, 341, 30, 18);
    S7.setFont(myFont2);
    this.add(S7);
    Label R1 = new Label("Amount");
    R1.setBounds(150, 221, 40, 18);
    R1.setFont(myFont2);
    this.add(R1);
    TextField R2 = new TextField();
    R2.setBounds(145, 241, 80, 18);
    R2.setFont(myFont2);
    this.add(R2);
    TextField R3 = new TextField();
    R3.setBounds(145, 261, 80, 18);
    R3.setFont(myFont2);
    this.add(R3);
    TextField R4 = new TextField();
    R4.setBounds(145, 281, 80, 18);
    R4.setFont(myFont2);
    this.add(R4);
    TextField R5 = new TextField();
    R5.setBounds(145, 301, 80, 18);
    R5.setFont(myFont2);
    this.add(R5);
    TextField R6 = new TextField();
    R6.setBounds(145, 321, 80, 18);
    R6.setFont(myFont2);
    this.add(R6);
    TextField R7 = new TextField();
    R7.setBounds(145, 341, 80, 18);
    R7.setFont(myFont2);
    this.add(R7);

    Label L15 = new Label("Total Freight Payable Rs.");
    L15.setBounds(190, 366, 150, 19);
    this.add(L15);
    Label L16 = new Label("Rupees....................................................................................");
    L16.setBounds(30, 395, 200, 19);
    this.add(L16);
    Label L17 = new Label("Paid Date.................................................");
    L17.setBounds(10, 425, 200, 19);
    this.add(L17);
    L17 = new Label("Recieved By Name....................................");
    L17.setBounds(10, 450, 200, 19);
    this.add(L17);
    Label L18 = new Label("Mobile No........................................");
    L18.setBounds(10, 475, 200, 19);
    this.add(L18);
    Label L19 = new Label("Signature");
    L19.setBounds(250, 475, 150, 19);
    this.add(L19);
    Label L20 = new Label("For:A Co.(P)Ltd");
    L20.setBounds(440, 475, 155, 19);
    this.add(L20);

    T1 = new TextField();
    T1.setBounds(5, 118, 110, 28);
    this.add(T1);
    T2 = new TextField();
    T2.setBounds(125, 118, 110, 28);
    this.add(T2);
    T3 = new TextField();
    T3.setBounds(245, 118, 110, 28);
    this.add(T3);
    T4 = new TextField();
    T4.setBounds(365, 118, 110, 28);
    this.add(T4);
    T5 = new TextField();
    T5.setBounds(485, 118, 110, 28);
    this.add(T5);

    B1 = new Button("Submit");
    B1.setBounds(200, 520, 100, 23);

    B1.addActionListener(this);
    this.add(B1);

    T1.setText("40");
    T2.setText("20");
    ST1 = T1.getText();
    ST2 = T2.getText();
    a = Double.parseDouble(ST1) - Double.parseDouble(ST2);
    ST3 = "" + a;
    }

    public void actionPerformed(ActionEvent ev) {
    Object obj = ev.getSource();
    if (obj == B1) {

        System.out.println("wjnqjqw");
    } else {
        T3.setText(ST3);
        System.out.println("assassas");

    }
    }
}// <applet code="abc.java" width=600 height=550></applet>
  • 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-06-08T02:52:50+00:00Added an answer on June 8, 2026 at 2:52 am

    1. First add B1, then apply listener to it.

    2. Keep your Substraction code inside the actionPerformed() method.

    T1.setText("40");
    T2.setText("20"); 
    this.add(B1);
    B1.addActionListener(this);
    
    public void actionPerformed(ActionEvent ev){
    
    ST1=T1.getText(); 
    ST2=T2.getText(); 
    a=Double.parseDouble(ST1)-Double.parseDouble(ST2); 
    ST3=""+a; 
    }
    

    3. Objects are compared using .equals() methods, so use (obj.equals(B1))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run wget as follows shell_exec('wget 'http://somedomain.com/somefile.mp4''); sleep(20); continue my code... What
I have a piece of javascript code as follows: var data = { ...
I want to create 1MB String for benchmark,so I writed code as follow: public
Why can't I do something like this in c# (pseudo code follows) Interface1 {
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
For some code as follows, opts, args = getopt.getopt(sys.argv[1:], c:, ... for o,v in
I need to build some client side code which follows this use case: An
I'm setting the timeout value of an NSMutableURLRequest in code as follows: request.timeoutInterval =
Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter

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.