2个回答
展开全部
import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
public class test extends JFrame implements ActionListener
{
JButton button ;
JTextField text ;
public test()
{
button=new JButton("确定") ;
text=new JTextField(10) ;
setTitle("测试按键监听") ;
button.addActionListener(this) ;
getContentPane().add(text,BorderLayout.NORTH) ;
getContentPane().add(button,BorderLayout.SOUTH) ;
setSize(300,200) ;
setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
text.setText(button.getText()) ;
}
public static void main(String []s)
{
new test() ;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
/**
* Sample application using Frame.
*
* @author
* @version 1.00 04/05/03
*/
public class rame extends JFrame implements AncestorListener{
//f1 f2;
JButton jb;
JTextField jt;
public static void main(String[] arg)
{ new rame();}
public rame() {
jb=new JButton("按钮");
jt=new JTextField();
jb.addAncestorListener(this);
JFrame rame=new JFrame();
Container c=rame.getContentPane();
// f2=new f1();
c.add(jb,BorderLayout.NORTH);
c.add(jt,BorderLayout.CENTER);
// g=new Graphics();
rame.addWindowListener
(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
rame.this.windowClosed();
}
}
);
rame.pack();
rame.setVisible(true);
}
/**
* Shutdown procedure when run as an application.
*/
protected void windowClosed() {
// TODO: Check if it is safe to close the application
// Exit application.
System.exit(0);
}
public void ancestorRemoved(AncestorEvent arg0) {
// TODO 自动生成方法存根
}
public void ancestorAdded(AncestorEvent arg0) {
// TODO 自动生成方法存根
}
public void ancestorMoved(AncestorEvent arg0) {
// TODO 自动生成方法存根
jt.setText(jb.getText());
}
}
import java.awt.Container;
import java.awt.Graphics;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
/**
* Sample application using Frame.
*
* @author
* @version 1.00 04/05/03
*/
public class rame extends JFrame implements AncestorListener{
//f1 f2;
JButton jb;
JTextField jt;
public static void main(String[] arg)
{ new rame();}
public rame() {
jb=new JButton("按钮");
jt=new JTextField();
jb.addAncestorListener(this);
JFrame rame=new JFrame();
Container c=rame.getContentPane();
// f2=new f1();
c.add(jb,BorderLayout.NORTH);
c.add(jt,BorderLayout.CENTER);
// g=new Graphics();
rame.addWindowListener
(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
rame.this.windowClosed();
}
}
);
rame.pack();
rame.setVisible(true);
}
/**
* Shutdown procedure when run as an application.
*/
protected void windowClosed() {
// TODO: Check if it is safe to close the application
// Exit application.
System.exit(0);
}
public void ancestorRemoved(AncestorEvent arg0) {
// TODO 自动生成方法存根
}
public void ancestorAdded(AncestorEvent arg0) {
// TODO 自动生成方法存根
}
public void ancestorMoved(AncestorEvent arg0) {
// TODO 自动生成方法存根
jt.setText(jb.getText());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询