InstallAnyWhere中,自定义面板的一个例子

自定义面板需要依赖于InstallAnyWhere的主jar包IAClasses.zip。

package com.cvicse.inforguard.install;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;

import com.zerog.ia.api.pub.CustomCodePanel;
import com.zerog.ia.api.pub.CustomCodePanelProxy;

public class EnCompentPanel extends CustomCodePanel implements ActionListener {
private static final long serialVersionUID = 1222L;
private boolean inited = false;

private JLabel jLabelInfor = null;
private JLabel jLabelError = null;
private JCheckBox jCheckBoxMC = null;
private JCheckBox jCheckBoxConsole = null;
private JTextPane jTextPaneInfor = null;
//资源类,存放了所有的文字提示信息
public iRes res = null;

public EnCompentPanel() {
//得到一个英文的资源类
res = new ResEnglish();
}

public boolean setupUI(CustomCodePanelProxy customCodePanelProxy) {
if (inited == true)
return true;
inited = true;
//在面板下方,显示错误提示信息的label
jLabelError = new JLabel();
jLabelError.setBounds(new Rectangle(15, 185, 300, 18));
jLabelError.setText("");

//jLabelInfor是面板最上方的信息提示框
jLabelInfor = new JLabel();
jLabelInfor.setBounds(new Rectangle(5, 5, 377, 110));
jLabelInfor.setVerticalTextPosition(SwingConstants.TOP);
jLabelInfor.setVerticalAlignment(SwingConstants.TOP);
jLabelInfor.setText("");
jLabelInfor.setBorder(BorderFactory.createLineBorder(Color.GRAY));

//面板的默认宽、高
this.setSize(404, 310);
this.setLayout(null);
//将用到的控件都添加到面板中去
this.add(jLabelInfor, null);
this.add(jLabelError, null);
this.add(getJCheckBoxMC(), null);
this.add(getJCheckBoxConsole(), null);
this.add(getJTextPaneInfor(), null);

return true;
}

public void panelIsDisplayed() {
}

//点击下一步按钮时触发的事件,返回true时可以进入下一步,返回false时停留在本页面
public boolean okToContinue() {
if (!jCheckBoxMC.isSelected()) {
if (!jCheckBoxConsole.isSelected()) {
jLabelError.setText(res.getComponentjLabelErrorText());
return false;
}
} else {
jLabelError.setText("");
}

//以下一段设置InstallAnyWhere中的环境变量
if (jCheckBoxMC.isSelected()) {
customCodePanelProxy.setVariable("mc", "mcSelect");
} else {
customCodePanelProxy.setVariable("mc", "mcNotSelect");
}
if (jCheckBoxConsole.isSelected()) {
customCodePanelProxy.setVariable("console", "consoleSelect");
} else {
customCodePanelProxy.setVariable("console", "consoleNotSelect");
}
return true;
}

//点击上一步按钮时触发的事件,返回true时可以进入下一步,返回false时停留在本页面
public boolean okToGoPrevious() {
jLabelError.setText("");
return true;
}
//此面板显示在右上角的标题
public String getTitle() {
return res.getComponentPanelTitle();
}

public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}

private JCheckBox getJCheckBoxMC() {
if (jCheckBoxMC == null) {
jCheckBoxMC = new JCheckBox();
jCheckBoxMC.setBounds(new Rectangle(10, 128, 147, 21));
jCheckBoxMC.setText("InforGuard MC");
jCheckBoxMC.setBackground(Color.white);
jCheckBoxMC.setSelected(true);
}
return jCheckBoxMC;
}

private JCheckBox getJCheckBoxConsole() {
if (jCheckBoxConsole == null) {
jCheckBoxConsole = new JCheckBox();
jCheckBoxConsole.setBounds(new Rectangle(10, 148, 163, 26));
jCheckBoxConsole.setText("InforGuard Console");
jCheckBoxConsole.setBackground(Color.white);
jCheckBoxConsole.setSelected(true);
}
return jCheckBoxConsole;
}

private JTextPane getJTextPaneInfor() {
if (jTextPaneInfor == null) {
jTextPaneInfor = new JTextPane();
jTextPaneInfor.setBounds(new Rectangle(8, 8, 362, 100));
jTextPaneInfor.setText(res.getComponentjTextPaneInfor());
jTextPaneInfor.setEditable(false);
}
return jTextPaneInfor;
}
}


编写完成后,将编译好的代码打为一个zip包。然后在installanywhere的工程里添加一个Custom Code的panel,然后在这个panel里选择刚才打出的zip包,并指定类名即可。

