Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Comission Calculator not performing

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Comission Calculator not performing

    Hi everyone. There doesn't seem to be an error on this IDE convertion calculator. Its the actual exercise Java offers to beginners. When I enter the digits though, I get this error message : run:
    Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.



     
     
     
    /*
     * To Convert Celcius to Farenheit
     */
     
    /**
     *
     * @author user
     */
    public class CelsiusConverterGUI extends javax.swing.JFrame {
     
        /**
         * Creates new form CelsiusConverterGUI
         */
        public CelsiusConverterGUI() {
            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() {
     
            jTextField1 = new javax.swing.JTextField();
            CelsiusjLabel1 = new javax.swing.JLabel();
            ConvertjButton1 = new javax.swing.JButton();
            FarenheitJLabel2 = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("CelsiusConverterProject");
     
            jTextField1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextField1ActionPerformed(evt);
                }
            });
     
            CelsiusjLabel1.setText("Celsius");
     
            ConvertjButton1.setText("Convert");
            ConvertjButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ConvertjButton1ActionPerformed(evt);
                }
            });
     
            FarenheitJLabel2.setText("Farenheit");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(CelsiusjLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(ConvertjButton1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(FarenheitJLabel2)))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
     
            layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CelsiusjLabel1, ConvertjButton1, jTextField1});
     
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(CelsiusjLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(ConvertjButton1)
                        .addComponent(FarenheitJLabel2))
                    .addGap(0, 15, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>                        
     
        private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
            // TODO add your handling code here:
        }                                           
     
        private void ConvertjButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                
              //Parse degrees Celsius as a double and convert to Fahrenheit.
        int tempFahr = (int)((Double.parseDouble(tempTextField.getText()))
                * 1.8 + 32);
        fahrenheitLabel.setText(tempFahr + " Fahrenheit");
        }                                               
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see [url=http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html]How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)[/url] 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(CelsiusConverterGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
     
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(() -> {
                new CelsiusConverterGUI().setVisible(true);
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.JLabel CelsiusjLabel1;
        private javax.swing.JButton ConvertjButton1;
        private javax.swing.JLabel FarenheitJLabel2;
        private javax.swing.JTextField jTextField1;
        // End of variables declaration                   
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,580
    Thanks
    49
    Thanked 2,233 Times in 2,205 Posts

    Default Re: Comission Calculator not performing

    There are compiler errors that need to be fixed before trying to execute the code. I compiled it in 1.8.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Comission Calculator not performing

    Would you share with me the line containing the error ? I'm using Netbeans and not getting any error message.
    thanks

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,580
    Thanks
    49
    Thanked 2,233 Times in 2,205 Posts

    Default Re: Comission Calculator not performing

    You need to learn how to use Netbeans. I don't use NB and can't help you.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Sep 2013
    Posts
    68
    My Mood
    Confused
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: Comission Calculator not performing

    In my IDE I got compilation error in these lines...
    int tempFahr = (int) ((Double.parseDouble(tempTextField.getText())) * 1.8 + 32);
    fahrenheitLabel.setText(tempFahr + " Fahrenheit");

    tempTextField and fahrenheitLabel are not defined.

    instead of above code it should be
    int tempFahr = (int) ((Double.parseDouble(jTextField1.getText())) * 1.8 + 32);
    FarenheitJLabel2.setText(tempFahr + " Fahrenheit");
    Last edited by aprabhat; May 16th, 2014 at 03:22 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,580
    Thanks
    49
    Thanked 2,233 Times in 2,205 Posts

    Default Re: Comission Calculator not performing

    @aprabhat Can you tell the OP how to use his IDE so he can see errors like this?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Sep 2013
    Posts
    68
    My Mood
    Confused
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: Comission Calculator not performing

    In Netbeans IDE the editor window is not showing any error symbol may be Netbeans is not able to scan these lines, but in eclipse is properly showing the error in the above mentioned lines.
    If you want to see the error in Netbeans IDE then first run your project in debug mode (use Ctrl + F5) then the IDE ig going to show you errors.

    Hope this help you out.

Similar Threads

  1. Performing operations without using ARithmetic Operators
    By farrahdee in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 24th, 2013, 06:49 AM
  2. Replies: 4
    Last Post: April 13th, 2013, 02:40 AM
  3. java: performing modification in file.
    By basha2013 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 8th, 2013, 10:41 PM
  4. [SOLVED] Performing Division with Double Variables
    By bgroenks96 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 5th, 2011, 05:36 PM
  5. my FileReader(i think) isn't performing properly..
    By weej25aya in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 21st, 2011, 10:06 PM