import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;
+import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;
import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.main.Version;
+import com.google.common.eventbus.EventBus;
+
/**
* Sonitus main window.
*
*/
public class MainWindow extends JFrame {
+ /** The event bus. */
+ private final EventBus eventBus;
+
/** The tabbed pane displaying all controlled components. */
private final JTabbedPane tabbedPane = new JTabbedPane();
- /** Creates a new main window. */
- public MainWindow() {
+ /**
+ * Creates a new main window.
+ *
+ * @param eventBus
+ * The event bus
+ */
+ public MainWindow(EventBus eventBus) {
super(String.format("Sonitus %s", Version.version()));
+ this.eventBus = eventBus;
+ tabbedPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
getContentPane().add(tabbedPane, BorderLayout.CENTER);
setSize(new Dimension(800, 450));
* The controlled to add
*/
public void addControllers(Controlled controlled) {
- List<Controller> controllers = controlled.controllers();
- if (controllers.isEmpty()) {
- return;
- }
- ControlledPane controlledPane = new ControlledPane(controlled);
- tabbedPane.addTab(controlled.toString(), controlledPane);
+ List<Controller<?>> controllers = controlled.controllers();
+ ControlledPane controlledPane = new ControlledPane(eventBus, controlled);
+ tabbedPane.addTab(controlled.name(), controlledPane);
}
}