import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.Scanner;

    public class ExpressionCalculatorPanel extends JPanel
   {
   // Variables to be used
      private JLabel inputLabel, resultLabel;
      private JTextField ExpressionCalculator;
      private JButton computeButton;
   
   //-----------------------------------------------------------------
   //  Constructor: Sets up the main GUI components.
   //-----------------------------------------------------------------
       public ExpressionCalculatorPanel()
      {
         inputLabel = new JLabel ("Enter a value of x");
         resultLabel = new JLabel ("Final result = ---");
         
         ExpressionCalculator = new JTextField (5);
         ExpressionCalculator.addActionListener(new ButtonListener());
      
      
      	// Set buttons and listeners
         computeButton = new JButton("Compute Final Result");
         computeButton.addActionListener(new ButtonListener());
      
                
      	// Add to panels
         add (computeButton);
         add (inputLabel);
         add (resultLabel);
         
      
         setPreferredSize (new Dimension(300, 75));
         setBackground (Color.white);
      }
   
   //*****************************************************************
   //  Represents an action listener for the temperature input field.
   //*****************************************************************
       private class ButtonListener implements ActionListener
      {
      //--------------------------------------------------------------
      //  Performs the conversion when the enter key is pressed in
      //  the text field.
      //--------------------------------------------------------------
          public void actionPerformed (ActionEvent event)
         {
                
			int x, String, Result, Stringresult;
			
		//Math.sqrt (Math.pow(x,5)-(2)*Math.pow(x,3)-
          // Math.abs(5)*Math.pow(x,2)+(4)*(x));
         String stringResult = Double.toString(result);
        ExpressionCalculator.setText("Final result:"+ Result);
			

			}

What problem(s) are you having? What is it not doing that you intend it to do? What does it do that you don't want it to do? What works? Please be more specific.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.