另,界面的设计可以使用Eclipse Visual Editor或者其他支持Swing图形界面设置的工具来设计。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Installanywhere打包javaweb项目 一 准备阶段 由于我们打包的是javaweb项目,实现的目标是在一台没有javaweb项目运行环境下,可以通过一键安装后执行我们的项目客户机上,那么,我们需要准备如下文件 1、jdk -- 可以直接将你本机下安装好的jdk拷贝,如 2、Tomcat -- 由于客户可能是不懂软件的,那么我们就需要下载一个免安装解压版的Tomcat,直接去官网下载 3、Mysql -- 同理,下载免安装版的mysql数据库 二 预处理阶段 1、对Tomcat进行部分优化,具体根据情况而定,我这里做了适当优化 2、将要运行的项目打成war包 放入Tomcat下的webapps下,尽量保证你的项目开发依赖的Tomcat和该Tomcat版本一直吧 3、往mysql目录下添文件夹和文件,如: data : 存放数据库数据的,在后面的脚本可能要用到,这里提前创建,避免脚本出 错 sql : 这里用于存放你从本地库导出的数据库脚本.sql文件,具体也不一定会用到 ,主要看后面的脚本如何编写 my.ini: 这是windows下的配置文件,配置了mysql的信息,解压版是没有该文件的 手动创建一个,内容可以为空,也可以不为空,放入些基本的配置,我这里是直接为空的 为了后面installanywhere动态插入配置方便 4、将jdk, tomcat, mysql全部放入一个文件夹下如: Install.bat : 该文件用于注册和启动Tomcat,mysql的服务 set Path=%SystemRoot%\system32 set JAVA_HOME=%1%\jdk set CATALINA_HOME=%1%\tomcat set mysql_home=%1%\mysql net stop mysql5 call %1%\mysql\bin\mysqld --remove mysql5 call %1%\mysql\bin\mysqld --install mysql5 sc config mysql5 start= auto net start mysql5 call %mysql_home%\bin\mysqladmin -h localhost -u root password 123 call %mysql_home%\bin\mysql -hlocalhost -uroot -p123 <%mysql_home%\sql\one.sql net stop mytomcat call %1%\tomcat\bin\service remove mytomcat call %1%\tomcat\bin\service install mytomcat sc config mytomcat start= auto net start mytomcat uninstall.bat : 该文件用于停止并注销删除服务 set Path=%SystemRoot%\system32 set JAVA_HOME=%1%\jdk set CATALINA_HOME=%1%\tomcat net stop mytomcat net stop mysql5 call %1%\tomcat\bin\service remove mytomcat call %1%\mysql\bin\mysqld --remove mysql5 start.bat : 用于手动启动服务 set Path=%SystemRoot%\system32 net start mytomcat stop.bat : 用于手动关闭服务 set Path=%SystemRoot%\system32 net stop mytomcat one : 这个是用于制作应用程序打开的快捷方式 是一个.url文件 -- one.url 1.ico : 图片文件,用于快捷方式和或安装文件的图标 三 installanywhere 制作 注:产品名称就是那个会在windows开始菜单栏显示的文件夹名字 添四个环境变量:就是会添到windows下的高级属性设置的那个环境变量那里 JAVA_HOME $USER_INSTALL_DIR$\jdk CATALINA_HOME $USER_INSTALL_DIR$\tomcat CATALINA_DIR $USER_INSTALL_DIR$\tomcat\bin PATH $USER_INSTALL_DIR$\jdk\bin;$USER_INSTALL_DIR$\mysql\bin;$USER_INSTALL_DIR$\tomcat\bin 接下来制作快捷方式和开始菜单栏的选项 其的程序快捷方式制作 [InternetShortcut] URL="http://localhost:8082/test" IconFile=$USER_INSTALL_DIR$$\1.ico HotKey=0 IconIndex=0 IDList= 开始菜单栏的卸载菜单制作 动态修改配置文件 这里我们先将mysql的my.ini文件进行修改,因为这个文件有两个属性的值是用户在选择安装目录的时候传进来的,所以要修改,但是,我的文件内容是空的,就直接插入配置文本 我的文本模板是: [client] port=3306 default-character-set=utf8 [mysqld] port=3306 character_set_server=utf8 #安装路径 basedir="$USER_INSTALL_DIR$\\mysql" #数据路径 datadir="$USER_INSTALL_DIR$\\mysql\\data" # 允许最大连接数 max_connections=200 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [WinMySQLAdmin] $USER_INSTALL_DIR$\bin\mysqld.exe 后面再来执行安装注册时的批处理命令 -- 其Command Line: cmd /c $USER_INSTALL_DIR$\install.bat $USER_INSTALL_DIR$ cmd /c表示执行指定的命令并断。 $USER_INSTALL_DIR$是传递给install.bat%1%的参数。 并且,选Options的3个选项。 将该Execute Command移动到Panel: Install Complete前面。 配置安装安程序后自动打开页面 反安装:配置卸载批处理 -- 菜单Pre-Uninstall>,按钮Add Action>Execute Command>Add>。 Command Line:  cmd /c $USER_INSTALL_DIR$\uninstall.bat $USER_INSTALL_DIR$ 将该Execute Command移动到第一个。 选Options的3个选项。 放在倒数第二的原因是:表示要等到选择完需要卸载的项后再执行,避免用户点击取消,把服务给注销了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值