为什么我的eclipse写Java,用JTextField的时候,输入的字符没有在文本框中显示??
/**File:GraphicsJTextField.java;*---------------------------------------*Thisprograma...
/*
* File: GraphicsJTextField.java;
* ---------------------------------------
* This program applies JTextfield;
*/
import java.awt.event.*;
import javax.swing.*;
import acm.graphics.*;
import acm.program.*;
public class GraphicsJTextField extends ConsoleProgram {
private JTextField namefield;
private int x = 20;
private int y = 20;
private GLabel label;
public void init() {
setSize(500,500);
setFont("Courier-24");
namefield = new JTextField(15);
//namefield.setActionCommand("name");
add(new JLabel("Name "), SOUTH );
add(namefield, SOUTH);
namefield.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if ( namefield == e.getSource()) {
println("Hello, " + namefield.getText());
}
}
} 展开
* File: GraphicsJTextField.java;
* ---------------------------------------
* This program applies JTextfield;
*/
import java.awt.event.*;
import javax.swing.*;
import acm.graphics.*;
import acm.program.*;
public class GraphicsJTextField extends ConsoleProgram {
private JTextField namefield;
private int x = 20;
private int y = 20;
private GLabel label;
public void init() {
setSize(500,500);
setFont("Courier-24");
namefield = new JTextField(15);
//namefield.setActionCommand("name");
add(new JLabel("Name "), SOUTH );
add(namefield, SOUTH);
namefield.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if ( namefield == e.getSource()) {
println("Hello, " + namefield.getText());
}
}
} 展开
2013-05-18
展开全部
代码放 上来啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
事件写的很有问题啊;还是好好看看awt事件方面的资料吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
actionPerformed(ActionEvent e)这事件是不就是输出的如果是请问你在哪把它调用的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询