0

Java GUI using intellij

hello everyone, can help me to solve the problem. i want to make program to calculate the interpolation with Java GUI. when the calculate button pressed, there is no value on the inputText1. i want the inputText1 display the value after all Textfield has has value from user input. the code is below: import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Scanner; public class contohInterpolasi { private Scanner userInput; private JPanel panelInterpolasi; private JLabel labelX1; private JLabel labelX2; private JLabel labelY1; private JLabel labelY2; private JLabel labelY; private JLabel labelX; private JTextField textX1; private JButton buttonCalculate; private JFormattedTextField inputTextX; private JFormattedTextField inputTextY; private JFormattedTextField inputTextX1; private JFormattedTextField inputTextX2; private JFormattedTextField inputTextY1; private JFormattedTextField inputTextY2; private JButton exit; contohInterpolasi() { exit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); buttonCalculate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double X1 = (double) inputTextX1.getValue(); double X2 = (double) inputTextX2.getValue(); double Y1 = (double) inputTextY1.getValue(); double Y2 = (double) inputTextY2.getValue(); double Y = (double) inputTextY.getValue(); double X = ((Y-Y1)*(X2-X1)/(Y2-Y1))+X1; } }); }

25th Aug 2021, 10:27 AM
Choi_142
Choi_142 - avatar
1 Respuesta
0
continue program from above: public static void main(String[] args) { JFrame frame = new JFrame("contohInterpolasi"); frame.setContentPane(new contohInterpolasi().panelInterpolasi); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); frame.setSize(600,600); } }
25th Aug 2021, 10:30 AM
Choi_142
Choi_142 - avatar