NissanNut

SuperheaterUI.java 0.1

Nov 14th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.38 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JPanel;
  5. import javax.swing.border.EmptyBorder;
  6. import javax.swing.JList;
  7. import javax.swing.JSlider;
  8. import javax.swing.JCheckBox;
  9. import javax.swing.AbstractListModel;
  10. import javax.swing.JButton;
  11. import java.awt.event.ActionListener;
  12. import java.awt.event.ActionEvent;
  13. import javax.swing.JLabel;
  14. import javax.swing.SwingConstants;
  15. import java.awt.Font;
  16. import java.awt.Color;
  17. import java.awt.Panel;
  18. import javax.swing.ImageIcon;
  19. import java.awt.Toolkit;
  20.  
  21.  
  22. @SuppressWarnings("serial")
  23. public class SuperheaterUI extends JFrame {
  24.     boolean start = false;
  25.     JCheckBox chckbxAntiban, boxCenter, boxNorth, boxSouth, boxEast, boxWest;
  26.     JSlider slider;
  27.     JLabel lblMouseSpeed;
  28.     Panel panel;
  29.     @SuppressWarnings("rawtypes")
  30.     JList list;
  31.     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.                     SuperheaterUI frame = new SuperheaterUI();
  41.                     frame.setVisible(true);
  42.                 } catch (Exception e) {
  43.                     e.printStackTrace();
  44.                 }
  45.             }
  46.         });
  47.     }
  48.  
  49.     /**
  50.      * Create the frame.
  51.      */
  52.     @SuppressWarnings({ "rawtypes", "unchecked", "serial" })
  53.     public SuperheaterUI() {
  54.         setIconImage(Toolkit.getDefaultToolkit().getImage(SuperheaterUI.class.getResource("/resources/settings.png")));
  55.         setTitle("Settings");
  56.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  57.         setBounds(100, 100, 250, 305);
  58.         contentPane = new JPanel();
  59.         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  60.         setContentPane(contentPane);
  61.         contentPane.setLayout(null);
  62.        
  63.         list = new JList();
  64.         list.setBackground(Color.WHITE);
  65.         list.setBounds(168, 36, 56, 128);
  66.         list.setModel(new AbstractListModel() {
  67.             String[] values = new String[] {" Bronze", " Iron", " Steel", " Silver", " Gold", " Mithril", " Adamant", " Rune"};
  68.             public int getSize() {
  69.                 return values.length;
  70.             }
  71.             public Object getElementAt(int index) {
  72.                 return values[index];
  73.             }
  74.         });
  75.         contentPane.add(list);
  76.        
  77.         JCheckBox chckbxNewCheckBox = new JCheckBox("Fire Staff");
  78.         chckbxNewCheckBox.setBounds(10, 36, 71, 23);
  79.         chckbxNewCheckBox.setEnabled(false);
  80.         chckbxNewCheckBox.setSelected(true);
  81.         contentPane.add(chckbxNewCheckBox);
  82.        
  83.         slider = new JSlider();
  84.         slider.setPaintTicks(true);
  85.         slider.setToolTipText("Mosue Speed");
  86.         slider.setBounds(0, 200, 234, 27);
  87.         slider.setValue(5);
  88.         slider.setMaximum(9);
  89.         slider.setMinimum(1);
  90.         contentPane.add(slider);
  91.        
  92.         JButton btnNewButton = new JButton("Start");
  93.         btnNewButton.addActionListener(new ActionListener() {
  94.             public void actionPerformed(ActionEvent arg0) {
  95.                 Color c = Color.white;
  96.                
  97.                 if (list.getSelectedIndex() == -1)
  98.                     list.setBackground(Color.orange);
  99.                 else
  100.                     list.setBackground(Color.WHITE);
  101.  
  102.                 if (!(boxNorth.isSelected() || boxSouth.isSelected() || boxEast.isSelected() || boxWest.isSelected()))
  103.                     c = Color.orange;
  104.                
  105.                 panel.setBackground(c);
  106.                 boxCenter.setBackground(c);
  107.                 boxNorth.setBackground(c);
  108.                 boxSouth.setBackground(c);
  109.                 boxEast.setBackground(c);
  110.                 boxWest.setBackground(c);
  111.                
  112.                 if (list.getSelectedIndex() != -1 && (boxNorth.isSelected() || boxSouth.isSelected() || boxEast.isSelected() || boxWest.isSelected())){
  113.                     start = true;
  114.                     dispose();
  115.                 }
  116.                    
  117.             }
  118.         });
  119.         btnNewButton.setBounds(75, 233, 89, 23);
  120.         contentPane.add(btnNewButton);
  121.        
  122.         lblMouseSpeed = new JLabel("Mouse Speed:");
  123.         lblMouseSpeed.setHorizontalAlignment(SwingConstants.CENTER);
  124.         lblMouseSpeed.setBounds(0, 175, 219, 14);
  125.         contentPane.add(lblMouseSpeed);
  126.        
  127.         JLabel lblNewLabel = new JLabel("Nissan's Superheater");
  128.         lblNewLabel.setIcon(new ImageIcon(SuperheaterUI.class.getResource("/resources/mouse.png")));
  129.         lblNewLabel.setFont(new Font("Malgun Gothic", Font.BOLD, 16));
  130.         lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
  131.         lblNewLabel.setBounds(0, 0, 219, 34);
  132.         contentPane.add(lblNewLabel);
  133.        
  134.         chckbxAntiban = new JCheckBox("Antiban");
  135.         chckbxAntiban.setSelected(true);
  136.         chckbxAntiban.addActionListener(new ActionListener() {
  137.             public void actionPerformed(ActionEvent e) {
  138.                 slider.setEnabled(chckbxAntiban.isSelected());
  139.                 lblMouseSpeed.setEnabled(chckbxAntiban.isSelected());
  140.                 slider.setValue(5);
  141.             }
  142.         });
  143.         chckbxAntiban.setBounds(10, 62, 71, 23);
  144.         contentPane.add(chckbxAntiban);
  145.        
  146.         panel = new Panel();
  147.         panel.setForeground(Color.WHITE);
  148.         panel.setBackground(Color.WHITE);
  149.         panel.setBounds(10, 91, 152, 73);
  150.         contentPane.add(panel);
  151.         panel.setLayout(null);
  152.        
  153.         JLabel lblBankLocation = new JLabel("Bank Location:");
  154.         lblBankLocation.setHorizontalAlignment(SwingConstants.CENTER);
  155.         lblBankLocation.setBounds(0, 26, 85, 23);
  156.         panel.add(lblBankLocation);
  157.        
  158.         boxWest = new JCheckBox("");
  159.         boxWest.addActionListener(new ActionListener() {
  160.             public void actionPerformed(ActionEvent e) {
  161.                 boxNorth.setSelected(false);
  162.                 boxSouth.setSelected(false);
  163.                 boxEast.setSelected(false);
  164.             }
  165.         });
  166.         boxWest.setBackground(Color.WHITE);
  167.         boxWest.setBounds(81, 26, 21, 23);
  168.         panel.add(boxWest);
  169.        
  170.         boxSouth = new JCheckBox("S");
  171.         boxSouth.addActionListener(new ActionListener() {
  172.             public void actionPerformed(ActionEvent arg0) {
  173.                 boxNorth.setSelected(false);
  174.                 boxWest.setSelected(false);
  175.                 boxEast.setSelected(false);
  176.             }
  177.         });
  178.         boxSouth.setBackground(Color.WHITE);
  179.         boxSouth.setBounds(104, 52, 48, 23);
  180.         panel.add(boxSouth);
  181.        
  182.         boxCenter = new JCheckBox("");
  183.         boxCenter.setBackground(Color.WHITE);
  184.         boxCenter.setSelected(true);
  185.         boxCenter.setEnabled(false);
  186.         boxCenter.setBounds(104, 26, 21, 23);
  187.         panel.add(boxCenter);
  188.        
  189.         boxEast = new JCheckBox("");
  190.         boxEast.addActionListener(new ActionListener() {
  191.             public void actionPerformed(ActionEvent e) {
  192.                 boxNorth.setSelected(false);
  193.                 boxWest.setSelected(false);
  194.                 boxSouth.setSelected(false);
  195.             }
  196.         });
  197.         boxEast.setBackground(Color.WHITE);
  198.         boxEast.setBounds(127, 26, 21, 23);
  199.         panel.add(boxEast);
  200.        
  201.         boxNorth = new JCheckBox("N");
  202.         boxNorth.addActionListener(new ActionListener() {
  203.             public void actionPerformed(ActionEvent e) {
  204.                 boxEast.setSelected(false);
  205.                 boxSouth.setSelected(false);
  206.                 boxWest.setSelected(false);
  207.             }
  208.         });
  209.         boxNorth.setBackground(Color.WHITE);
  210.         boxNorth.setBounds(104, 0, 44, 23);
  211.         panel.add(boxNorth);
  212.     }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment