Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- /**
- @author Dharshini Vigneswaran
- @title GUI
- */
- /**
- just testing the documentation style
- */
- public class Dharsh
- {
- private JFrame frame;
- private JPanel westPanel, centerPanel, aidPanel, aidPanel2;
- private JLabel tag;
- private JTextField getCharacter;
- private JButton guess;
- private JTextArea commentry;
- private int x;
- public static void main(String[] param)
- {
- new Dharsh();
- }
- /**
- * Constructor that initializes the frame and also adds the components to the frame
- */
- public Dharsh()
- {
- frame = new JFrame("The simpsond guessing game");
- frame.setLayout(new BorderLayout());
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(750,470);
- initialize();
- frame.add(aidPanel2, BorderLayout.CENTER);
- frame.add(westPanel, BorderLayout.WEST);
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- }
- void initialize()
- {
- centerPanel = new JPanel();
- aidPanel2 = new JPanel();
- centerPanel.setLayout(new BorderLayout());
- commentry = new JTextArea();
- commentry.setEditable(false);
- centerPanel.add(commentry);
- JScrollPane scroller = new JScrollPane(centerPanel);
- scroller.setPreferredSize(new Dimension(600,400));
- aidPanel2.add(scroller);
- aidPanel= new JPanel();
- aidPanel.setLayout(new GridLayout(2,2));
- tag = new JLabel("Guess Simpson character: ");
- getCharacter = new JTextField(10);
- guess = new JButton("GO!");
- aidPanel.add(tag);
- aidPanel.add(getCharacter);
- aidPanel.add(guess);
- westPanel = new JPanel();
- westPanel.add(aidPanel);
- guess.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent event)
- {
- if(!getCharacter.getText().trim().equals(""))
- commentry.append(getCharacter.getText()+"\n");
- loadDashes();
- }
- });
- }
- void loadDashes()
- {
- // for(int i=0; i<=7; i++)
- // {
- x++;
- commentry.append("==");
- try{
- Thread.sleep(30);
- if(x <= 9){
- System.exit(0);
- }
- loadDashes();
- }catch(Exception e){
- }
- // }
- commentry.append("\n");
- }
- void loadBart()
- {
- //to be completed
- }
- void loadMaggie()
- {
- //to be completed
- }
- public static void main(String[] args) {
- /* */
- /** */
- System.out.println();
- class Dharsh extends Parent implements Interface {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement