0

I am trying to pass the value in the text field but I found an error. Here is the code, please guide. getting Run-time error in this line ' double textpk=Double.parseDouble( lp.getText() ); '

        //convetor button

        convrt = new JButton("Convert");
        convrt.setBounds(70,350,120,60);
        convrt.setBackground(Color.DARK_GRAY);
        convrt.setForeground(Color.WHITE);
        Cursor crs=new Cursor(Cursor.HAND_CURSOR);
        convrt.setCursor(crs);
        conn2.add(convrt);

        //pkr text settings
        convrt.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e2)
            {

                String ch=e2.getActionCommand();
                if(ch=="Convert")
                {
                        
                        double textpk=Double.parseDouble( lp.getText() );
                        if(textpk>0)
                        {
                            double textDollar=textpk/165.4;
                            String txt=String.valueOf(textDollar);
                            ld.setText(txt);
                        }
                        else
                        {
                            //money convertion code and set money for dollars
                            JOptionPane.showMessageDialog(conn2,"Please Enter the Amount!");
                        }
                        
                }
            }
        }
        );
        

0 Answers0