Вывод в текстовое поле - Java
Формулировка задачи:
package pilot;
import java.awt.Component;
import java.awt.FlowLayout;
import javax.swing.*;
import java.awt.event.*;
/**
*
* @author Влад
*/
public class Pilot extends JFrame{
private JTextField f1, f2, f3;
private JButton b1;
int i=0;
int a,b,c;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
JFrame fr = new JFrame();
fr.setSize(500, 150);
fr.setLayout(new FlowLayout());
fr.setVisible(true);
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.setLocationRelativeTo(null);
JButton b1 = new JButton("Вычислить");
JTextField f1 = new JTextField(10);
JTextField f2 = new JTextField(10);
JTextField f3 = new JTextField(10);
fr.add(b1);
fr.add(f1);
fr.add(f2);
fr.add(f3);
// ActionListener eHandler = null;
//eHandler e;
// ActionListener eHandler = null;
// b1.addActionListener(eHandler);
}
public class eHandler implements ActionListener
{
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b1)
{
a=Integer.parseInt(f1.getText());
b=Integer.parseInt(f2.getText());
c=a+b;
c = Integer.parseInt(f3.getText());
// f3.setText(c);
}
}
}
}Решение задачи: «Вывод в текстовое поле»
textual
Листинг программы
import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter;