Advertisement
fayimora

Untitled

May 5th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.32 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. /**
  5. @author Dharshini Vigneswaran
  6.  
  7. @title GUI
  8. */
  9. /**
  10.     just testing the documentation style
  11. */
  12. public class Dharsh
  13. {
  14.     private JFrame frame;
  15.     private JPanel westPanel, centerPanel, aidPanel, aidPanel2;
  16.     private JLabel tag;
  17.     private JTextField getCharacter;
  18.     private JButton guess;
  19.     private JTextArea commentry;
  20.     private int x;
  21.     public static void main(String[] param)
  22.     {
  23.         new Dharsh();
  24.     }
  25.     /**
  26.     * Constructor that initializes the frame and also adds the components to the frame
  27.     */
  28.     public Dharsh()
  29.     {
  30.         frame = new JFrame("The simpsond guessing game");
  31.        
  32.         frame.setLayout(new BorderLayout());
  33.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  34.         frame.setSize(750,470);
  35.        
  36.         initialize();
  37.        
  38.         frame.add(aidPanel2, BorderLayout.CENTER);
  39.         frame.add(westPanel, BorderLayout.WEST);
  40.         frame.setLocationRelativeTo(null);
  41.         frame.setVisible(true);
  42.     }
  43.    
  44.    
  45.     void initialize()
  46.     {
  47.         centerPanel = new JPanel();
  48.         aidPanel2 = new JPanel();
  49.         centerPanel.setLayout(new BorderLayout());
  50.         commentry = new JTextArea();
  51.         commentry.setEditable(false);
  52.         centerPanel.add(commentry);
  53.        
  54.         JScrollPane scroller = new JScrollPane(centerPanel);
  55.         scroller.setPreferredSize(new Dimension(600,400));
  56.         aidPanel2.add(scroller);
  57.        
  58.        
  59.         aidPanel= new JPanel();
  60.         aidPanel.setLayout(new GridLayout(2,2));
  61.        
  62.         tag = new JLabel("Guess Simpson character: ");
  63.         getCharacter = new JTextField(10);
  64.         guess = new JButton("GO!");
  65.         aidPanel.add(tag);
  66.         aidPanel.add(getCharacter);
  67.         aidPanel.add(guess);
  68.        
  69.         westPanel = new JPanel();
  70.         westPanel.add(aidPanel);
  71.        
  72.         guess.addActionListener(new ActionListener(){
  73.             public void actionPerformed(ActionEvent event)
  74.             {
  75.                 if(!getCharacter.getText().trim().equals(""))
  76.                     commentry.append(getCharacter.getText()+"\n");
  77.                     loadDashes();
  78.             }
  79.         });
  80.     }
  81.    
  82.     void loadDashes()
  83.     {
  84.     //  for(int i=0; i<=7; i++)
  85.     //  {
  86.         x++;
  87.             commentry.append("==");
  88.             try{
  89.                 Thread.sleep(30);
  90.                 if(x <= 9){
  91.                     System.exit(0);
  92.                 }
  93.                 loadDashes();
  94.             }catch(Exception e){
  95.                
  96.             }
  97.     //  }
  98.         commentry.append("\n");
  99.     }
  100.    
  101.     void loadBart()
  102.     {
  103.         //to be completed
  104.     }
  105.    
  106.     void loadMaggie()
  107.     {
  108.         //to be completed
  109.     }
  110.    
  111.    
  112.    
  113.    
  114.    
  115.    
  116.    
  117.     public static void main(String[] args) {
  118.         /*  */
  119.         /**   */
  120.        
  121.         System.out.println();
  122.        
  123.         class Dharsh extends Parent implements Interface {
  124.            
  125.         }
  126.     }
  127.    
  128.    
  129.    
  130.    
  131.    
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement