Home Answers Viewqa Java-Beginners java -netbeans help

 
 


punitha
java -netbeans help
2 Answer(s)      3 years and a month ago
Posted in : Java Beginners

a simple program in netbeans ide to add two numbers and display the result as ADDITION OF TWO NUMBERS IS:70 in the textarea
design contains
one textarea
one button
and two text field to get input
these GUI actions should be in input.java file
when u press the button it should call add.java file
the add.java file should do addition and display the result in textarea that is created in input.java file
View Answers

April 22, 2010 at 1:08 PM


Hi Friend,

Try the following code:

1)input.java:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class input{
public static void main(String[] args)
{
JFrame f=new JFrame();
JPanel p=new JPanel(new GridLayout(4,2));
JLabel l1=new JLabel("Enter first number");
final JTextField text1=new JTextField(20);
JLabel l2=new JLabel("Enter second number");
final JTextField text2=new JTextField(20);
JLabel l3=new JLabel("Result");
final JTextArea area=new JTextArea(4,10);
JButton b=new JButton("Add");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String value1=text1.getText();
String value2=text2.getText();
int num1=Integer.parseInt(value1);
int num2=Integer.parseInt(value2);

add a=new add();
int sum=a.findSum(num1,num2);
area.setText(Integer.toString(sum));
}
});
p.add(l1);
p.add(text1);
p.add(l2);
p.add(text2);
p.add(l3);
p.add(area);
p.add(b);
f.add(p);
f.pack();
f.setVisible(true);
}
}

2)add.java:

public class add
{
public static int findSum(int num1,int num2){
int sum=num1+num2;
return sum;
}
}

Thanks

April 22, 2010 at 2:45 PM


thank you soooo much for the reply...am looking for more than that..
am doing a project,to make it simple i gave the program of addition.
sir/mam, i developed frontend with netbeans with buttons and textarea..
am executing a clustering algorithm by pressing the button.
the custering algorithm reads the data from database and it performs clustering.everything is going well.
but the output is not displayed in the textarea...as the textarea is created in input.java file
ouput is executed and it has print stmt in the cluster.java file....where i cannot return values...but i want this cluster.java file to recognise the textarea created in the input.java file..pls how to do this..
if u have ur mail id pls pass it to punithap@gmail.com
so i can contact u personnaly for help to overcome this problem









