文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > New Text Document (4)
侵权投诉

New Text Document (4)

hangman

package gui;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class HangMan implements ActionListener{
JFrame frame;
JPanel contentPane,contentPane2;
JLabel wordInput, guessInput, check, hangMan, submit;
JTextField word, guess;
JButton submitButton, checkButton;

// The place of the picture on
String path = "E:\\1) hangmanproject\\net\\Project\\hangman\\";

public HangMan(){

// create and setup the farme #1
frame=new JFrame("Hangman Game");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// create a content pane and set size, content pane #1
contentPane=new JPanel();
contentPane.setLayout(new GridLayout(0,2,10,5));
contentPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

// create and add prompt than a text field for name
wordInput=new JLabel("Enter word: ");
contentPane.add(wordInput);
word=new JTextField(25);
contentPane.add(word);

// create and add buttom that will display the second frame when sumit
submitButton=new JButton("Player 1");
submitButton.setActionCommand("Player 1");
submitButton.addActionListener(this);
contentPane.add(submitButton);

// create and add the label that will display the ok
submit=new JLabel("");
contentPane.add(submit);

// add content pane to farme first frame
frame.setContentPane(contentPane);


// Creat a content pane with a BoxLayout
contentPane2 = new JPanel();
contentPane2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
contentPane2.setBackground(Color.white);
contentPane2.setLayout(new BoxLayout(contentPane2, BoxLayout.PAGE_AXIS));

// Creat a label that shows a hangman picture #1
hangMan = new JLabel(new ImageIcon(path+"08.jpg"));
hangMan.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
hangMan.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
hangMan.setOpaque(true);
contentPane2.add(hangMan);

// create and add prompt than a text field for age
guessInput=new JLabel("Enter letter: ");
contentPane2.add(guessInput);
guess=new JTextField(25);
contentPane2.add(guess);

// create and add the label that will display the goBack
check=new JLabel("");
contentPane2.add(check);

// create and add buttom that go back to the first frame
checkButton=new JButton("Player 2");
checkButton.setActionCommand("Player 2");
checkButton.addActionListener(this);
contentPane2.add(checkButton);


// size and then display the frame
frame.pack();
frame.setVisible(true);
}


/**handle button click action event
* pre: none
* post: Check the age of applicant and displ

第1页

你可能喜欢

热门文档

相关文档

  • New Rich Text Document (2)

    New Text Document luo ... 5页 2下载券New Rich Text Documen...

  • New Text Document (3)

    New Text Document (2) 8页 免费 New Rich Text Document 4页 免费 New Text Document luo ... 5页 2下载券 New Text Document (4) 暂无评价 2页 ...

  • New Text Document (3)

    New Text Document (2) 8页 免费 New Rich Text Document 4页 免费 New Text Document luo ... 5页 2下载券 New Text Document (4) 暂无评价 2页 ...

  • New Text Document (2)

    New Rich Text Document 4页 免费 New Text Document luo ha... 5页 5财富值 New Text Document (4) 暂无评价 2页 免费 New Text Document (3) 暂无...

  • New Text Document (2)

    New Rich Text Document 4页 免费 New Text Document luo ... 5页 2下载券 New Text Document (4) 暂无评价 2页 免费 New Text Document (3) 暂无评价...

  • New Text Document (3)

    New Rich Text Document 4页 免费 New Text Document luo ha... 5页 5财富值 New Text Document (4) 暂无评价 2页 免费 New Text Document (11) 暂无...

  • New Text Document (3)

    New Text Document new 暂无评价 1页 20财富值 New Rich Text Document 4页 免费 New Text Document luo ha... 5页 5财富值 New Text Document (4) ...

  • New Text Document (2)

    免费 New Text Document (11) 暂无评价 2页 2财富值搜你所想,读你所爱 拒绝盗版,营造绿色文库 如要投诉违规内容,请到百度文库投诉中心;如要提出功能问题或...

  • New Text Document (2)

    New Rich Text Document 4页 免费 New Text Document luo ha... 5页 5财富值 New Text Document (4) 暂无评价 2页 免费 New Text Document (3) 暂无...

  • New Text Document

    New Text Document (2) 8页 免费 New Rich Text Document 4页 免费 New Text Document luo ha... 5页 5财富值 New Text Document (4) 暂无评价 2页 ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email