Embedding JBotSim within another GUI

JBotSim's default GUI consists of an outer component called the JViewer, and an inner component called the JTopology. While being often invisible to the user, the JTopology is actually the most important component, responsible for drawing the topology and managing interaction with the user, while the JViewer mainly adds windowing features and some entries in the context menu.

If you design your own graphical app, you may embed the JTopology directly within your graphical container. Here is an example of basic application that creates its own window frame and adds the JTopology into it. Then a custom button is created to add randomly located nodes to the topology (coordinate -1 is interpreted as random).

import io.jbotsim.core.Topology;
import io.jbotsim.ui.JTopology;

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

public class MyCustomApp implements ActionListener{
    Topology tp;

    public MyCustomApp() {
        tp = new Topology();
        JFrame window = new JFrame("MyCustomApp");
        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 MyCustomApp();