我想要將一個類中的文本框中的值傳遞給另一個類中的另一個文本框。我有一個名爲PurchaseSystem和另一個PaymentSystem的類,我想將PurchaseSystem中的值傳遞給PaymentSystem。將變量從一個文本框傳遞到另一個文本框
private void btnMakePaymentActionPerformed(java.awt.event.ActionEvent evt) {
String selected;
new PaymentSystem().setVisible(true);
PaymentSystem information;
information = new PaymentSystem();
information.itemChoosen = txtDisplayItem.getText();
information.itemPrice = txtDisplayPrice.getSelectedText();
information.setVisible(true);
}
public class PaymentSystem extends javax.swing.JFrame {
public String itemChoosen, itemPrice, itemQuantity, itemSubTotal;
/**
* Creates new form PaymentSystem
*/
public PaymentSystem() {
initComponents();
itemTextBox.setText(itemChoosen);
priceTextBox.setText(itemPrice);
}
這是我迄今所做但PurchaseSystem類的值不會出現在PaymentSystem類文本框。請幫助
你同時聲明類的靜態內部類? – DRastislav
@DRastislav我只在Paymentsystem類中有一組公共字符串,因爲我使用它來將值存儲在購買系統類 – user1642943