问题1:
我试图确定我ton子的大小,但似乎并没有改变,而是总是要填满我所希望的 t。
Problem 2:
当我用我的电文补充公开无效的行动(行动)时,似乎没有显示。 也许,这只是因为填满整个空间的纽子,但我不知道。
Here is the code for the buttons:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class HockeyGame extends JFrame implements
ActionListener, KeyListener, Runnable, WindowListener //, ActionListener
{
Thread t;
int xpuck, ypuck,xspeed,yspeed,gx,gy,redx2,redy2,lg,rg, redscore, bluescore,
redx,redy, gx2, gy2, bluex, bluey,bluex2,bluey2,rg2,lg2;
//int SQUARE_SIZE=10;
public HockeyGame ( ) {
}
public static void main ( String [ ] commandLine ) {
HockeyGame hg=new HockeyGame();
hg.init();
}
public void actionPerformed1(ActionEvent e) {
JOptionPane.showMessageDialog(null,"testing");
}
public void init() {
Button b;
b = new Button("Click me");
b.addActionListener(this);
b.setSize(40, 40);
add(b);
t=new Thread(this);
this.addKeyListener(this);
this.setFocusable(true);
setSize(700,700);
setVisible ( true );
Any help is appreciatedasd