Guest User

Wallsafer_Gui

a guest
Oct 1st, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.67 KB | None | 0 0
  1. package wall_safer;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.EventQueue;
  5.  
  6. import javax.swing.JFrame;
  7. import javax.swing.JPanel;
  8. import javax.swing.border.EmptyBorder;
  9.  
  10. import java.awt.Toolkit;
  11.  
  12. import javax.swing.JCheckBoxMenuItem;
  13. import javax.swing.JLabel;
  14. import javax.swing.JComboBox;
  15. import javax.swing.DefaultComboBoxModel;
  16. import javax.swing.JMenu;
  17. import javax.swing.JMenuBar;
  18. import javax.swing.JMenuItem;
  19. import javax.swing.JSpinner;
  20. import javax.swing.SpinnerNumberModel;
  21. import javax.swing.JSlider;
  22. import java.awt.event.ActionListener;
  23. import java.awt.event.ActionEvent;
  24.  
  25. public class Gui extends JFrame {
  26.     public static boolean scopeboolean = false;
  27.     public static boolean worldboolean = false;
  28.     public static int hp;
  29.     public static int foodamount;
  30.     public static String food;
  31.     private JPanel contentPane;
  32.  
  33.     /**
  34.      * Launch the application.
  35.      */
  36.     public static void main(String[] args) {
  37.         EventQueue.invokeLater(new Runnable() {
  38.             public void run() {
  39.                 try {
  40.                     Gui frame = new Gui();
  41.                     frame.setVisible(true);
  42.                 } catch (Exception e) {
  43.                     e.printStackTrace();
  44.                 }
  45.             }
  46.         });
  47.     }
  48.  
  49.     /**
  50.      * Create the frame.
  51.      */
  52.     public Gui() {
  53.         setIconImage(Toolkit.getDefaultToolkit().getImage(
  54.                 "C:\\Users\\MY-PC\\Desktop\\abs.jpg"));
  55.         setTitle(" Wall Safer");
  56.         setAlwaysOnTop(true);
  57.         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  58.         setBounds(100, 100, 249, 231);
  59.  
  60.         JMenuBar menuBar = new JMenuBar();
  61.         setJMenuBar(menuBar);
  62.         contentPane = new JPanel();
  63.         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  64.         setContentPane(contentPane);
  65.         contentPane.setLayout(null);
  66.  
  67.         JLabel lblFoodType = new JLabel("Food Type");
  68.         lblFoodType.setBounds(30, 25, 62, 14);
  69.         contentPane.add(lblFoodType);
  70.  
  71.         final JComboBox comboBox = new JComboBox();
  72.         comboBox.setModel(new DefaultComboBoxModel(new String[] { "Trout",
  73.                 "Salmon", "Tuna", "Lobster", "Swordfish", "Monkfish", "Curry",
  74.                 "Shark" }));
  75.         comboBox.setBounds(10, 39, 100, 22);
  76.         contentPane.add(comboBox);
  77.        
  78.         JLabel lblWithdrawAmount = new JLabel("Withdraw Amount");
  79.         lblWithdrawAmount.setBounds(116, 25, 115, 14);
  80.         contentPane.add(lblWithdrawAmount);
  81.  
  82.         //the food amount
  83.         final JSpinner spinner = new JSpinner();
  84.         spinner.setModel(new SpinnerNumberModel(1, 1, 28, 3));
  85.         spinner.setBounds(135, 41, 36, 18);
  86.         contentPane.add(spinner);
  87.  
  88.         // the hp bar
  89.         final JSlider slider = new JSlider();
  90.         slider.setValue(35);
  91.         slider.setPaintTicks(true);
  92.         slider.setPaintLabels(true);
  93.         slider.setMinorTickSpacing(5);
  94.         slider.setMajorTickSpacing(10);
  95.         slider.setBounds(10, 132, 210, 40);
  96.         contentPane.add(slider);
  97.  
  98.         JLabel lblHitPoints = new JLabel("Hit Points");
  99.         lblHitPoints.setBounds(100, 107, 71, 14);
  100.         contentPane.add(lblHitPoints);
  101.  
  102.         JMenu menu = new JMenu("Settings");
  103.         menuBar.add(menu);
  104.         JMenuItem start = new JMenuItem("Start");
  105.         menu.add(start);
  106.         start.addActionListener(new ActionListener() {
  107.             public void actionPerformed(ActionEvent arg0) {
  108.                 setData();
  109.                 dispose();
  110.             }
  111.  
  112.             private void setData() {
  113.                 hp = slider.getValue();
  114.                 foodamount = (Integer) spinner.getValue();
  115.                 food = comboBox.getSelectedItem().toString();
  116.             }
  117.         });
  118.         final JCheckBoxMenuItem scope = new JCheckBoxMenuItem("Scope");
  119.         scope.addActionListener(new ActionListener() {
  120.             public void actionPerformed(ActionEvent arg0) {
  121.                 scopeboolean = true;
  122.             }
  123.         });
  124.         menu.add(scope);
  125.         JCheckBoxMenuItem worldhopping = new JCheckBoxMenuItem("World Hopping");
  126.         worldhopping.addActionListener(new ActionListener() {
  127.             public void actionPerformed(ActionEvent arg0) {
  128.                 worldboolean = true;
  129.             }
  130.         });
  131.         menu.add(worldhopping);
  132.  
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment