我有两个类另一个JFrame的,我现在用的ActionListeners,事情是,我想从第二个... THE FIRST CLASS接收第一类中的int值这是一个:传递int值从一个JFrame中使用的ActionListener
public class PanelCotizacion extends javax.swing.JPanel implements ActionListener {
private int numCotizacion = 0;
public PanelCotizacion() {
initComponents();
}
public void actionPerformed(ActionEvent e) {
System.out.println("HERE IS WHERE I WANT TO RECEIVE THE VALUE");
this numCotizacion = "";
//THE VALUE THAT I WANT TO RECEIVE FROM THE OTHER jFRAME
//TRIGGERED BY THE EVENT OF THE BUTTON (action performed)
}
}
这是第二个,在这里我要发送的int值:
public class BusquedaCotizacionGUI extends javax.swing.JFrame {
private int numCotizacion = 0;
public BusquedaCotizacionGUI() {
initComponents();
this.setLocationRelativeTo(null);
PanelCotizacion pC = new PanelCotizacion();
this.cmdOK.addActionListener(pC);
}
private void cmdOKActionPerformed(java.awt.event.ActionEvent evt) {
this.numCotizacion = Integer.parseInt(this.txtNumCotizacion.getText());
//Here is where I WANT TO PASS THE VARIABLE "numCotizacion" tho the other class
//Can Somebody Help Me
this.dispose();
}
}
你能帮我家伙要做到这一点,非常感谢!
感谢Salah您的评论,构造函数采取一个int参数不起作用,第二个选项我不知道把它放到我的代码“parent.getNumCotizacion();”导致它产生我的错误,我忘了也提到,我使用的面板我已经改变了很多时间与其他面板,使用removeAll(); .add(component),.updateUI();所以我不知道这是否会影响为什么我不能看到变量numCotizacion的更新,我要尝试Kojotak – Mario