我在用这个工具开发GUI程序的时候遇到一个问题:我在项目当中新建了一个"JFrame窗体"后,在窗体上面放了一个按钮和一个文本框,希望在按下按钮后,文本框的内容显示"Button pressed!",但是我不知道后面应该怎么做了!请大家指点、指点。请详细一点。我下面附上在“源”当中的代码:(请问我应该在哪几个位置加入代码)
*
* MyFrame.java
*
* Created on 2006年11月17日, 下午8:04
*/package MyProj;/**
*
* @author SUN
*/
public class MyFrame extends javax.swing.JFrame {
/** Creates new form MyFrame */
public MyFrame() {
initComponents();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyFrame().setVisible(true);
}
});
}
// 变量声明 - 不进行修改
private javax.swing.JButton jButton1;
private javax.swing.JTextField jTextField1;
// 变量声明结束
}
*
* MyFrame.java
*
* Created on 2006年11月17日, 下午8:04
*/package MyProj;/**
*
* @author SUN
*/
public class MyFrame extends javax.swing.JFrame {
/** Creates new form MyFrame */
public MyFrame() {
initComponents();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyFrame().setVisible(true);
}
});
}
// 变量声明 - 不进行修改
private javax.swing.JButton jButton1;
private javax.swing.JTextField jTextField1;
// 变量声明结束
}
GUI工具可以方便开发,但不能替代开发,建议楼主先学习基础知识,基本功那是相当重要啊。
这个就可以
jPasswordField1 = new javax.swing.JPasswordField();
jTextField1 .setText("Button pressed");
然后运行即可