Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gui;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.SwingUtilities;
- import data.Data;
- public class GUI extends JFrame {
- private JFrame frame;
- private boolean start;
- private static int chosenBarType;
- private static JComboBox<Object> barTypeJCB;
- public GUI() {
- gui();
- }
- public void gui() {
- frame = new JFrame("Smelter");
- frame.setSize(250, 80);
- frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- frame.setLocationRelativeTo(null);
- JPanel panel = new JPanel();
- JPanel optionsPanel = new JPanel();
- barTypeJCB = new JComboBox<>();
- barTypeJCB.setModel(new DefaultComboBoxModel<Object>(Data.bars));
- optionsPanel.add(barTypeJCB);
- panel.add(optionsPanel);
- JButton startButton = new JButton("Start");
- startButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- chosenBarType = barTypeJCB.getSelectedIndex();
- start = true;
- frame.dispose();
- }
- });
- panel.add(startButton);
- frame.add(panel);
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- frame.setVisible(true);
- }
- });
- }
- public static int getBarType() {
- return chosenBarType;
- }
- public static String getBarTypeString() {
- return Data.bars[barTypeJCB.getSelectedIndex()];
- }
- public boolean getStart() {
- return start;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement