Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Help!!! please Help!!
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JavaKing




PostPosted: Sat May 22, 2010 10:18 am   Post subject: 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.

Java:

/*
 * 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")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    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();
    }// </editor-fold>

    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[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Factorial().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration

}


Mod Edit: Edited title and added code tags.
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sat May 22, 2010 10:48 am   Post subject: 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]
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Dan




PostPosted: Sat May 22, 2010 3:13 pm   Post subject: 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.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: