下面的方法扩展了一个 JFrame,但我需要在其中有一个 swing 文本框来接收双精度值并将它们存储在一个变量中。必须将文本框添加到容器中。
public class myClass extends JFrame{
Container container;
container = getContentPane();
//Item label
JLabel labelText = new JLabel();
...
labelText.setText ("Item:");
container.add( labelText );
//Item name: Textbox
//code to make a textbox, add it to the container, and store the value in a variable goes here