⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hardlook.java

📁 学了2个月java 练习用~ 可以看下 希望同意
💻 JAVA
字号:
import java.awt.event.*;
import java.awt.AWTEvent.*;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.lang.reflect.*;

public class hardlook
{
	private JFrame frame1,frame2;
	private JButton button1,button2;
	private JLabel label1,label2;
	private JTextField field1,field2;
	private Container one;
	private JTextArea testevent=new JTextArea();
	private event listen=new event();

	public hardlook(){
		frame1=new JFrame("test one");
		frame2=new JFrame("test two");
		frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		one=frame1.getContentPane();
		setframe1();
	}

	public void setframe1(){
		frame1.setVisible(true);
		frame1.setLayout(null);
		frame1.setBounds(200,50,500,800);

		button1=new JButton("确定");
		button1.setBounds(80,50,80,50);
		button1.addActionListener(listen);
		frame1.add(button1);

		label1=new JLabel("退出确认");
		label1.setBounds(10,50,100,50);
		frame1.add(label1);

		testevent.setBounds(10,120,450,500);
		frame1.add(testevent);

	}
	class event implements ActionListener {

		public void actionPerformed(ActionEvent e){
			Newtask task=new Newtask((JButton)e.getSource());
			Class ae=e.getClass();
			Field[] findid=ae.getFields();
			for (int i=0;i<findid.length ;i++ ){
				findid[i].setAccessible(true);
				testevent.append(findid[i].toString()+"\n");
			}

	/*		try{
				Field id=ae.getDeclaredField("id");
				id.setAccessible(true);
				label1.setText(id.get(e)+"");
			}
			catch (Exception a){
				System.out.println(a);
			}
*/

		//	java.util.Timer out=new java.util.Timer();
		//	out.schedule(task,0,1000);
		}

	}
	public void go(){

		frame1.show();
	}

	public static void main(String[] args) throws Exception
	{

		(new hardlook()).go();
	}
}

class Newtask extends TimerTask{
	private int i=5;
	private JButton button;

	public Newtask(JButton button){
		super();
		this.button=button;
	}
	public Newtask(){
		super();
	}
	public void run(){
		int now=zero();
		if (now==0){
			System.exit(0);
		}
		button.setText(now+"");
	}
	public int zero(){
		return i--;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -