} private class txtLis extends FocusAdapter { public void focusGained(FocusEvent e) { if(e.getSource().equals(txt1)) { txt1.setText("cursor int the TextField"); txt2.setText(""); } else { txt1.setText(""); txt2.setText("cursor int the TextField"); } } } public void paint(Graphics g) { g.drawImage(img,0,0,300,300,this);
}
} public class Test { public static void main(String[] args) { new MyFrame(); } } 关于声音 http://developer.ccidnet.com/pub/disp/Article?columnID=294&articleID=47658&pageNO=1 关于按钮 http://www.ciw.com.cn/media/swm/146/12616.htm
你可以给出实现的代码吗?只要短短几行就行了
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
class MyFrame extends Frame
{
Image img;
TextField txt1,txt2;
public MyFrame()
{
img=Toolkit.getDefaultToolkit().getImage("xxx.gif");
txt1=new TextField(20);
txt2=new TextField(20);
txt1.addFocusListener(new txtLis());
txt2.addFocusListener(new txtLis());
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
this.add(txt1);
this.add(txt2);
this.setLayout(new FlowLayout());
this.setSize(300,300);
this.show();
}
private class txtLis extends FocusAdapter
{
public void focusGained(FocusEvent e)
{
if(e.getSource().equals(txt1))
{
txt1.setText("cursor int the TextField");
txt2.setText("");
}
else
{
txt1.setText("");
txt2.setText("cursor int the TextField");
}
}
}
public void paint(Graphics g)
{
g.drawImage(img,0,0,300,300,this);
}
}
public class Test
{
public static void main(String[] args)
{
new MyFrame();
}
}
关于声音
http://developer.ccidnet.com/pub/disp/Article?columnID=294&articleID=47658&pageNO=1
关于按钮
http://www.ciw.com.cn/media/swm/146/12616.htm