/* Author: Maple * Dec. 12 2025 * */ package org.openautonomousconnection.webclient.ui; import lombok.Getter; import org.openautonomousconnection.webclient.network.website.tab.Tab; import org.openautonomousconnection.webclient.ui.dom.DOMContainerPanel; import org.openautonomousconnection.webclient.ui.tab.TabButton; import org.openautonomousconnection.webclient.ui.tab.TabButtonView; import javax.swing.*; import java.awt.*; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; public final class MainFrame extends BrowserFrame { @Getter private Tab openTab; @Getter private final DOMContainerPanel domContainerPanel; public MainFrame() { super(new TabButtonView()); this.setSize(800, 600); try { this.openTab = new Tab( URI.create("web://open-autonomous-connection.org").toURL() ); } catch (MalformedURLException e) { throw new RuntimeException(e); } this.add(this.topBar, BorderLayout.NORTH); this.domContainerPanel = new DOMContainerPanel(); this.add(this.domContainerPanel, BorderLayout.CENTER); } private void init() { this.open(this.openTab); } @Override public TabButtonView getTopBar() { return (TabButtonView) this.topBar; } public void setOpenTab(int index) { this.openTab = this.getTopBar().getButton(index).getTab(); this.getTopBar().getButton(index).grabFocus(); } public void setOpenTab(Tab tab) { for(TabButton button : this.getTopBar().getTabButtons()) if(button.getTab().equals(tab)) { this.openTab = button.getTab(); button.grabFocus(); } } public void open(URL url) { TabButton button = new TabButton(url); this.getTopBar().addButton(button); button.grabFocus(); } public void open(Tab tab) { TabButton button = new TabButton(tab); this.getTopBar().addButton(button); button.grabFocus(); } }