Share on Google+Share on Google+

Suraj Arun Nalawade
program for factorial
1 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners

how to set size of buttons on frame


View Answers

November 15, 2010 at 1:14 PM

Hi Friend,

Using the setPreferredSize(new Dimension(40,15)); method, you can set the button size in awt in java.

Here is your required code:

import java.awt.*;
import java.awt.event.*;
import java.util.regex.*;
class ButtonSize extends Frame{
    Label l;
        Label lab=new Label("Enter number to find its factorial: ");
        final TextField text=new TextField(20);
        Button b=new Button("Find");
        Panel p=new Panel();
        l=new Label();
        Panel pan=new Panel();
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                String input=text.getText();
    Pattern p = Pattern.compile("[A-Z,a-z,&%$#@!()*^]");
    Matcher m = p.matcher(input);
    l.setText("*Enter only numeric value!");
else if(input.equals("")){
    l.setText("*Enter value!");

    int num=Integer.parseInt(input);
    long fac=num;
    for(int i=num;i>1;i--){
    l.setText("Factorial Of Number "+input+" is: "+Long.toString(fac));
        b.setPreferredSize(new Dimension(40,15));     
    public static void main(String[] args){
        new ButtonSize();


Related Tutorials/Questions & Answers:
program for factorial
program for factorial  how to set size of buttons on frame
program for factorial
program for factorial  how to set size of buttons on frame
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
Factorial Program in Java
Factorial program in Java helps programmer to write factors of any given... exception". Example of Factorial program in Java: import*; class... execution of the program. BufferReader is defined under the Java I/O package
Write a program to calculate factorial of any given number
program to calculate factorial of any given number. First of all define a class... Factorial Examples - Java Factorial Example to calculate factorial of any.... As in this program we are going to insert certain instruction by creating buffer reader
Write a program to find a factorial in any given number
Write a program to find a factorial in any given number This programming tutorial will teach you how to write a factorial of any given number... that is equal to 24, and factorial of  0! is 0 always.Example : A program to find
find the factorial
find the factorial  how to find the factorial through the while loop...) { int value = 5, factorial = 1, temp = value; while (temp > 0) { factorial *= temp; temp
factorial of fibonacci
factorial of fibonacci   A code for the factorial of a fibonacci series. Example when the user enters 6, the fibonacci series is 8 and the factorial will be 8! or 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1. So if the user enters the number 6
factorial - Java Beginners
factorial Example in Java  The factorial method is used frequently in probability problems. The factorial of a positive integer n (written as n!) is equal... class Factorial Example{ public static long factorial(int n){ if(n <
How to get factorial in mysql
How to get factorial in mysql  Hi, In order to improve the speed... alot for a function in mysql to find factorial numbers of a number and couldn't.... example: for 1155, the factorial numbers would be: 3, 5, 7, 11 Thank you
Calculate factorial of a number.
Calculate factorial of a number.  How to calculate factorial...; import; public class Factorial { public static...; } System.out.println(result); } } Description: - Factorial of any
Finding a Factorial using while loop
Finding a Factorial using while loop   ... are going to find out the factorial of 12 by using the while loop. In while loop... the scriptlet to calculate the factorial of 12. In the scriptlet we generally writes
factorial using recursive
factorial using recursive  can please give this code !i am going to do a factorial function using recursion definition and then . my professor told me that we are going to create a three screen. the first screen should be input
Finding a Factorial using while loop
; factorial* temp and keep on decreasing the value of temp by l. Code of the Program...Finding a Factorial using while loop      In this example we are going to find out the factorial of 12 by using
Calculate factorial Using Recursion
by using recursion in jsp. To make a program on factorial, firstly it must... a program on factorial by using recursion in jsp we are going to design a html page...Calculate factorial Using Recursion  
Java Swing Compute Factorial
Java Swing Compute Factorial In this section, we are going to find the factorial of a given number. Here an user is allowed to enter a number into the text field whose factorial is to be determined. On pressing the button the value
Calculating factorial in JRuby
Calculating factorial in JRuby   ... program" example you must be aware with the way to run JRuby program. Now in this example you will know to "Calculate Factorial in JRuby"
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
find factorial of any number using recursion
find factorial of any number using recursion  error in 14 line ; expected int rec( int a) ^ how to resolve this.please correct the code. import*; class Fact { public static void main(String[]arg)throws IOException
Java Program - Java Beginners
Java Program  Write a program to find the Factorial of a number using Recursion. Factorial can be defined as Factorial(n) = 1 * 2 * 3 ?.* (n-1... FactorialUsingRecursion(); System.out.println("Factorial of 2 = " + f.findFactorial(2
java program code
java program code  can any one write a program (class) which will have two methods Fibonacci and Factorial, which will be a void and a return respectively. i will be glad if it can have a good display results
program  any program of hotel or school management
program  write a program different between to dates in terms of days in java
program  write a html program in show table and this word in box
program  write a javascript program to create a application form with validation
program  program of jdbc using ms access for creating table
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null