CS计算机代考程序代写 Java import java.awt.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Square extends JFrame implements ActionListener {

private JTextField input = new JTextField();

public Square() {
super(“Square GUI”);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(1,2));
JButton button;
button= new JButton(“Square”);
add(button);
add(input);
button.addActionListener(this);
pack();
setVisible( true );
}

public void actionPerformed(ActionEvent e) {
int v = Integer.parseInt(input.getText());
input.setText(Integer.toString(v*v));
}

public static void main(String[] args) {
new Square();
}

}