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

class swingExample {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Button Example");
        frame.setSize(300, 100);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JTextField textField = new JTextField(20);
        JButton button = new JButton("Click Here");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textField.setText("Welcome to griet.");
            }
        });
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout());
        panel.add(textField);
        panel.add(button);
        frame.add(panel);
        frame.setVisible(true);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: