mmb.menu.world.window.TabRecipes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multimachinebuilder Show documentation
Show all versions of multimachinebuilder Show documentation
Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world.
THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<
/**
*
*/
package mmb.menu.world.window;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
import io.vavr.Tuple2;
/**
* @author oskar
*
*/
public class TabRecipes extends JPanel {
private static final long serialVersionUID = -2195639936444264957L;
private static final List>> tabs = new ArrayList<>();
/**
* Adds a tab
* @param tab a function, which returns tab title and its component
*/
public static void add(Supplier> tab) {
tabs.add(tab);
}
/**
* Create the panel.
*/
public TabRecipes() {
setLayout(new MigLayout("", "[grow]", "[][grow]"));
JLabel lblNewLabel = new JLabel("Select a recipe group, or search using inventory");
add(lblNewLabel, "flowx,cell 0 0,growx");
JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP);
for(Supplier> tabsup: tabs) {
Tuple2 result = tabsup.get();
tabbedPane.add(result._1, result._2);
}
add(tabbedPane, "cell 0 1,grow");
}
}