Related Pages:
help
help   how i can send a pitcture on url in java
help
help  pls help me to get the code of a java program a program to perform different shapes in a menu using javaapplet
help
help  i need help with this code. write a java code for a method named addSevenToKthElement that takes an integer array, and an integer k as its arguments and returns the kth element plus 7. any help would be greatly
help
help  Hii.. I have to design one registration page in java that looks like REGISTER USERNAME (here i have to check whether username already exists... to the user) please tell me how could i design that. Please help me asap Thanks a lot
help
help  how can i query for a minimum value of of one of the column in my database through java   Use min to retrieve the minimum value from one column of database table. Suppose you have a table named emp where
help
(); } } SFDV2103 â?? Java Programming Fall, 2012 Term Project... on the percentage of cheating. SFDV2103 â?? Java Programming Fall, 2012 Term... based on the percentage of cheating. please help me
help
this in java then try this: import java.util.*; class SquareNumber { public
help
Java application  public int remainder(int a, int b) { int answer = a % b; System.out.printf("%d % %d = ", a , b); return (answer); } and in my main, int answerRemain
help
. Based on the above scenario, write a complete Java program. Your program should
Help With Java...
Help With Java...  Write a java program that can take a positive integer greater than 2 as input and write out the number of times one must repeatedly divide this number by 2 before getting a value less than 2
Regular Expression Help Help HELP!!!!
Regular Expression Help Help HELP!!!!  HI all I am very new to java... could help me to give a solution of how to retrieve the name and email add... the quotes ""07001", "MR Harish Ram","M.RHarish @ hotmail.com"" Help is greatly
java help
java help  How to Open CSV Files in a Microsoft Excel Application Using Java Code with example pgm
help in java
help in java   Rational Numbers Rational numbers are numbers that can be represented as a fraction p / q where p is an integer number and q is a positive integer (q != 0). Design and implement a Java class RationalNumber
help in java
help in java  Write an application that prompt the user to enter a number to use as an array size, and then attempt to declare an array using the entered size. Java generates a NegativeArraySizeException if wou attempt to create
help in java
help in java  3.Flights Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name, flight number, and the flight's origin and destination cities
help in java
help in java  Write a program that will evaluate simple expressions such as 17 + 3 and 3.14159 * 4.7. The expressions are to be typed in by the user. The input always consist of a number, followed by an operator, followed
java help?
java help?  Write a program, where you first ask values to an array with 6 integer values and then count the sum and average of the values in methods (send in the array & return the counted value to the main program). Print
java help
java help   Write a Java program that does the following: 1.Creates a grading program based on the Baker College grading standard. You will need to look up the current grade standard. You may use only the letter grades without
help in java
help in java  Design and implement a class called Sphere that contains instance data that represents the sphere's diameter. Define the Sphere constructor to accept and initialize the diameter, and include getter and setter
help in java
help in java  The factorial of a nonnegative integer n is written n! (pronounced ââ?¬Å? n factorialââ?¬Â?) and is defined as follows: n!=n . (n-1) . (n-2) . .... . 1 (for values of n greater than or equal to 1) and n!=1 (for n
help for java
help for java  1.convert the following Pseudo code to java if/else structure if student?s grade is greater than or equal to 90 Print ?A? else if student?s grade is greater than or equal to 80 Print ?B? else
help in java
help in java  Gross And Dozens Design and implement a class called GrossAndDozens to convert a given number of eggs into the number of gross, the number of dozens, and to the number of left over eggs. If you have N eggs, then you
help in java
help in java  Shopping cart Create 3 shopping carts from a Cart class. Each class should have four items in it, a title, a price for the 4 items and the number of each. Your shopping cart should use private variables, so use
help in java
help in java   Team Roster Create a program called TeamRoster that uses a class called Roster. Roster should contain a team name and the names of all... or help me on this pleas.. 7. Gross And Dozens Design and implement a class
java help
java help  1) build class(es) for the dresses, choose (dress ID, color, price, designer)( link lists) 2) construct the driver class by establishing two separate objects for each sister 3) let them both to enter the dresses
java help
java help  Rational numbers are numbers that can be represented as a fraction p / q where p is an integer number and q is a positive integer (q != 0). Design and implement a Java class RationalNumber for representing such numbers
help in java
help in java  Write a Temperature class that has two instance variables: a temperature value (a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have a number
help in java
help in java  Temperature Write a Temperature class that has two instance variables: a temperature value (a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have
help in java
help in java  Define a class named Money whose objects represent amounts of U.S. money. The class will have two instance variables of type int for the dollars and cents in the amount of money. Include a constructor with two
help in java
help in java  Create a class named Order that performs order processing of a single item. The class has five instance variables (fields) : customer name, customer number, quantity ordered, unit price, and total price. Define
help in java
help in java  Create 3 shopping carts from a Cart class. Each class should have four items in it, a title, a price for the 4 items and the number of each. Your shopping cart should use private variables, so use getter and setter
Java help
Java help  Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a Floating-point number for the temperature and a character for the scale: either 'C' for Celsius or 'F
Java Help
Java Help  Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a Floating-point number for the temperature and a character for the scale: either 'C' for Celsius or 'F
java help
java help  Design and implement a class called DateWriter that has three instance variables: a string for month, an integer for day, and an integer for year. The class should has a constructor to accept and initialize the values
java,java,java,help
java,java,java,help  Dear people, can anyone help me complete this program import java.util.*; public class StringDemo { static String a="{a=100;b=200;c=300}"; public static void main(String args[]) { String b[]=a.split
help me
help me  please send me the java code to count the number of similar words in given string and replace that word with new one
Timeseries help
Timeseries help  hey....... can u plz help me in time series code... that java swings has a timeseries method to display the output as the method of Barchart???? plz help
Help me
Help me  plz i want code of program to add real numbers and magic numbers in java example this input :- 5+3i-2+3i output:- 3+6i
help pleas? -_-
help pleas? -_-  Write a Java program that reads from the user an integer N followed by N integers. The program then prints the product of odd integers, and, the sum of even integers
java-help - Java Beginners
java-help  hello sir, please help me.....the below given is the output.java program here in this program am using the stmts ta. append("clustering") where ta is a textarea created in input.java file.i have designed only one
Intro Java help with Double
Intro Java help with Double  I have to evaluate a math expression using double in Java. I can input the code fine for the expression, but I don't know how to view the answer that it gives me. help
java help - Java Beginners
java help  Code a try statement that catches the NumberFormatException that may be thrown when the following statement is executed: int count... on Java visit to : http://www.roseindia.net/java/exceptions/ Thanks
java help - Java Beginners
java help  Code a catch block that catches a NumberFormatException and then prints the name of the class that the exception was created from along... information on Exception Handling in Java visit to : http://www.roseindia.net/java
java help - Java Beginners
java help  Code a try statement that calls the calculateDiscount method and assigns the return value to a double variable named discountPct... information on Exception Handling in Java visit to : http://www.roseindia.net/java
java help - Java Beginners
java help  Code a try statement that catches an IOException and an EOFException. If an IOException occurs, print the message ?An I/O error occurred.? to the console. If an EOFException occurs, print the message ?End of file
Java help - Java Beginners
Java help  I need to write an application that uses the circle class. It must read a radius of a circle from the user creates a circle object, and return the object. The program creates a circle object by using the above method
java help - Java Beginners
java help  Code a statement to test a catch block that catches an IOException.  Hi friend, Code a statement to test a catch block that catches an IOException. import java.io.*; class IOExample { public static
java help - Java Beginners
java help  Code a catch block that catches a NumberFormatException and then prints the stack trace.  Hi friend, Code a catch block that catches a NumberFormatException and prints stack trace : class
java help - Java Beginners
java help  Write the code for a method named calculateTax that accepts a double parameter named subtotal and a boolean parameter named isFresno and calculates and returns the sales tax. If isFresno is false, the sales tax should
java help - Java Beginners
java help  Write the code for a method named getFile that accepts a file name and returns a file created from the RandomAccessFile class. This method should catch the FileNotFoundException if it occurs and print the message ?File

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.