基本上我有一个带有卡片的程序(我正在使用 CardLayout),当用户输入句子或他们输入的任何内容时,我希望在他们点击名为 create 的按钮时将其添加到下一页上的标签中。我不确定如何保存输入的字段并将其作为变量放入标签中。有任何想法吗?如有必要,我可以提供我的代码。
createButton2.addActionListener(new ActionListener() { //Back button listener, switches back to ADMIN fixtures panel
@Override
public void actionPerformed(ActionEvent e) {
cardLayout.show(container, "6");
String theText = descriptionField.getText();
fixtureDescLabel.setText( theText );
fixtureDescLabel.setBounds(250, 150, 200, 40);
add(fixtureDescLabel);
}
});