以下是一个使用 Java 编写的满足您需求的示例程序: ```java import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; public class MyFrame extends JFrame { private JTextField inputTextField; private JTextField resultTextField; public MyFrame() { setTitle("myframe"); setSize(400, 300); setLocation(100, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout()); JLabel inputLabel = new JLabel("输入:"); add(inputLabel); inputTextField = new JTextField(20); add(inputTextField); JLabel resultLabel = new JLabel("结果:"); add(resultLabel); resultTextField = new JTextField(20); add(resultTextField); JButton copyButton = new JButton("copy"); copyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = inputTextField.getText(); resultTextField.setText(text); } }); add(copyButton); JButton closeButton = new JButton("close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); add(closeButton); } public static void main(String[] args) { MyFrame frame = new MyFrame(); frame.setVisible(true); } } ``` [2024-11-12 14:15:28 | AI写代码神器 | 385点数解答]