Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class GUI extends JFrame {
- private JTextField textField1;
- private JButton generujButton;
- private JButton kopírujButton;
- private JTextArea textArea1;
- private JPanel panelMain;
- public GUI() {
- generujButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- double randomDouble = Math.random()*100;
- int random = (int) Math.round(randomDouble);
- textField1.setText(String.valueOf(random));
- }
- });
- kopírujButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- textArea1.append(textField1.getText()+"\n");
- }
- });
- }
- public static void main(String[] args) {
- GUI gui = new GUI();
- gui.setVisible(true);
- gui.setTitle("náhodné číslo");
- gui.setContentPane(gui.panelMain);
- gui.setSize(300, 200);
- gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement