别踩白块源代码java js别踩白块
【急】有没有朋友用java写过别踩白块,急求源码!
package 别踩白块;
专注于为中小企业提供成都网站建设、做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业南岳免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千余家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
public class Main extends JFrame implements MouseListener {
Block[] block=new Block[9];
Block1 block1=new Block1();
public Main(){
setTitle("别踩白块");
setBounds(200,300,200,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(3,3,5,5));
addblock();
bk();
this.setVisible(true);
}
public void addblock(){
for(int i=0;i9;i++)
{
block[i]=new Block();
add(block[i]);
}
}
public void bk(){
block1.setbk1(block[(int)(Math.random()*2)]);
block1.setbk1(block[(int)(Math.random()*2+4)]);
block1.setbk1(block[(int)(Math.random()*2+6)]);
}
public void over(){
block[3].setText("g");
block[4].setText("g");
block[5].setText("!");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main();
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource().equals(""));
over();
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
java初学者如何编写别踩黑白块,求编写内容 在eclipse里,是要有图形用户界面的,别乱复制
小弟啊,看来你真的是初学啊,抽象类Friut定义在哪个包中都可以,但是在它的子类中要导入,importFruit这个类,然后在Fruit这个类中定义一个抽象方法harvest(),不做任何实现就可以啦
JAVA中为什么画出的图形没法显示出来?
你这个是代码里面拼写错误了,改成下面的可以显示
class DontStepOnWhitePiece extends JPanel
{
public void paint(Graphics g) //上面的这里拼写错误,panit
{
super.paint(g);
g.setColor(Color.black);
g.drawRect(0, 0, 100, 100);
}
JAVA别踩白块怎么让一行除了黑块其他都是白块
import java.awt.Color;import java.awt.GridLayout;import javax.swing.JButton;import javax.swing.JFrame; public class MiGong extends JFrame{ private static final long serialVersionUID = 1L; private static final int ROW = 8; private static final int COL = 9; int[][] map = { {2,0,1,0,0,0,1,0}, {0,0,1,0,0,0,1,0}, {0,0,1,0,1,1,0,0}, {0,1,1,1,0,0,0,0}, {0,0,0,1,0,0,0,0}, {0,1,0,0,0,1,0,1}, {0,1,1,1,1,0,0,1}, {1,1,0,0,0,1,0,1}, {1,1,0,0,0,0,0,3} }; public static void main ( String args[] ) { new MiGong (); } public MiGong () { setTitle ("迷宫"); setLayout (new GridLayout (ROW, COL, 0, 0)); for ( int h = 0; h COL; h++ ) { for ( int g = 0; g ROW; g++ ) { switch (map[h][g]) { case 0: JButton p = new JButton (); p.setBackground (Color.red); add (p); break; case 1: JButton q = new JButton (); q.setBackground (Color.blue); add (q); break; case 2: JButton m = new JButton ("入口"); m.setBackground (Color.green); add (m); break; case 3: JButton n = new JButton ("出口"); n.setBackground (Color.green); add (n); break; } } } pack (); setLocationRelativeTo (null); setDefaultCloseOperation (EXIT_ON_CLOSE); setVisible (true); }}
标题名称:别踩白块源代码java js别踩白块
浏览地址:http://scjbc.cn/article/ddsooeh.html