该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
主界面
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.*;
public class Mouse_event {
/**
* @param args
*/
private Frame f;
private TextField tf;
private Button but1;
private Button but2;
private Label la;
private TextArea tex;
public Mouse_event() {
init();
// TODO Auto-generated constructor stub
}
private void init() {
// TODO Auto-generated method stub
f = new Frame("本体工具");
f.setBounds(200, 200,400, 400);
f.setLayout(new FlowLayout());
la = new Label("本体展示及编辑",la.CENTER);
tf = new TextField(50);
but1 = new Button("添加本体");
but2 = new Button("开始分析");
tex = new TextArea("",10, 50,TextArea.SCROLLBARS_VERTICAL_ONLY);
f.add(la);
f.add(tf);
f.add(but1);
f.add(but2);
f.add(tex);
f.setVisible(true);
MyEvent();
}
public String[] OloN = new String[100];
public int i;
private void MyEvent() {
// TODO Auto-generated method stub
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
});
but1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
OloN[i] = tf.getText();
String zt = "添加了本体"+tf.getText()+" ";
tex.setText(zt+tex.getText());
i++;
}
});
//but2.addActionListener(new ActionListener() {
//
//@Override
//public void actionPerformed(ActionEvent e) {
TODO Auto-generated method stub
//f.dispose();
//new form1();
//
//}
//});
but2.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
f.dispose();
new form1();
}
});
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Mouse_event();
}
}