xhtml
 

Adding Content

This program adds a single button which does nothing when you press it:

OneButton.java
...
import javax.swing.*;
import java.awt.*;
...
   public void run()
   {
      JFrame frame = new JFrame();
      frame.setTitle("One Button");
      frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
      JButton button = new JButton("Do Nothing");
      frame.add(button);
      frame.pack();
      frame.setLocationByPlatform(true);
      frame.setVisible(true);
   }
...

Here are some notes about the program


Back