Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

SwingHello

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.SwingUtilities;

public class SwingHello extends JFrame implements ActionListener {
    private JPanel contentPane;
    private JButton helloButton;
    private int count;
    
    public SwingHello(){
        this.count = 0;
        this.setTitle("Hello World");
        this.setSize(300,300);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        initControls();
        this.setVisible(true);
    }

    public void initControls(){
        contentPane = new JPanel();
        helloButton = new JButton("Hello");
        helloButton.addActionListener(this);
        
        contentPane.add(helloButton);
        this.add(contentPane);
    }

    @Override
    public void actionPerformed(ActionEvent e){
        helloButton.setText("Clicked " + ++count);
    }

    public static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run(){
                    new SwingHello();
                }
            });
    }

}