Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


navn
java fx
1 Answer(s)      4 years and 4 months ago
Posted in : Java Interview Questions


compute the factorial of a number entered in one text field by pressing the compute button and output displayed in another text field in javafx

Advertisement
View Answers

August 11, 2010 at 4:31 PM


Hi Friend,

We have created an example in swing. Here is the code:

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

class FactorialExample extends JFrame{
JTextField t1,t2;
FactorialExample(){
JLabel l1=new JLabel("Enter Number: ");
JLabel l2=new JLabel("Factorial of Input Number: ");
t1=new JTextField(20);
t2=new JTextField(20);
JPanel p=new JPanel(new GridLayout(3,2));
JButton b=new JButton("Find");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String number=t1.getText();
int num=Integer.parseInt(number);
long fac=num;
for(int i=num;i>1;i--)
{
fac=fac*(i-1);
}
t2.setText(Long.toString(fac));

}
});
p.add(l1);
p.add(t1);
p.add(l2);
p.add(t2);
p.add(b);
add(p);
setVisible(true);
pack();
}
public static void main(String[] args) {
FactorialExample f=new FactorialExample();
}
}

Thanks


Related Tutorials/Questions & Answers:
java fx - Java Interview Questions
java fx  compute the factorial of a number entered in one text field by pressing the compute button and output displayed in another text field in javafx  Hi Friend, We have created an example in swing. Here
converting java class to java fx class
converting java class to java fx class   i am working on a java project which would convert text to speech and speech to text. i have developed a java file that would work for text to speech. it is working fine as a .java file
Advertisements
What is Java FX?
What is Java FX? The JavaFX technology is yet another set of technologies... technology can be used to develop applications for mobile devices. Java FX?s promises Java FX technology can be used to create highly interactive
Java fx for windows
Java fx for windows         JavaFX, a family of products, is based on Java technology to create Rich Internet applications (RIAs) that simplifies and speed up the creation
Data Binding With fx:Model tag in Flex4
Data Binding with fx:Model tag  in Flex4: The <fx:Model> tag... and these node of objects have a scalar values. The tag is <fx:Model>. Syntax...;?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
Data Binding with XML Data Model in Flex4
Data Binding with XML DataModel in Flex4: The <fx:XML> tag contains a data in tree format. It is just like a <fx:Model> tag. The flex builder compiles the <fx:XML> tag into literal XML data. You can use this data
Local style sheets in Flex4
Local style sheets in Flex4: You can set the style of components in <fx... is following: <fx:Style> @namespace namespace_identifiernamespace_string; selector_name { style_property: value; [...] } </fx:Style>
IT115 programming with java - Java Beginners
comment lines. 1. Using valid Java code from Chapter 1 to 4, create... sections in your principle class ( constructor fx, accessor fx, custom fx, private data members) ,along with the three custom fx use input(), calculation
Java Courses
Java FX Programming JSF Java project based training...Java Courses We are conduction various Java Courses online, onsite and classroom training. Our Java Courses content is well designed and supported with many
java
java  diff bt core java and java
java
java  what is java
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
 

 

 

DMCA.com