関数を呼び出すときに、ラベルを作成しようとしています。しかし、私はこれを行うことはできません..どのようにそれを行うには? 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.
}