问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

急求java打字小程序的代码

发布网友 发布时间:2022-04-24 03:15

我来回答

1个回答

热心网友 时间:2023-10-24 06:34

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Random;
class WordPanel extends JPanel implements Runnable{
private Thread thread = null;
private int level = 1;
private Font font = new Font("宋体",Font.ITALIC+Font.BOLD,24);
private Color color = Color.BLUE;
public static final int x = 10;
private int y = 0;
private char word;//下落的字母
private static Random rand = new Random();

public void setY(int y){
this.y = y;
}
public void setWord(char word){
this.word = word;
}

public char getWord(){
return this.word;
}

public static char newChar(){
return (char)(97+rand.nextInt(26));
}

public WordPanel(){
word = newChar();
thread = new Thread(this);
thread.start();
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(font);
g.setColor(color);
g.drawString(String.valueOf(word),x,y);
}

public void run(){
while (true){
try {
Thread.sleep(1000);
this.repaint();
if (y>=this.getHeight()){
y = 0;
word = this.newChar();
}else
y+=20;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

class WordGame extends JFrame{
private WordPanel[] words = new WordPanel[10];

class Listener extends KeyAdapter{
public void keyTyped(KeyEvent e) {
char input = e.getKeyChar();
for (int i = 0; i<words.length; i++){
if ( input==words[i].getWord() ){
words[i].setWord(WordPanel.newChar());
words[i].setY(0);
words[i].repaint();
break;
}
}
}
}

public WordGame(String title){
super(title);//思考
Container c = this.getContentPane();
c.setLayout(new GridLayout(1,words.length));
this.addKeyListener( new Listener() );
for (int i = 0; i<words.length; i++){
words[i] = new WordPanel();
c.add(words[i]);
}

this.setSize( new Dimension(300,300) );
this.setVisible(true);
}

public static void main(String[] args){
WordGame game = new WordGame("开个窗口掉字母");
}
}

热心网友 时间:2023-10-24 06:34

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Random;
class WordPanel extends JPanel implements Runnable{
private Thread thread = null;
private int level = 1;
private Font font = new Font("宋体",Font.ITALIC+Font.BOLD,24);
private Color color = Color.BLUE;
public static final int x = 10;
private int y = 0;
private char word;//下落的字母
private static Random rand = new Random();

public void setY(int y){
this.y = y;
}
public void setWord(char word){
this.word = word;
}

public char getWord(){
return this.word;
}

public static char newChar(){
return (char)(97+rand.nextInt(26));
}

public WordPanel(){
word = newChar();
thread = new Thread(this);
thread.start();
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(font);
g.setColor(color);
g.drawString(String.valueOf(word),x,y);
}

public void run(){
while (true){
try {
Thread.sleep(1000);
this.repaint();
if (y>=this.getHeight()){
y = 0;
word = this.newChar();
}else
y+=20;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

class WordGame extends JFrame{
private WordPanel[] words = new WordPanel[10];

class Listener extends KeyAdapter{
public void keyTyped(KeyEvent e) {
char input = e.getKeyChar();
for (int i = 0; i<words.length; i++){
if ( input==words[i].getWord() ){
words[i].setWord(WordPanel.newChar());
words[i].setY(0);
words[i].repaint();
break;
}
}
}
}

public WordGame(String title){
super(title);//思考
Container c = this.getContentPane();
c.setLayout(new GridLayout(1,words.length));
this.addKeyListener( new Listener() );
for (int i = 0; i<words.length; i++){
words[i] = new WordPanel();
c.add(words[i]);
}

this.setSize( new Dimension(300,300) );
this.setVisible(true);
}

public static void main(String[] args){
WordGame game = new WordGame("开个窗口掉字母");
}
}

热心网友 时间:2023-10-24 06:34

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Random;
class WordPanel extends JPanel implements Runnable{
private Thread thread = null;
private int level = 1;
private Font font = new Font("宋体",Font.ITALIC+Font.BOLD,24);
private Color color = Color.BLUE;
public static final int x = 10;
private int y = 0;
private char word;//下落的字母
private static Random rand = new Random();

public void setY(int y){
this.y = y;
}
public void setWord(char word){
this.word = word;
}

public char getWord(){
return this.word;
}

public static char newChar(){
return (char)(97+rand.nextInt(26));
}

public WordPanel(){
word = newChar();
thread = new Thread(this);
thread.start();
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(font);
g.setColor(color);
g.drawString(String.valueOf(word),x,y);
}

public void run(){
while (true){
try {
Thread.sleep(1000);
this.repaint();
if (y>=this.getHeight()){
y = 0;
word = this.newChar();
}else
y+=20;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

class WordGame extends JFrame{
private WordPanel[] words = new WordPanel[10];

class Listener extends KeyAdapter{
public void keyTyped(KeyEvent e) {
char input = e.getKeyChar();
for (int i = 0; i<words.length; i++){
if ( input==words[i].getWord() ){
words[i].setWord(WordPanel.newChar());
words[i].setY(0);
words[i].repaint();
break;
}
}
}
}

public WordGame(String title){
super(title);//思考
Container c = this.getContentPane();
c.setLayout(new GridLayout(1,words.length));
this.addKeyListener( new Listener() );
for (int i = 0; i<words.length; i++){
words[i] = new WordPanel();
c.add(words[i]);
}

this.setSize( new Dimension(300,300) );
this.setVisible(true);
}

public static void main(String[] args){
WordGame game = new WordGame("开个窗口掉字母");
}
}

热心网友 时间:2023-10-24 06:34

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Random;
class WordPanel extends JPanel implements Runnable{
private Thread thread = null;
private int level = 1;
private Font font = new Font("宋体",Font.ITALIC+Font.BOLD,24);
private Color color = Color.BLUE;
public static final int x = 10;
private int y = 0;
private char word;//下落的字母
private static Random rand = new Random();

public void setY(int y){
this.y = y;
}
public void setWord(char word){
this.word = word;
}

public char getWord(){
return this.word;
}

public static char newChar(){
return (char)(97+rand.nextInt(26));
}

public WordPanel(){
word = newChar();
thread = new Thread(this);
thread.start();
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(font);
g.setColor(color);
g.drawString(String.valueOf(word),x,y);
}

public void run(){
while (true){
try {
Thread.sleep(1000);
this.repaint();
if (y>=this.getHeight()){
y = 0;
word = this.newChar();
}else
y+=20;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

class WordGame extends JFrame{
private WordPanel[] words = new WordPanel[10];

class Listener extends KeyAdapter{
public void keyTyped(KeyEvent e) {
char input = e.getKeyChar();
for (int i = 0; i<words.length; i++){
if ( input==words[i].getWord() ){
words[i].setWord(WordPanel.newChar());
words[i].setY(0);
words[i].repaint();
break;
}
}
}
}

public WordGame(String title){
super(title);//思考
Container c = this.getContentPane();
c.setLayout(new GridLayout(1,words.length));
this.addKeyListener( new Listener() );
for (int i = 0; i<words.length; i++){
words[i] = new WordPanel();
c.add(words[i]);
}

this.setSize( new Dimension(300,300) );
this.setVisible(true);
}

public static void main(String[] args){
WordGame game = new WordGame("开个窗口掉字母");
}
}
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
逆水寒手游庄园怎么邀请好友同住 逆水寒手游 逆水寒不同区可以一起组队吗? 逆水寒手游 逆水寒怎么进入好友世界? 逆水寒手游 逆水寒怎么去别人的庄园? 使用puppeteer实现将htmll转成pdf 内卷时代下的前端技术-使用JavaScript在浏览器中生成PDF文档 【译】将HTML转为PDF的几种实现方案 变形金刚08动画怎么样 变形金刚08动画的问题 变形金刚08动画日语版剧情介绍 Java中Applet小程序的编写 java小程序源代码 求java小程序代码,500行左右。。大作业用。追加50 JAVA小程序代码问题,求高手 java 小程序太阳码中间的logo如何能换掉成为当前用户的头像,成为这个用户的专属二维码 一个JAVA小程序从代码编写到运行的过程理解是否正确? java 小程序源代码 求一个JAVA小程序的源代码,要求如下 java小程序代码修改 谁能提供一个java小程序代码? 急求JAVA小程序代码(20分重赏) 急需一些java小程序代码 求大神给我一个Java语言编写的小程序代码 java小程序代码 谁能给个JAVA的小程序代码,越小越好! 求java经典小程序代码 微信里买的电影票,可以退票吗? 我的微信6.2.2版本的,怎么删除不了朋友圈里面好友给我的评论? 微信6.2.2版本为何没办法添加好友 微信6.2.2新从哪儿下载? 东莞地铁国庆运营时间 东莞地铁2号线蛤地站首末班车时刻表 东莞地铁时间 东莞地铁2号线开通了,早上几点开车,最晚的一班是几点? 1月27日起,东莞地铁延长行车间隔,高峰期10分钟一班 东莞地铁2号线开通了,早上几点开车,最晚的是几点? 2月26日起,东莞地铁运行间隔缩短,高峰期12分钟一班 东莞寮夏最早到虎门是几点的地铁? 东莞地铁2号线东莞火车站最后一班车几点 东莞会展中心地铁几点开始运营 东莞2号线西平西到茶山多久一趟车?有没有时间表 通车越来越近了,东莞地铁1号线最新进展披露 东莞2号线怎么去广州8号线 电子版证件照怎么发给朋友- 问一问 如何将我的电子版照片发给对方的网络信箱? 支付宝为什么别人扫了红包,但是扫我的收款码不能用红包? mp4格式转换成高清视频? 分辨率480*256的MP4的视频怎样转码?能转成全屏播放都很清晰的高清视频 怎么在excel自定义工具栏设置上下快捷按钮快速返回最上端和最下端 MP4格式的片子转换成1080的以后清晰度提高了吗?