【发布时间】:2013-09-19 18:19:02
【问题描述】:
我正在为此创建按钮,当我点击他时..没有发生任何事情...当我点击 btn 时,没有调用函数 btnActionPerformed...如何使其工作?
private void btButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here
int[] ret = new int[SQL.freetables().size()];
Iterator<Integer> iterator = SQL.freetables().iterator();
for (int i = 0; i < ret.length; i++)
{
ret[i] = iterator.next().intValue();
int num=SQL.freetables().size() + 1;
this.btn = new JButton();
this.btn.setText("" + ret[i]);
this.btn.setSize(60,20);
int x = 100+(80*i);
this.btn.setLocation(x, 140);
this.btn.setVisible(true);
this.add(btn);
// }
}
this.revalidate();
this.repaint();
}
private void btnActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.out.print("\b Test: " + btn.getText());
}
【问题讨论】:
标签: java swing jframe jbutton buttonclick