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

📄 myframe.java

📁 修改系统时间
💻 JAVA
字号:
/**
 * 
 */
package test;

/**
 * @author 张雷
 *
 */
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.swing.*;

public class MyFrame extends Frame implements ActionListener,WindowListener{
	
	
	TextField change;
	public MyFrame(){
		
		setTitle("时间");
		setSize(300,400);
		Color bgColor = new Color(240,240,240);
		setBackground(bgColor);
		
		
		//画钟用
		//Panel pan1 = new Panel();
		
		
		//add("North",pan1);
		Label a = new Label("请输入修改时间:");
		a.setBounds(10,250,100,25);
		add(a);
		change = new TextField("",10);
		change.setBounds(120,250,110,20);
		
		Button b1 = new Button("确定");
		b1.addActionListener(this);
		Button b2 = new Button("取消");
		b2.addActionListener((ActionListener) new Exit());
		Button b3 = new Button("应用");
		b3.addActionListener((ActionListener) new Join());
		b1.setBounds(60,300,50,18);
		b2.setBounds(120,300,50,18);
		b3.setBounds(180,300,50,18);
		this.add(b1);
		this.add(b2);
		this.add(b3);
		this.add(change);
		//this.add(pan1);
		
		//以数字显示时间,并可以修改时间。
		TimePanel t = new TimePanel();
		t.setBounds(10,100,50,150);
		add("Center",t);
		
		/*ClockPanel c = new ClockPanel();
		c.setBounds(10, 10, 50, 50);
		add("Center",c);*/
		
		
		setVisible(true);
		addWindowListener(this);
	}
	
	
	
	public static void main(String[] args) {
		new MyFrame();
	}


	public void actionPerformed(ActionEvent arg0) {
		ChangeTime c = new ChangeTime(); 
		String t = change.getText();
		c.changeTime(t);
		System.exit(0);
		
	}


	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	public void windowClosed(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	public void windowClosing(WindowEvent arg0) {
		// TODO Auto-generated method stub
		System.exit(0);
	}


	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}


	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
	
	/*实现“取消”按钮*/
	class Exit implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			// TODO 自动生成方法存根
			System.exit(0);
		}

	}
	/*实现“应用”按钮*/
	class Join implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			ChangeTime c = new ChangeTime(); 
			
			String t = change.getText();
			//if(isTime(t))
			c.changeTime(t);
			//else
				//JOptionPane.showMessageDialog(null, "您输入的不是时间");
			
		}
		
	}
}


⌨️ 快捷键说明

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