CS计算机代考程序代写 Java import javax.swing.JFrame;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.event.*;

import java.awt.BorderLayout;
import java.awt.event.*;

public class EventListenersApp extends JFrame implements ActionListener, MouseListener, DocumentListener {

private static final long serialVersionUID = 1;

public EventListenersApp(String title) {
super(title);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JTextField text;
text = new JTextField(“Some text”);
text.getDocument().addDocumentListener(this);

add(text,BorderLayout.NORTH);

JButton button;
button = new JButton(“Press Me!”);
button.addActionListener(this);
add(button, BorderLayout.SOUTH);

addMouseListener(this);

setSize(200,300);
setVisible(true);

}

public void actionPerformed(ActionEvent e) {
System.out.println(“actionPerformed! “);
}

public void mouseClicked(MouseEvent e) {
System.out.println(“mouseClicked! “);
}

public void mouseEntered(MouseEvent e) {
System.out.println(“mouseEntered!”);
}

public void mouseExited(MouseEvent e) {
System.out.println(“mouseExited!”);
}

public void mousePressed(MouseEvent e) {
System.out.println(“mousePressed!”);
}

public void mouseReleased(MouseEvent e) {
System.out.println(“mouseReleased!”);
}

public void changedUpdate(DocumentEvent e) {
System.out.println(“changedUpdate!”);
}

public void insertUpdate(DocumentEvent e) {
System.out.println(“insertUpdate!”);
}

public void removeUpdate(DocumentEvent e) {
System.out.println(“removeUpdate!”;
}

public static void main(String[] args) {
new EventListenersApp(“Hello World”);
}

}