package com.admin; import java.awt.*; import java.awt.event.*; public class AnonymousClass { private Frame f; private TextArea before; private TextArea after; private Button button; public AnonymousClass() { f = new Frame(); before = new TextArea(null,20,10,1); after = new TextArea(null,20,10,1); button = new Button("tans"); } public void launchFrame() { after.setEditable(false); f.setResizable(false); f.add(before,BorderLayout.NORTH); f.add(button,BorderLayout.CENTER); f.add(after,BorderLayout.SOUTH); button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { //TODO 处理逻辑 String s = before.getText(); System.out.println(s); after.setText(s); } }); //匿名类结束 f.addWindowListener(new WindowAdapter() { //匿名类开始 public void windowClosing(WindowEvent e) { System.exit(1); } }); //匿名类结束 f.setBounds(500, 100, 500, 700); f.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub AnonymousClass obj = new AnonymousClass(); obj.launchFrame(); } }