package net.knarcraft.serverlauncher.userinterface; import net.knarcraft.serverlauncher.profile.Collection; import javax.swing.JFrame; import javax.swing.JTabbedPane; import java.awt.BorderLayout; import java.util.ArrayList; /** * A parent window for server consoles. * Should be toggled with the "View server consoles" button. * Keeps track of all consoles. * * @author Kristian Knarvik * @version 0.0.0.1 * @since 0.0.0.1 */ public class ServerConsoles { private static ServerConsoles serverConsoles; private static JFrame frame; private static JTabbedPane consolesTab; public ServerConsoles() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); consolesTab = new JTabbedPane(JTabbedPane.TOP); frame.getContentPane().add(consolesTab, BorderLayout.CENTER); serverConsoles = this; } public static ServerConsoles getGUI() { return serverConsoles; } public static void show() { frame.setVisible(true); } public static void update(ArrayList collections) { consolesTab.removeAll(); for (Collection collection : collections) { consolesTab.add(collection.getName(), collection.getServerConsole().getPanel()); } } public static Console addTab(String name) { return new Console(consolesTab, name); } }