I didn't gat an output for this code, plz send me a correct code
Hi,
Here is my code:
import java.awt.event.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.*;
import java.sql.*;
public class example2 extends javax.swing.JFrame {
public example2() {
tmark1=new JTextField();
tmark1.addKeyListener(new TetAdapter());
tmark2=new JTextField();
tmark2.addKeyListener(new TetAdapter());
ttotal=new JTextField();
initComponents();
}
class TetAdapter extends KeyAdapter{
public void keyReleased(KeyEvent k){
int value1 = 0, value2 = 0;
try{
value1 = Integer.parseInt(tmark1.getText());
}catch(NumberFormatException ne){
value1 = 0;
}
try{
value2 = Integer.parseInt(tmark2.getText());
}catch(NumberFormatException ne){
value2 = 0;
}
ttotal.setText(value1+value2+"");
}
}
@SuppressWarnings("unchecked")
//
private void initComponents() {
ttotal = new javax.swing.JTextField();
ltotal = new javax.swing.JLabel();
tmark1 = new javax.swing.JTextField();
lmark2 = new javax.swing.JLabel();
tmark2 = new javax.swing.JTextField();
lmark1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
ttotal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ttotalActionPerformed(evt);
}
});
ltotal.setText("TOTAL");
lmark2.setText("MARK2");
lmark1.setText("MARK1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(ltotal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lmark2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lmark1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(tmark1)
.addComponent(tmark2, javax.swing.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
.addComponent(ttotal))
.addGap(80, 80, 80))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tmark1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lmark1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tmark2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lmark2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ltotal)
.addComponent(ttotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(131, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void ttotalActionPerformed(java.awt.event.ActionEvent evt) {
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new example2().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel lmark1;
private javax.swing.JLabel lmark2;
private javax.swing.JLabel ltotal;
public javax.swing.JTextField tmark1;
public javax.swing.JTextField tmark2;
public javax.swing.JTextField ttotal;
// End of variables declaration
}
Thanks
View Answers
Related Tutorials/Questions & Answers:
PLZ HELP ME. i need php code. PLZ HELP
ME.
i need php
code.
I want php
code for bellow
OUTPUT.
output is just example but it must be letters only.
abc
bcd
efg
jku
rgt
azs
hje
qqc
wws
adt
Advertisements
plz send code for thisplz send code for this Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
Plz give me code for this questionPlz give
me code for this question Program to find depth of the file in a directory and list all files those are having more number of parent directories
Plz Provide correct program code for all questions.Plz Provide
correct program
code for all questions.
Write a program... rate expressed as a decimal, and the number of years.
Mail
me... the following
code:
1)
import java.util.*;
class FindDifference
{
public static
Plz send me answer qucklyPlz send me answer quckly Respected Sir,
myself is pavan shrivastava.i want ask a question that is ( we can't
create object of interface then how would possible to create object
conert java code to jsp... plz imm i wan...conert java
code to jsp...
plz imm
i wan... how to convert this java
code into jsp??
Java| Frameworks| Databases| Technology| Development| Build... currency according to the locale. In the
code given below we are formatting Currency
plz Help me find the correct programs answersplz Help
me find the
correct programs answers
Create a washing... INDICA" and "TATA NANO" respectively.
Plz mail
me your answers...; subtract
Create a class called Student which has the following methods:
i Pls send code Pls
send code I am Mohini Charankar
suppose Name="Mohini" Edit Button Click on that
I change my Name with "Mohini/" Save it and page refresh After... an error pls
send code java code to send an emailjava
code to
send an email
i developed one java
code that has to
send a mail but
i am getting an runtime exception calledjavax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested
pls send code pls
send code pls
send code for set database value into text box based on selected value
in struts and jsp
use any database and get its
code for getting values from google
plz explain me the output of program - Java Beginnersplz explain
me the
output of program Hi friends,
can u please explain
me the
output of below program with proper explanation of each and every line...;Hi Friend,
Output of this program is:
a=2
b=0
c=0
mul=27
volume=18
jsp code plzjsp
code plz write jsp
code which takes student roll number as input and prints the student group,study center, and his grade card
Please visit the following links:
http://www.roseindia.net/jsp/user-search.shtml
please send code - Java Beginnersplease
send code hai friends plese provide
code for fallowing program(CORE JAVA)
i am taking string from commandprompt like 'AC2E4T45hj789'
now... number it should be taken as single number)
URGENTLY
send the
code how to send sms on mobile and email using java codehow to
send sms on mobile and email using java code hi....
I am developing a project where
I need to
send a confirmation/updation msg on clients mobile and also an email on their particular email id....
plz help
me to find
verify the code and give me the code with out errorsverify the
code and give
me the
code with out errors
import...();
}
}
when
i run this program... it shows the given below errors.pls clear the errors and give
me correct tutorial for my knowledge improving.pls anyone
php brute force code.. hlp plz .....php brute force
code.. hlp
plz ..... hello friends,
from somewhere
i got a
code that can generate all posible combination via recursive function..., '');
//////////////////////////////////// Ended PHP
Code //////////////////////
now
i i want code for these programsi want
code for these programs Advances in operating system
Laboratory Work:
(The following programs can be executed on any available and suitable platform)
Design, develop and execute a program using any
Give me the source code for this problemGive
me the source
code for this problem Ram likes skiing a lot... the heights. R and C won't be bigger than 100.
Output
For each test case, print...
13 12 11 10 9
Sample
Output
Manali: 7
Narkanda: 25
Plz send - Java BeginnersPlz send Hi,
please
send whole
code i understood ur sending sql query
Thanks hai dear frnd........
look how can
i write the
code... without knowing ur table structure...from where should the search occur
Can i write JavaScript code in AjaxResponse Code ?Can
i write JavaScript
code in AjaxResponse
Code ? Hai Every Dynamic's
We can't write JavaScript
code in Ajax Response Code.Why because it takes...'s not working.rather than that
i try to created on innerHtml document.
here
plz send immediately - Java Beginnersplz send immediately Hi Deepak,
How are you,
Deepak
I face some problem in my project,
plz help
me
My Questin is user input... should be updated.
plz write a
code and immediate response its very urgent
plz