Advertisement
HrvojeH

Untitled

Jun 12th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. public class GUI extends JFrame {
  2. String[] lvls = {"Pirate Cave", "Forest Maze", "Spider Den","testic"};
  3. JComboBox<String> lvlMenu;
  4. JComboBox<String> dropsMenu;
  5. JPanel topPanel;
  6. JPanel inputPanel;
  7. JPanel buttonTextPanel;
  8. JButton appendButton;
  9. JTextArea inputTextArea;
  10. JLabel selectAmmountLabel;
  11. JPanel textAreaPanel;
  12.  
  13. String[] pirateCaveDrops = {"Pirate Rum", "First Mate's Hook"};
  14. String[] forestMazeDrops = {"Speed Sprouts", "Pet Eggs"};
  15. String[] spiderDenDrops = {"Healing Ichor", "Spider's Eye Ring", "Poison Fang Dagger"};
  16. HashMap<String, String[]> lvlMap = new HashMap<>();
  17.  
  18.  
  19.  
  20. public GUI() {
  21. setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  22. setLayout(new GridLayout(0,1));
  23. selectAmmountLabel = new JLabel("Select ammount:");
  24. topPanel = new JPanel();
  25. inputPanel = new JPanel(new GridLayout(0,1));
  26.  
  27. buttonTextPanel = new JPanel();
  28. textAreaPanel = new JPanel();
  29. textAreaPanel.setLayout(new BorderLayout());
  30.  
  31.  
  32. appendButton = new JButton("Done");
  33.  
  34. inputTextArea = new JTextArea();
  35.  
  36. lvlMenu = new JComboBox<>(lvls);
  37. dropsMenu = new JComboBox<>(pirateCaveDrops);
  38. topPanel.add(lvlMenu);
  39. topPanel.add(dropsMenu);
  40. textAreaPanel.add(inputTextArea,BorderLayout.CENTER);
  41.  
  42. inputPanel.add(selectAmmountLabel);
  43. inputPanel.add(buttonTextPanel);
  44.  
  45. buttonTextPanel.add(textAreaPanel);
  46.  
  47. buttonTextPanel.add(appendButton);
  48.  
  49.  
  50.  
  51.  
  52. add(topPanel);
  53. add(inputPanel);
  54. setTitle("Realm of the Mad God Item tracker");
  55.  
  56.  
  57.  
  58. lvlMap.put("Pirate Cave", pirateCaveDrops);
  59. lvlMap.put("Forest Maze", forestMazeDrops);
  60. lvlMap.put("Spider Den", spiderDenDrops);
  61.  
  62. lvlMenu.addActionListener(e -> {
  63. JComboBox jcb = (JComboBox) e.getSource();
  64. String lvlName = jcb.getSelectedItem().toString();
  65. dropsMenu.removeAllItems();
  66.  
  67. if(lvlMap.containsKey(lvlName)){
  68. for(String s : lvlMap.get(lvlName)){
  69. dropsMenu.addItem(s);
  70. }
  71. }
  72. else{
  73. dropsMenu.addItem("No Items Found");
  74. }
  75. });
  76.  
  77.  
  78.  
  79. }
  80.  
  81.  
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement