当我调用一个函数时,我正在尝试创建一个标签。但我不能这样做..怎么做?我想通过funcoes.test()
方法(在第一个代码下方)创建一个标签,以显示在JFrame
(第一类,命名Interface
)
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:,
System.out.print("test");
for(int i = 1; i < 5; i++) {
System.out.print("hi");
this.button = new JButton();
this.button.setSize(60, 50);
this.button.setLocation(50+(80*i), 100);
this.button.setVisible(true);
this.button.setText("" + i);
this.button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int op = Integer.parseInt(ae.getActionCommand());
funcoes.test(op);
}
});
this.add(button);
this.jPanel1.add(button);
this.revalidate();
this.repaint();
}
}
这是我的另一堂课:
public class funcoes extends Interface {
public static void test(int x) {
System.out.print("Hi: " + x);
JLabel numero = new JLabel();
JLabel total = new JLabel();
//Interface.
}