Set up basic UI
This commit is contained in:
@@ -6,15 +6,26 @@ 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{
|
||||
public final class MainFrame extends BrowserFrame {
|
||||
@Getter
|
||||
private Tab openTab;
|
||||
|
||||
@Getter
|
||||
private DOMContainerPanel domContainerPanel;
|
||||
|
||||
public MainFrame() {
|
||||
super(new TabButtonView());
|
||||
|
||||
this.setSize(800, 600);
|
||||
|
||||
try {
|
||||
@@ -24,5 +35,47 @@ public final class MainFrame extends BrowserFrame{
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
this.add(this.topBar, BorderLayout.NORTH);
|
||||
this.domContainerPanel = new DOMContainerPanel();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user