/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package javaapplication3;
import java.awt.Color;
import static java.awt.Color.black;
import static java.awt.Color.blue;
import static java.awt.Color.pink;
import static java.awt.Color.yellow;
import java.awt.PopupMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
* @author Student
*/
public class JavaApplication3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setLocation(700,300);
frame.setSize(700,300);
frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
frame.setVisible(true);
JPanel panel = new JPanel();
JTextField textField = new JTextField("ВВОД",20);
textField.setBackground(pink);
panel.add(textField);
JLabel label = new JLabel();
label.setBounds(50,50,100,100);
label.setForeground(Color.RED);
panel.add(label);
JButton button = new JButton("Добавить");
button.setBackground(black);
button.setForeground(yellow);
button.setBounds(40,50,500,50);
panel.add(button);
frame.add(panel);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
String name = textField.getText();
ArrayList <String> list = new ArrayList<String>();
list.add(name);
System.out.println(list);
label.setText(name);
}
});
}
}