JAML/src/main/java/tech/nevets/jaml/gui/HomeGui.java

76 lines
2.9 KiB
Java

package tech.nevets.jaml.gui;
import tech.nevets.jaml.JAML;
import tech.nevets.jaml.listeners.RightClickListener;
import tech.nevets.jaml.util.ImageUtils;
import tech.nevets.jaml.util.ProfileUtils;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class HomeGui extends JFrame {
//private JPanel contentPane;
private JTabbedPane tabPanel;
private JPanel homePanel;
//private JPanel contentPane;
public HomeGui() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 1280, 720);
SpringLayout springLayout = new SpringLayout();
getContentPane().setLayout(springLayout);
addMouseListener(new RightClickListener());
tabPanel = new JTabbedPane();
springLayout.putConstraint(SpringLayout.NORTH, tabPanel, 0, SpringLayout.NORTH, getContentPane());
springLayout.putConstraint(SpringLayout.WEST, tabPanel, 0, SpringLayout.WEST, getContentPane());
springLayout.putConstraint(SpringLayout.SOUTH, tabPanel, 720, SpringLayout.NORTH, getContentPane());
springLayout.putConstraint(SpringLayout.EAST, tabPanel, 1280, SpringLayout.WEST, getContentPane());
tabPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
//setContentPane(tabPanel);
homePanel = new JPanel();
tabPanel.add("Home", homePanel);
getContentPane().add(tabPanel);
JButton newProfileButton = new JButton("Create New Profile");
newProfileButton.setBounds(920, 601, 134, 36);
newProfileButton.addActionListener(al -> {
JAML.guiHandler.startNewProfileGui();
});
homePanel.add(newProfileButton);
JButton launchButton = new JButton("Launch");
launchButton.setBounds(512, 619, 196, 51);
homePanel.add(launchButton);
JComboBox activeProfileDropdown = new JComboBox(ProfileUtils.profileList);
activeProfileDropdown.setBounds(858, 648, 196, 22);
homePanel.add(activeProfileDropdown);
JButton reloadProfileButton = new JButton("Reload Profiles");
reloadProfileButton.setBounds(800, 608, 106, 23);
reloadProfileButton.addActionListener(al -> {
ProfileUtils.getProfileList();
activeProfileDropdown.removeAllItems();
for (int i = 0; i < ProfileUtils.profileList.length; i++) {
activeProfileDropdown.addItem(ProfileUtils.profileList[i]);
}
});
homePanel.add(reloadProfileButton);
JLabel backgroundIcon = new JLabel("");
backgroundIcon.setBounds(0, 25, 1264, 542);
ImageIcon backgroundImg = new ImageIcon(JAML.path + "\\assets\\background.png");
backgroundImg = ImageUtils.resizeIcon(backgroundImg, backgroundIcon.getWidth(), backgroundIcon.getHeight());
backgroundIcon.setIcon(backgroundImg);
homePanel.add(backgroundIcon);
tabPanel.addMouseListener(new RightClickListener());
}
}