A.4. Modules

To explore what modules are, we should take a peek at a common feature from other languages: the import. Consider the following class in Java, adapted from a tutorial at www.javatpoint.com/java-swing.

Listing A.16. Example of a Java import
import javax.swing.*;

public class SwingHelloWorld {
     public static void main(String[] args) {
               JFrame f=new JFrame();
               JButton b=new JButton("click");       1
               b.setBounds(130,100,100, 40);         2
               f.add(b);                             3
               f.setSize(400,500);                   4
               f.setLayout(null);
               f.setVisible(true);
    }
}
  • 1 Creates instance of button
  • 2 Sets x axis, y axis, width, height
  • 3 Adds button to UI
  • 4 Sets button size

In this Java-based example, we’re programmatically creating a button and placing it in a window. If you don’t know Java, this ...

Get Web Components in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.