📄 javacontainer.java
字号:
/*
* javacontainer.java
*
* Created on July 24, 2008, 4:26 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package NewGUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/**
*
* @author mekala
*/
public class javacontainer extends Frame implements ActionListener, WindowListener, Runnable{
Button b1,b2,b3;
TextField t1,t2,t3;
Label l1,l2,l3;
public static void main(String args[])
{
javacontainer j=new javacontainer();
}
/** Creates a new instance of javacontainer */
public javacontainer() {
try
{
setLayout(new FlowLayout());
l1=new Label("Enter Name");
l2=new Label("Result");
l3=new Label("Enter");
t1=new TextField(20);
t2=new TextField(20);
t3=new TextField(20);
b1=new Button("Add");
b2=new Button("Clear");
b3=new Button("verify");
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b1);
add(b2);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
setSize(900,500);
l3.setVisible(false);
t3.setVisible(false);
setVisible(true);
addWindowListener(this);
}
catch(Exception e)
{
System.out.println("Exception:"+e);
t2.setText(e.getMessage());
}
}
public void actionPerformed(ActionEvent e) {
try
{
Button b=(Button)e.getSource();
if(b==b1)
{
String s;
s=t1.getText();
t2.setText(s);
}
else
if(b==b2)
{
t1.setText("");
t2.setText("");
}
else
if(b==b3)
{
t1.setText("wait....");
Thre1 thr=new Thre1();
Thread th=new Thread(thr);
th.setPriority(10);
th.start();
//Thread.sleep(2000);
//thr.close();
setVisible(true);
t1.setText("ok");
}
}
catch(Exception e1)
{
System.out.println("Exception:"+e1);
}
}
public void run() {
System.out.println("called run");
t3.setText("idle..");
l3.setVisible(true);
t3.setVisible(true);
t3.setEditable(true);
t3.setEnabled(true);
t3.setCursor(new Cursor(1));
setVisible(true);
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
//t1.setText("try to close");
System.exit(0);
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -