
-----------------------------------
JavaKing
Sat May 22, 2010 10:18 am

Java Help!!! please Help!!
-----------------------------------
For some reason my program isn't working. I want to display a button and when the button is clicked the user could input a number then the program will calculate and output the anaswer. 


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Factorial.java
 *
 * Created on May 22, 2010, 10:20:58 AM
 */

/**
 *
 * @author Daniel
 */
public class Factorial extends javax.swing.JFrame {

    /** Creates new form Factorial */
    public Factorial() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // 
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jButton1 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Factorial: Find the factorial of any number");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jTextField1.setText("jTextField1");
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1)
                .addGap(18, 18, 18)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(78, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(257, Short.MAX_VALUE))
        );

        pack();
    }// 

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
      //IMPRTANRDFDDG
        int input = Interger.parstInt.tempTextField.getText
		int	factors=1;
		int count=input;
		try
		{
		while (count>1) //Starts a loop when count is greater than 1
		{
			factors*=count;
			count--;
		}

		}catch(IOException ignored){}
		System.out.println("Answer"+input+"!="+factors);//Outputs the answer




    }

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args

Mod Edit: Edited title and added code tags.

-----------------------------------
Dan
Sat May 22, 2010 10:48 am

Re: Java Help!!! please Help!!
-----------------------------------
The subject of your post goes against the guide lines of the site. Since you are posting in the java help forum we know you need help with java, your subject should reflect what exactly you need help with. in your java program. Secondly you subject was way too long and there was no need for those (now removed) exclamation points.


Also you may want to try placing your code in code tags when posting. They work as follows:

[code="java"]
My java code goes here.
[/code]

-----------------------------------
Dan
Sat May 22, 2010 3:13 pm

RE:Java Help!!! please Help!!
-----------------------------------
This topic is being locked as the user was banned for ban evasion and stealing code.

Note that they are mike123 form http://compsci.ca/v3/viewtopic.php?p=177912.
