加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java开发_windows下面的关机,重启,注销小程序_源码下载

发布时间:2020-12-14 06:28:49 所属栏目:Java 来源:网络整理
导读:@SuppressWarnings("unused" MyWindowDao dao= MyWindowImpl("Hongten-v1.0.定时关机" } Box left= Box center= Box right= Box middle_part= .left = .center = .right = middle_part = } JButton shutdown = JButton("关机" JButton restart = JButton("重

@SuppressWarnings("unused" MyWindowDao dao= MyWindowImpl("Hongten-v1.0.定时关机" }

Box left= Box center= Box right= Box middle_part= .left = .center = .right = middle_part = }

JButton shutdown = JButton("关机" JButton restart = JButton("重启" JButton logout = JButton("注销" JButton clear = JButton("清零" JButton cancel = JButton("取消" JButton immshutdown = JButton("立刻关机" .shutdown = .restart = .logout = .clear = .cancel = .immshutdown = }

JLabel time_now = JLabel set_hour = JLabel("设置小时" JLabel set_min = JLabel("设置分钟" JLabel set_sec = JLabel("设置秒钟" JLabel concept = JLabel("Hongten-B510" JLabel workspace = JLabel("Hongtenzone@foxmain.com" JLabel surplus = time_now = set_hour = set_min = set_sec = .concept = .workspace = .surplus = }

JPanel buttom= .buttom = }

JTextField hour = JTextField(10 JTextField min = JTextField(10 JTextField sec = JTextField(10 MyTextField.hour = MyTextField.min = MyTextField.sec = }

}

}

}

MyWindowImpl JFrame serialVersionUID = -7018374117422042620L MyTextField myTextField = MyLabel myLabel = MyButton myButton = MyBox myBox = MyPanel buttom = (title); .setVisible( .setResizable(); .setSize(525,215 Dimension screen = .setLocation(screen.width - 525,0); .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SetMyLayoutDao setMyLayout = setLabel(); timeListener(); setTextFieldAddListener(); setButtonAddListener(); setLayout(); myTextField.getHour().addActionListener( (myTextField.getHour().getDocument()).addDocumentListener( myTextField.getMin().addActionListener( (myTextField.getMin().getDocument()).addDocumentListener( myTextField.getSec().addActionListener( (myTextField.getSec().getDocument()).addDocumentListener( myLabel.getTime_now().setText("SystemTime:" + myButton.getShutdown().setEnabled(); myButton.getShutdown().addActionListener( myButton.getRestart().setEnabled(); myButton.getRestart().addActionListener( myButton.getLogout().setEnabled(); myButton.getLogout().addActionListener( myButton.getClear().setEnabled(); myButton.getClear().addActionListener( myButton.getCancel().setEnabled(); myButton.getCancel().addActionListener( myButton.getImmshutdown().addActionListener(); myBox.getLeft().add(Box.createVerticalStrut(20 myBox.getLeft().add(Box.createVerticalStrut(20 myBox.getCenter().add(Box.createVerticalStrut(9 myBox.getCenter().add(Box.createVerticalStrut(9 myBox.getRight().add(Box.createVerticalStrut(10 myBox.getRight().add(Box.createVerticalStrut(10 myBox.getMiddle_part().add(Box.createHorizontalStrut(5 myBox.getMiddle_part().add(Box.createHorizontalStrut(5 buttom.getButtom().setLayout( GridLayout(2,3)); container = container.setLayout( Calendar cal = year = month = cal.get(Calendar.MONTH) + 1 day = hour = min = sec = String current = String(year + "-" + month + "-" + day + " " + + ":" + min + ":" + myLabel.getTime_now().setText("SystemTime:" + Calendar cal = Calendar.getInstance(); sur_hour = sur_min = sur_sec = (! JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24,0=<分钟<60,0=<秒<60!","温馨提示" myTextField.getHour().setText(String.valueOf(sur_hour)); myTextField.getHour().requestFocus(); } (! JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getMin().setText(String.valueOf(sur_min)); myTextField.getMin().requestFocus(); } (! JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getSec().setText(String.valueOf(sur_sec)); myTextField.getSec().requestFocus(); } Integer int_hour = Integer int_min = Integer int_sec = hour = int_hour.intValue() - min = int_min.intValue() - sec = int_sec.intValue() - (sec < 0 (min > 0 && hour >= 0 sec += 60 min = min - 1 (min == 0 && hour > 0 min += 60 hour -= 1 } (min < 0 (hour > 0 min += 60 hour = hour - 1 } (hour == 0 && min == 0 && sec < 0 myLabel.getSurplus().setVisible( String sur = String("剩余:" + hour + "时" + min + "分" + sec + "秒" changedUpdate(DocumentEvent e) { (myTextField.getHour().getText().equals("" || myTextField.getMin().getText().equals("" || myTextField.getSec().getText().equals("" myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( myButton.getClear().setEnabled( } myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( myButton.getClear().setEnabled( Runtime.getRuntime().exec("shutdown.exe -s -t 1" } JOptionPane.showMessageDialog(,"关机执行失败!" Runtime.getRuntime().exec("shutdown.exe -r -t 1" } JOptionPane.showMessageDialog(,"重启执行失败!" Runtime.getRuntime().exec("shutdown.exe -l" } JOptionPane.showMessageDialog(,"注销执行失败!" Runtime.getRuntime().exec("shutdown.exe -a" } JOptionPane.showMessageDialog(,"取消执行失败!" Calendar cal = then_hour = then_min = then_sec = (! JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getHour().setText(String.valueOf(then_hour)); myTextField.getHour().requestFocus(); } (! JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getMin().setText(String.valueOf(then_min)); myTextField.getMin().requestFocus(); } (! JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getSec().setText(String.valueOf(then_sec)); myTextField.getSec().requestFocus(); } Integer int_hour = Integer int_min = Integer int_sec = (then_hour == && then_min == && then_sec == (flag == 1 myButton.getCancel().setEnabled( myButton.getClear().setEnabled( (flag == 2 myButton.getCancel().setEnabled( myButton.getClear().setEnabled( (flag == 3 myButton.getCancel().setEnabled( myButton.getClear().setEnabled( action_hour = action_min = action_sec = (e.getSource() == (e.getSource() == myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( myButton.getClear().setEnabled( myButton.getCancel().setEnabled( myLabel.getSurplus().setVisible( myTextField.getHour().setEnabled( myTextField.getMin().setEnabled( myTextField.getSec().setEnabled( flag = 1 (action_hour >= 0 && action_hour <= 23 && action_min >= 0 && action_min <= 59 && action_sec >= 0 && action_sec <= 59 } JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getHour().requestFocus(); (e.getSource() == myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( myButton.getClear().setEnabled( myButton.getCancel().setEnabled( myLabel.getSurplus().setVisible( myTextField.getHour().setEnabled( myTextField.getMin().setEnabled( myTextField.getSec().setEnabled( flag = 2 (action_hour >= 0 && action_hour <= 23 && action_min >= 0 && action_min <= 59 && action_sec >= 0 && action_sec <= 59 } JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myTextField.getHour().requestFocus(); (e.getSource() == myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( myButton.getClear().setEnabled( myButton.getCancel().setEnabled( myLabel.getSurplus().setVisible( myTextField.getHour().setEnabled( myTextField.getMin().setEnabled( myTextField.getSec().setEnabled( flag = 3 (action_hour >= 0 && action_hour <= 23 && action_min >= 0 && action_min <= 59 && action_sec >= 0 && action_sec <= 59 } JOptionPane.showMessageDialog( "时间设置满足:0=<小时<24, myButton.getClear().setEnabled( myTextField.getHour().requestFocus(); (e.getSource() == myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( myButton.getClear().setEnabled( myButton.getCancel().setEnabled( myLabel.getSurplus().setVisible( myTextField.getHour().setEnabled( myTextField.getMin().setEnabled( myTextField.getSec().setEnabled( (e.getSource() == myTextField.getHour().setText("0" myTextField.getMin().setText("0" myTextField.getSec().setText("0" myButton.getClear().setEnabled( myLabel.getSurplus().setVisible( Thread( ( Thread.sleep(1000 } thenExecutive(); Thread( Runnable() { ( Thread.sleep(1000 } now(); surplus_time(); (judgeTime() == JOptionPane.showMessageDialog(,"时间设定错误" myLabel.getSurplus().setVisible( myButton.getShutdown().setEnabled( myButton.getRestart().setEnabled( myButton.getLogout().setEnabled( } boo = Calendar cal = judge_hour = judge_min = judge_sec = int_hour = int_min = int_sec = (int_hour < boo = } (int_hour == (int_min < boo = } (int_min == (int_sec < judge_sec + 5 boo = (str.matches("^[0-9]+$" } }

<span style="color: #0000ff;">import<span style="color: #000000;"> java.awt.Color;
<span style="color: #0000ff;">import<span style="color: #000000;"> java.awt.Font;
<span style="color: #0000ff;">import<span style="color: #000000;"> java.util.Calendar;

<span style="color: #0000ff;">import<span style="color: #000000;"> javax.swing.JFrame;

<span style="color: #0000ff;">import<span style="color: #000000;"> com.b510.examples.window.component.MyLabel;
<span style="color: #0000ff;">import<span style="color: #000000;"> com.b510.examples.window.component.MyTextField;
<span style="color: #0000ff;">import<span style="color: #000000;"> com.b510.examples.window.dao.SetMyLayoutDao;

<span style="color: #008000;">/**<span style="color: #008000;">

  • <span style="color: #808080;">@author<span style="color: #008000;"> Hongten

  • @time 2011-9-5 2011
    <span style="color: #008000;">*/
    <span style="color: #0000ff;">public <span style="color: #0000ff;">class SetMyLayoutImpl <span style="color: #0000ff;">extends JFrame <span style="color: #0000ff;">implements<span style="color: #000000;"> SetMyLayoutDao {

    <span style="color: #0000ff;">private <span style="color: #0000ff;">static <span style="color: #0000ff;">final <span style="color: #0000ff;">long serialVersionUID = -6414864615563143323L<span style="color: #000000;">;

    <span style="color: #008000;">/**<span style="color: #008000;">

    • 三个文本域(hour,sec)属性的相关设置
      <span style="color: #008000;">*/
      <span style="color: #0000ff;">public <span style="color: #0000ff;">void<span style="color: #000000;"> setTextField(MyTextField myTextField) {
      <span style="color: #008000;">//<span style="color: #008000;"> 小时文本域 位置:中间
      myTextField.getHour().setColumns(4);<span style="color: #008000;">//<span style="color: #008000;"> 4列
      <span style="color: #000000;"> myTextField.getHour().setForeground(Color.blue);
      <span style="color: #008000;">//<span style="color: #008000;"> 初始化小时文本域,设置为系统当前小时数
      <span style="color: #000000;"> myTextField.getHour().setText(
      String
      .valueOf(Calendar.getInstance().get(
      Calendar.HOUR_OF_DAY)));
      <span style="color: #008000;">//<span style="color: #008000;"> 分钟文本域 位置:中间
      myTextField.getMin().setColumns(4);<span style="color: #008000;">//<span style="color: #008000;"> 4列
      <span style="color: #000000;"> myTextField.getMin().setForeground(Color.blue);
      <span style="color: #008000;">//<span style="color: #008000;"> 初始化分钟文本域,设置值为0
      myTextField.getMin().setText("0"<span style="color: #000000;">);
      <span style="color: #008000;">//<span style="color: #008000;"> 秒钟文本域 位置:中间
      myTextField.getSec().setColumns(4);<span style="color: #008000;">//<span style="color: #008000;"> 4列
      <span style="color: #000000;"> myTextField.getSec().setForeground(Color.blue);
      <span style="color: #008000;">//<span style="color: #008000;"> 初始化秒钟文本域,设置为系统当前秒钟数
      <span style="color: #000000;"> myTextField.getSec().setText(
      String.valueOf(Calendar.getInstance().get(Calendar.SECOND)));
      }

    <span style="color: #008000;">/**<span style="color: #008000;">

    • 所有的JLabel属性设置
      <span style="color: #008000;">*/
      <span style="color: #0000ff;">public <span style="color: #0000ff;">void<span style="color: #000000;"> setLabel(MyLabel myLabel) {
      <span style="color: #008000;">//<span style="color: #008000;"> 现在时间 头部显示
      <span style="color: #000000;"> myLabel.getTime_now().setForeground(Color.red);
      myLabel.getTime_now().setFont(<span style="color: #0000ff;">new Font("楷体",Font.BOLD,20<span style="color: #000000;">));

      myLabel.getSurplus().setForeground(Color.red);
      myLabel.getSurplus().setFont(<span style="color: #0000ff;">new Font(<span style="color: #0000ff;">null,16<span style="color: #000000;">));
      myLabel.getSurplus().setVisible(<span style="color: #0000ff;">false);<span style="color: #008000;">//<span style="color: #008000;"> 初始化是为不可见
      <span style="color: #000000;">
      myLabel.getConcept().setForeground(Color.gray);
      myLabel.getWorkspace().setForeground(Color.gray);

    }
    }

MyButtonListener }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读