Embedding JBotSim's GUI in another application

JBotSim's default GUI consists of a main window (the JViewer), which contains a JTopology component. This component is responsible for most of the the actual features of the GUI.

You can directly embed the JTopology in your own application. Below is an example of application that creates its own window frame and adds the JTopology into it. A button is also added, whose effect is to create a randomly located new node (coordinate -1 means random).

import jbotsim.Topology;
import jbotsim.ui.JTopology;

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

public class EmbeddingApp implements ActionListener{
    Topology tp = new Topology(400,300);

    public EmbeddingApp() {
        JFrame window = new JFrame("EmbeddingApp");
        window.setLayout(new BorderLayout());
        JButton button = new JButton("Add random node");
        window.add(new JTopology(tp));

    public void actionPerformed(ActionEvent e) {

    public static void main(String[] args) {
        new EmbeddingApp();