源码文件2:Launcher.java
package com.teleca.robin;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class Launcher extends JFrame implements WindowListener{
private long interval;
private String executableFileName;
Launcher(String file,long time)
{
if(file==null)
executableFileName="";
else
executableFileName=file;
interval=time;
initComponents();
this.addWindowListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private voidinitComponents(){
jButtonStart = new javax.swing.JButton();
jButtonPause = new javax.swing.JButton();
jButtonExit = new javax.swing.JButton();
jTextFieldFile = new javax.swing.JTextField(20);
jTextFieldTime = new javax.swing.JTextField(5);
jLabelFile = new javax.swing.JLabel();
jLabelTime = new javax.swing.JLabel();
jLabelTip = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("Form"); // NOI18N
jButtonStart.setText("Start"); // NOI18N
jButtonStart.setName("jButtonStart"); // NOI18N
jButtonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
start();
}
});
jButtonPause.setText("Pause"); // NOI18N
jButtonPause.setName("jButtonPause"); // NOI18N
jButtonPause.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pause();
}
});
jButtonExit.setText("Exit"); // NOI18N
jButtonExit.setName("jButtonExit"); // NOI18N
jButtonExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
stop();
System.exit(0);
}
});
jButtonStart.setEnabled(true);
jButtonPause.setEnabled(false);
jTextFieldFile.setText(executableFileName); // NOI18N
jTextFieldFile.setName("jTextFieldFile"); // NOI18N
jTextFieldFile.setHorizontalAlignment(JTextField.CENTER);
jTextFieldTime.setText(""+interval); // NOI18N
jTextFieldTime.setName("jTextFieldTime"); // NOI18N
jTextFieldTime.setHorizontalAlignment(JTextField.CENTER);
jLabelFile.setText("the executable file"); // NOI18N
jLabelFile.setName("jLabelFile"); // NOI18N
jLabelTime.setText("the interval time(millisecond)"); // NOI18N
jLabelTime.setName("jLabelTime"); // NOI18N
jLabelTip.setText("idle"); // NOI18N
jLabelTip.setName("jLabelTip"); // NOI18N
jLabelTip.setHorizontalAlignment(SwingConstants.CENTER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(jLabelTime))
.addGroup(layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(jLabelFile))
.addGroup(layout.createSequentialGroup()
.addGap(90, 90, 90)
.addComponent(jButtonStart)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(100, 100, 100)
.addComponent(jTextFieldTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jTextFieldFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jButtonPause)
)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabelTip)
)
.addGroup(layout.createSequentialGroup()
.addGap(180, 180, 180)
.addComponent(jButtonExit)
)
))
)
.addContainerGap(151, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(63, 63, 63)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelFile)
.addComponent(jTextFieldFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelTime)
.addComponent(jTextFieldTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(62, 62, 62)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonStart)
.addComponent(jButtonPause)
.addComponent(jButtonExit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
.addComponent(jLabelTip)
.addGap(32, 32, 32))
);
pack();
}// </editor-fold>//GEN-END:initComponents
Worker worker;
private voidstop(){//GEN-FIRST:event_stop
// TODO add your handling code here:
if(worker!=null)
{
worker.die();
worker=null;
}
}//GEN-LAST:event_stop
private voidpause(){//GEN-FIRST:event_pause
// TODO add your handling code here:
worker.doPause();
jButtonStart.setEnabled(true);
jButtonPause.setEnabled(false);
jTextFieldFile.setEditable(true);
jTextFieldTime.setEditable(true);
}//GEN-LAST:event_pause
private voidstart(){//GEN-FIRST:event_start
// TODO add your handling code here:
String fileName=jTextFieldFile.getText().trim();
if(checkFileName(fileName))
{
executableFileName=fileName;
}
else
{
return;
}
String time=jTextFieldTime.getText();
if(time.length()==0)
{
interval=defaultInterval;
}
else
{
try{
long t=Long.parseLong(time);
interval=t;
}catch(NumberFormatException e)
{
jLabelTip.setText("the time "+time+"is not correct!");
return;
}
}
if(worker==null)
{
worker=new Worker(this.jLabelTip);
worker.setExecutableFileName(executableFileName);
worker.setInterval(interval);
worker.start();
jLabelTip.setText("start to execute file");
}
else
{
worker.setExecutableFileName(executableFileName);
worker.setInterval(interval);
worker.doResume();
jLabelTip.setText("Restart to execute file");
}
jButtonStart.setEnabled(false);
jButtonPause.setEnabled(true);
jTextFieldFile.setEditable(false);
jTextFieldTime.setEditable(false);
}//GEN-LAST:event_start
final static long defaultInterval=1000;
/**
* @param args
*/
public static void main(String[] args){
String fileName="";
long time=defaultInterval;
if(args.length>0)
{
fileName=args[0];
if(!checkFileName(fileName))
{
fileName="";
}
}
if(args.length>1)
{
time=Long.parseLong(args[1]);
}
// TODO Auto-generated method stub
new Launcher(fileName,time).setVisible(true);
}
static booleancheckFileName(String fileName)
{
if(fileName==null)
{
return false;
}
if(!(fileName.endsWith(".exe")||fileName.endsWith(".bat")||fileName.endsWith(".cmd")))
{
System.out.println("the file must be a executable file!");
System.out.println("Now only support *.exe , *.bat,*.cmd");
System.out.println("Please check the file again");
return false;
}
File file=new File(fileName);
if(!file.exists())
{
System.out.println("the file:"+fileName+" is not exists");
return false;
}
return true;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonExit;
private javax.swing.JButton jButtonPause;
private javax.swing.JButton jButtonStart;
private javax.swing.JLabel jLabelFile;
private javax.swing.JLabel jLabelTime;
private javax.swing.JLabel jLabelTip;
private javax.swing.JTextField jTextFieldFile;
private javax.swing.JTextField jTextFieldTime;
// End of variables declaration//GEN-END:variables
public void windowDeactivated(WindowEvent e)
{
//System.out.println("window is deactivated");
}
public void windowDeiconified(WindowEvent e)
{
//System.out.println("window is Deiconified");
}
public void windowActivated(WindowEvent e)
{
//System.out.println("window is actived");
}
public void windowOpened(WindowEvent e)
{
//System.out.println("window is Opened");
}
public void windowClosing(WindowEvent e)
{
stop();
}
public void windowClosed(WindowEvent e)
{
//System.out.println("window is Closed");
}
public void windowIconified(WindowEvent e)
{
//System.out.println("window is Closing");
}
}
<wbr><wbr></wbr></wbr>
相关推荐
对于需要监视的某个exe可执行文件,确保它一直在运行,或宕掉后需要自动启动该进程,则可以通过进程监视器程序,实时监视该进程是否存在,不存在则进程监视器会将此进程启动。示例中用windows自带的画图作为监视进程...
万能程序启动器类似于音速启动,可以自己定义启动的EXE,BAT等可执行文件,还带有疲劳提醒功能
设计一个用于智力竞赛的抢答器计时器,同时能测试人的反应时间。按启动键,测试开始,2个八段码倒计时开始(如从10秒或20秒倒计时),在随机时间内点亮抢答允许灯,参赛双方分别按各自的抢答按钮参与抢答。一旦其中...
在嵌入式应用程序开发过程里,由于使用C语言编程,基本很少涉及到机器底层寄存器的执行过程,一般都会直接在main函数里开始写代码...事实上,每一种微控制器,无论性能高下,结构简繁,价格贵贱都是必须有启动文件才能
exe4j是一个帮助你集成Java应用程序到Windows操作环境的java可执行文件生成工具,无论这些应用是用于服务器,还是图形用户界面(GUI)或命令行的应用程序。如果你想在任务管理器中及Windows XP分组的用户友好任务栏...
Whistle是一个辅助C#库,用于从.NET进程中启动外部可执行文件并返回该可执行文件产生的任何输出。 安装 Whistle在处可用,并且可以使用VisualStudio NuGet程序包管理器或通过NuGet命令行作为程序包安装: 安装包...
PJL-可执行文件= jar,exe等的免费跨平台便携式Java启动器。与Win Portable开始菜单和其他启动器程序相同。 USB和其他有用的东西。 简单直观的GUI。 使用SwiXML优秀的框架-https://swixml.org/、...
如果有多个可执行文件,则可以选择特定的可执行文件,或者双击应用程序将启动它找到的第一个Linux可执行文件。 .sh脚本文件的优先级高于其他可执行文件。 应用: 以下位置提供了不需要在主机系统上安装库的linux可...
我可以在不编辑可执行文件的情况下启动任何 Windows CE 应用程序(使用 )。 Windows 不会检查子系统; 有一次我尝试启动x86 Windows Longhorn 4074内核,失败是因为找不到HAL.dll等库; Windows 10 拒绝启动 ...
使用 /i 命令行选项可抑制显示该消息,从而导致 xcopy 认定在源是多个文件或一个目录的情况下,目标是一个目录。 使用 xcopy 命令设置 Destination 文件的存档属姓 xcopy 命令创建具有存档属姓设置的文件,无论...
W3C发射器 有一个专用子模块用于颜色切换和皮肤,您需要在w3c org中才能看到。 其他所有东西都可以正常构建。...启动启动器 npm run serve 构建启动器 不会对应用进行签名,而只是构建它。 npm run build
甚至还有可能运行了低版本的exe可执行swf动画,高版本的就再也打不开了。 2、没装媒体播放器;或者嫌mediaplayer播放器启动慢,运行慢;或者mediaplay等版本太低,打不开某些媒体文件(如不能播放DVD的vob文件); 3、...
创建后的EXE自解压文件可以选择多种提取模式:解压文件到指定的文件夹-不删除提取文件(可选在资源管理器提取后打开解压的文件夹)解压文件到指定的文件夹,启动可执行文件,当它已经完成执行删除提取的文件,可执行...
简单启动器 一个简单的 C# 游戏启动器。... Builder_LastExecutable到您游戏的可执行文件(相对于游戏目录的路径) Builder_LastURL到您的网络服务器上game文件夹的 URL。 构建游戏版本 按Build Manife
MakeInstantPlayer 1.20 汉化版,是一个转换器,将视频文件转换为 exe 可执行文件并集成 MPlayer 在里面,利用 MPlayer 来完成播放任务。即使电脑上啥播放器都没有,也照样能观看。MakeInstantPlayer 与 LameXP 是...
如何建造-如何建造安装和gradle build获取预构建的可执行Jar文件。 。获取预构建的Jar的源代码git clone在本地git clone此存储库从预构建的Jar中提取BuildInfo.txt。 在git_commit_hash和git checkout git_commit_...
原始可执行文件的开源替代品。 它提供了更好的游戏启动器和具有附加功能的专用服务器启动器。 特征 完整的源代码可用。 在一个可执行文件中支持所有游戏版本。 完全无DRM的启动器,内部没有任何损坏的SecuROM废话...
一个使用maven jfx插件和其他工具生成本机可执行文件和安装程序的演示应用程序 构建本机捆绑包(Windows) 安装 5.5.6+ 安装 3.1.0+ 将两个程序都添加到PATH 运行mvn package 注意:制作启动器并与JRE捆绑可能...
启动Win 9X / 启动旧版DOS,可按要求对换系统文件 当BootWin=0时,默认启动旧版DOS,若此时选择启动菜单的 “Previous MS-DOS version”,将启动Win 9X 注:BootWin级别高于BootGUI,两者冲突时以前者为...
它具有标签式浏览,强大的文件搜索功能,多功能预览,高度可定制的界面,可选的双窗格以及一系列独特的方法,可以有效地自动执行频繁重复的任务。它快速,轻便,便携。 XYplorer是一个可移植的文件管理器。它不需要...