求教,怎么修改程序,在用户输入中输入,不要不需要显示排序前了,按下按钮排序,然后就可以排序,
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame {
JPanel contentPane;
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel4 = new JLabel();
JTextField txt1 = new JTextField();
JTextField txtOrder = new JTextField();
JTextField txtIn = new JTextField();
JButton btn1 = new JButton();
public Frame1() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(457, 432));
setTitle("排序");
jLabel1.setText("排序前");
jLabel1.setBounds(new Rectangle(30, 99, 59, 36));
jLabel2.setText("排序后");
jLabel2.setBounds(new Rectangle(27, 183, 66, 36));
jLabel4.setText("用户输入");
jLabel4.setBounds(new Rectangle(28, 35, 71, 36));
txt1.setBounds(new Rectangle(116, 182, 307, 33));
txtOrder.setBounds(new Rectangle(118, 106, 307, 37));
txtIn.setText("请输入数字,并按回车键。一次只能输入一个数字");
txtIn.setBounds(new Rectangle(116, 37, 306, 39));
txtIn.addKeyListener(new Frame1_txtIn_keyAdapter(this));
btn1.setBounds(new Rectangle(28, 327, 162, 42));
btn1.setText("排序");
btn1.addActionListener(new Frame1_btn1_actionAdapter(this));
contentPane.add(jLabel4);
contentPane.add(jLabel1);
contentPane.add(txtOrder);
contentPane.add(jLabel2);
contentPane.add(txt1);
contentPane.add(txtIn);
contentPane.add(btn1);