JBotSim 1.0-beta has been released with some API changes. All examples have been updated accordingly. Please make sure you are using version 1.0 beta.

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 jbotsimx.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();

    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();