JFrame_example_

Before I waste too much time on this, would someone please remind me why this is a bad idea and shouldn’t be pursued. Other than the fact that I have two windows (one of which I didn’t ask for) it seems to work ok. ActionListener is used to trap button clicks.

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

void setup() {
  JFrame frame = new JFrame("JFrame Demo");
  frame.setBounds(500, 300, 300, 100);
  JButton btn = new JButton("Press me.");
  btn.setBounds(30,30,100,30);
  frame.add(btn);
  frame.setLayout(null); // Need this or btn takes up entire window
  frame.setVisible(true);
  ActionListener actionListener = new ActionListener() {
    public void actionPerformed(ActionEvent actionEvent) {
      println("JFrame btn hit.");
    }
  };
  btn.addActionListener(actionListener);
}

wnd