番职院电信拨号工具 v3.2.2 Beta
软件主要实现了位于校园网并使用电信天翼作为网络接入商的用户的电信拨号,撇去每次开机都需要在浏览器中输入网址进行拨号的步骤,只要设置为开机启动即可。
软件采用 java语言编写,EXE可执行程序采用VB语言编写,在VB语言中调用自带的精简JRE运行jar程序,打包程序使用Actual Installer。
涉及的java知识:
swing界面编程,thread多线程,MVC设计模式,IO流,REGEX正则表达式,Serializable序列化相关,HTTP网络编程。
文章目录:
一、安装包 二、安装向导 三、软件简介 四、软件源码简析 五、声明
一、安装包
下载地址:
百度网盘下载(11.38 MB)
病毒扫描报告:
(virscan查毒) :查看报告(火眼查毒):查看报告
二、安装向导
开始安装,点击下一步
阅读自述信息,点击下一步
设置路径或者使用默认路径进行安装,点击下一步
安装完成
三、软件简介
软件主界面
帐号输入框
记住密码
自动拨号
自动关闭
开机启动
设置开机启动方法
作者联系信息
IP设置
四、软件源码简析
源码下载:
百度网盘下载 (76 KB)
代码结构:
详细代码请看下一页
五、声明
作者小树,未通过作者允许,不准用于商业行为,但可作为学习或生活使用,使用源码请注明原创作者:小树技术博客(www.qiushurong.cn),本站保留版权和其他一切权利,有任何问题可以在博客评论或联系我的邮箱(admin@qiushurong.cn). 更多功能请期待…谢谢!
如果双击之后没打开程序,没反应的话,(一般XP系统都会如此),原因是没有安装VC运行库
下载后安装即可,地址:
32位 http://www.xiazaiba.com/html/1547.html
64位 http://www.xiazaiba.com/html/3589.html
或者自己百度 VC2010运行库下载
本软件仅限 广州番禺职业技术学院使用,其他地区GET方式不同,暂时不考虑。
作者:广州番禺职业技术学院 - 信息工程学院 - 12软件技术 - 小树
下一页:源码
Mian,程序入口类
import com.qsuron.action.PypController;
import com.qsuron.business.Data;
import com.qsuron.model.Conf;
import com.qsuron.view.PypFrame;
/**
- Main类
- @author admin@qiushurong.cn
/
public class Main {
/*- 程序主入口
- @param args
*/
public static void main(String[] args) {
PypFrame.InitLookAndFeel();
PypFrame view = new PypFrame();
Conf model = Data.recover();
@SuppressWarnings(“unused”)
PypController control = new PypController(view, model);
//control.getView().messageBox(“hello”);
//System.out.println(control.getView().showIpDial());
}
}
控制类
package com.qsuron.action;
import com.qsuron.util.Util;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JOptionPane;
import com.qsuron.business.Data;
import com.qsuron.model.Conf;
import com.qsuron.view.PypFrame;
/**
- 控制类
@author admin@qiushurong.cn
*/
public class PypController {
private PypFrame view;//视图
private Conf model;//模型
private Timer timer=new Timer();//计时器public PypController(PypFrame view,Conf model){
this.view = view; this.model = model; this.updateView(); this.setBtnListener(); this.setWindowsClose(); this.initLogin();
}
/**
检查是否自动拨号
*/
private void initLogin() {
Runnable runnable = new Runnable(){@Override public void run() { if(model.isRemConn() && !model.getPassword().equals("")){ updateModel(); login(); } }
};
new Thread(runnable).start();
}/**
拨号
*/
public void login(){
Runnable runnable = new Runnable(){private int timedelay = 0; @Override public void run() { //System.out.println("Thread-login"); String flag = Util.launch(model); //System.out.println("+++"+flag); if(flag.equals("登录成功")){ if(model.isRemClose()){ view.getjProgressBar1().setText("登录成功!3秒后退出程序..."); Data.backup(model); try { Thread.sleep(3500); } catch (InterruptedException e) { e.printStackTrace(); } updateModel(); Data.backup(model); System.exit(0); }else{ view.getjProgressBar1().setText("登录成功!"); } }else if(flag.equals("密码错误")){ view.getjProgressBar1().setText("密码错误!请重新输入密码..."); view.getjTextField2().setText(""); view.getjTextField2().requestFocus(); }else if(flag.equals("帐号不存在")){ view.getjProgressBar1().setText("帐号不存在!请重新输入..."); view.getjTextField1().setText(""); view.getjTextField2().setText(""); view.getjTextField1().requestFocus(); }else if(flag.equals("网络异常")||flag.equals("IP异常")||flag.equals("登录频繁")){ timedelay=3000; if(flag.equals("IP异常")){ view.getjProgressBar1().setText("IP异常!请检查锐捷是否开启!重新拨号中..."); }else if(flag.equals("登录频繁")){ view.getjProgressBar1().setText("登录频繁,15秒后自动重试,请无视之,等待即可!"); timedelay=16000; }else{ view.getjProgressBar1().setText("未知返回值,请手动检查能否上网,或联系作者..."); } timer.schedule(new TimerTask(){ public void run(){ if((model.getCountAnd())>60){ view.messageBox("本地网络错误,请先检查锐捷是否开启。\n或者手动设置IP!"); model.setIp(""); Data.backup(model); System.exit(0); } login(); this.cancel(); } },timedelay);//五秒 } }
};
new Thread(runnable).start();
}//关闭按钮响应
private void setWindowsClose() {
view.addWindowListener(new WindowAdapter(){@Override public void windowClosing(WindowEvent e) { int option = view.showCloseDial(); if (option == JOptionPane.YES_OPTION) { updateModel();//更新model Data.backup(model);//备份model System.exit(0);//退出程序 }else{ return; } }
});
}/**
设置按键监听
*/
private void setBtnListener() {
//拨号连接
view.getjButton1().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { updateModel();//更新model login(); }
});
//拨号连接
view.getjTextField1().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { updateModel();//更新model login(); }
});
//手动设置IP
view.getjRadioButton1().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { String ip = view.showIpDial(); if(ip != null){ model.setIp(ip); view.messageBox("设置IP[" + model.getIp() + "]成功! 请尝试拨号!"); view.getjTabbedPane1().setSelectedIndex(0); } }
});
//访问小树技术博客(www.qiushurong.cn)
view.getjRadioButton2().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { //判断当前系统是否支持Java AWT Desktop扩展 if(java.awt.Desktop.isDesktopSupported()){ try { //创建一个URI实例 java.net.URI uri = java.net.URI.create("http://www.qiushurong.cn/"); //获取当前系统桌面扩展 java.awt.Desktop dp = java.awt.Desktop.getDesktop(); //判断系统桌面是否支持要执行的功能 if(dp.isSupported(java.awt.Desktop.Action.BROWSE)){ //获取系统默认浏览器打开链接 dp.browse(uri); } } catch(java.lang.NullPointerException ee){ } catch (java.io.IOException ee) { view.messageBox("无法打开默认浏览器,请手动访问:www.qiushurong.cn !谢谢!"); } } }
});
//自动关闭
view.getjCheckBox3().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { if(view.getjCheckBox3().isSelected()){ view.getjProgressBar1().setText("下次拨号成功后自动退出程序..."); }else{ view.getjProgressBar1().setText("取消拨号成功后自动退出程序..."); } }
});
//自动拨号
view.getjCheckBox2().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(view.getjCheckBox2().isSelected()){ view.getjProgressBar1().setText("下次打开后自动开始拨号..."); }else{ view.getjProgressBar1().setText("取消打开后自动开始拨号..."); } } });
//开机启动
view.getjCheckBox4().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { view.messageBox("方法一:运行[设置为开机启动.bat](杀毒拦截的话要放行),方法二:把[快捷方式]拖动到[开始]-[程序]-[启动]中"); try { String[] cmd = new String[4]; String url = Data.LOCATION+"/设置为开机启动.bat"; url = url.replace("/", "\\"); //System.out.println(url); cmd[0] = "Explorer"; cmd[1] = "/select"; cmd[2] = ","; cmd[3] = url; //cmd[4] = url; Runtime.getRuntime().exec(cmd); } catch (IOException ee) { ee.printStackTrace(); } }
});
//开机启动
view.getjRadioButton3().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { view.messageBox("方法一:运行[设置为开机启动.bat](杀毒拦截的话要放行),方法二:把[快捷方式]拖动到[开始]-[程序]-[启动]中"); try { String[] cmd = new String[4]; String url = Data.LOCATION+"/设置为开机启动.bat"; url = url.replace("/", "\\"); //System.out.println(url); cmd[0] = "Explorer"; cmd[1] = "/select"; cmd[2] = ","; cmd[3] = url; //cmd[4] = url; Runtime.getRuntime().exec(cmd); } catch (IOException ee) { ee.printStackTrace(); } }
});
//软件漏洞
view.getjRadioButton4().addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent e) { view.messageBox("[QQ] 280970160 [邮箱] admin@qiushurong.cn [个人网站] www.qiushurong.cn"); }
});
}
/**
更新视图
*/
private void updateView() {
view.getjTextField1().setText(model.getAccount());
view.getjCheckBox1().setSelected(model.isRemPassword());
if(model.isRemPassword() && !model.getPassword().equals(“”)){view.getjTextField2().setText(model.getPassword()); view.getjButton1().requestFocus();
}else{
view.getjTextField2().requestFocus();
}
view.getjCheckBox2().setSelected(model.isRemConn());
view.getjCheckBox3().setSelected(model.isRemClose());
view.getjCheckBox4().setSelected(model.isRemStart());
}/**
- 更新视图
- @param model
@param view
*/
public void updateModel(){
model.setAccount(view.getjTextField1().getText());
model.setPassword(new String(view.getjTextField2().getPassword()));
model.setCount(model.getCount()+1);
model.setRemClose(view.getjCheckBox3().isSelected());
model.setRemConn(view.getjCheckBox2().isSelected());
model.setRemPassword(view.getjCheckBox1().isSelected());
model.setRemStart(view.getjCheckBox4().isSelected());
}public PypFrame getView() {
return view;
}public Conf getModel() {
return model;
}
}
缓存数据处理类
package com.qsuron.business;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import com.qsuron.model.Conf;
/**
- 缓存数据处理类(序列化Model类)
@author admin@qiushurong.cn
*/
public class Data {
public static String LOCATION;//序列化文件所在位置//静态代码段,获取主程序的路径
static {try { LOCATION = URLDecoder.decode(Data.class.getProtectionDomain().getCodeSource().getLocation().getFile(),"UTF-8"); LOCATION = LOCATION.substring(1,LOCATION.lastIndexOf('/')); } catch (UnsupportedEncodingException e) { LOCATION = ""; }
}
public static void main(String[] args) {
/* Conf model = Data.recover(); System.out.println(model.getAccount()); */ /* Conf model = new Conf(); model.setAccount("qsuron"); model.setRemClose(true); backup(model); */
}
/**
- 配置文件序列化恢复
@return Conf
*/
public static Conf recover() {
File file = new File(LOCATION+”\jre\Conf”);
Conf model = new Conf();
System.out.println(file.getAbsolutePath()+” exist:”+file.exists());
if(file.exists()){ObjectInputStream ois = null; try{ ois = new ObjectInputStream(new FileInputStream(file)); model = (Conf)ois.readObject(); ois.close(); }catch(Exception e){ e.printStackTrace(); }finally{ try { ois.close(); } catch (IOException e) { e.printStackTrace(); } }
}
return model;
}/**
- 配置文件序列化备份
- @param model
*/
public static void backup(Conf model) {
File file = new File(LOCATION+”\jre\Conf”);
ObjectOutputStream oos = null;
try{
}catch(Exception e){oos = new ObjectOutputStream(new FileOutputStream(file)); oos.writeObject(model); oos.close();
}finally{e.printStackTrace();
}try { oos.close(); } catch (IOException e1) { e1.printStackTrace(); }
}
}
Model类 存储各种配置信息
package com.qsuron.model;
import java.io.Serializable;
/**
- Model 存储各种配置信息
@author admin@qiushurong.cn
*/
public class Conf implements Serializable{
private static final long serialVersionUID = 8233781718173174500L;private String account,password;
private String ip = “”;
private boolean remPassword,remConn,remClose,remStart;
private int count = 0;
public String getIp() {
if(this.ip == null) return ""; return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getCount() {
return count;
}
public int getCountAnd() {
this.count++; return count;
}
public void setCount(int count) {
this.count = count;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isRemPassword() {
return remPassword;
}
public void setRemPassword(boolean remPassword) {
this.remPassword = remPassword;
}
public boolean isRemConn() {
return remConn;
}
public void setRemConn(boolean remConn) {
this.remConn = remConn;
}
public boolean isRemClose() {
return remClose;
}
public void setRemClose(boolean remClose) {
this.remClose = remClose;
}
public boolean isRemStart() {
return remStart;
}
public void setRemStart(boolean remStart) {
this.remStart = remStart;
}
}
拨号工具类
package com.qsuron.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Scanner;
import com.qsuron.model.Conf;
/**
- 拨号工具类
@author admin@qiushurong.cn
*/
public class Util {/**
- @param account 帐号
- @param password 密码
- @return
- IP异常
- 登录成功
- 登录频繁
- 密码错误
- 帐号不存在
网络异常
*/
public static String launch(Conf model){
String flag=”网络异常”;
String ip = model.getIp();
String hostip=””;
BufferedReader br = null;
Process p = null;if(!ip.matches(“192\.168\.\d{1,3}\.\d{1,3}”)) {
try { hostip = java.net.InetAddress.getLocalHost().getHostAddress(); ip = hostip.substring(0,hostip.lastIndexOf('.'))+".1"; p = Runtime.getRuntime().exec("ping "+ip+" -n 1"); br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; StringBuilder sb=new StringBuilder(); while ((line = br.readLine()) != null) { sb.append(line+"\n"); } if(sb.toString().contains("丢失 = 0")){ flag="网络异常"; }else{ flag="IP异常"; } } catch (Exception e) { } System.out.println("ip.1-"+ip); if(!ip.matches("192\\.168\\.\\d{1,3}\\.\\d{1,3}") || flag.equals("IP异常")) { flag = "IP异常"; return flag; } model.setIp(hostip);
}else{
hostip = ip;
}
try {
flag = "网络异常"; String command = "http://219.136.125.139/portalAuthAction.do?wlanacIp=121.33.224.66&auth_type=PAP&wlanacname=pyzyxy&wlanuserip=" + hostip + "&bank_acct=bank_acct&userid=" + model.getAccount() + "@PYZYXY.GZ&passwd=" + model.getPassword(); URL url=new URL(command); //System.out.println("new URL(address)"); Scanner s = new Scanner(url.openStream()); //System.out.println("url.openStream()"); String temp = new String();; while(s.hasNextLine()){ temp = new String(s.nextLine().getBytes("gb2312"),"GBK"); System.out.println(temp); if(temp.contains("我要下线")) { flag = "登录成功"; break; } else if(temp.contains("Please in 15 seconds after the restart!")) { flag="登录频繁"; break; } else if(temp.contains("Error 1002")) { flag = "密码错误"; break; } else if(temp.contains("Error 1001")) { flag = "帐号不存在"; break; } } s.close();
} catch (Exception ex) {
ex.printStackTrace(); flag = "网络异常";
}
return flag;
}
}
界面类
package com.qsuron.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
/**
- 界面类
@author admin@qiushurong.cn
*/
public class PypFrame extends JFrame{
private static final long serialVersionUID = -1;private static final String TITLE = “电信拨号工具 - v3.2.2 Beta”;
private JButton jButton1 = new JButton(“拨号连接”); // 拨号连接
private JCheckBox jCheckBox1 = new JCheckBox(“记住密码”); // 记住密码
private JCheckBox jCheckBox2 = new JCheckBox(“自动拨号”); // 自动拨号
private JCheckBox jCheckBox3 = new JCheckBox(“自动关闭”); // 自动关闭
private JCheckBox jCheckBox4 = new JCheckBox(“开机自启”); // 开机自启
private JLabel jLabel1 = new JLabel();//帐号
private JLabel jLabel2 = new JLabel();//密码
private JLabel jLabel3 = new JLabel();//@PYZYXY.GZ
private JPanel jPanel1 = new JPanel();// 面板 - 拨号工具
private JPanel jPanel2 = new JPanel();// 面板 - 设置帮助
private JLabel jProgressBar1 = new JLabel();// 提示信息private JRadioButton jRadioButton1 = new JRadioButton();
private JRadioButton jRadioButton2 = new JRadioButton();
private JRadioButton jRadioButton3 = new JRadioButton();
private JRadioButton jRadioButton4 = new JRadioButton();
private JRadioButton jRadioButton5 = new JRadioButton();
private JTabbedPane jTabbedPane1 = new JTabbedPane();
private JTextField jTextField1 = new JTextField();// 账号框
private JPasswordField jTextField2 = new JPasswordField ();// 密码框
private int width,height;public PypFrame(){
initComponents();
}
/**
界面初始化
*/
private void initComponents() {this.InitText();
this.InitToolTipText();
jPanel1.setPreferredSize(new Dimension(260, 180));
jTextField1.setColumns(10);
jTextField2.setColumns(10);
jTextField2.setEchoChar(‘*’);//this.InitMenu(jMenuBar1);
this.InitLayout(jPanel1, jPanel2, getContentPane());
this.InitTab(jTabbedPane1, jPanel1, jPanel2);
this.pack();
// 定义工具包,获取屏幕的尺寸,使窗口位于正中央
Toolkit kit = Toolkit.getDefaultToolkit();
width = kit.getScreenSize().width/2-this.getWidth()/2;
height = kit.getScreenSize().height/2-this.getHeight()/2;
this.setLocation(width,height);
this.setResizable(false);
this.setTitle(TITLE);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);jProgressBar1.setBackground(Color.GRAY);
jProgressBar1.setForeground(Color.RED);// 使得帐号框取得焦点
jTextField1.requestFocus();this.setVisible(true);
}/ Set the Tab Panel /
private void InitTab(JTabbedPane jTabbedPane1,JPanel jPanel1,JPanel jPanel2) {
jTabbedPane1.addTab(“拨号工具”, jPanel1);
jTabbedPane1.addTab(“设置帮助”, jPanel2);
jTabbedPane1.setSelectedIndex(0);
jTabbedPane1.setSelectedComponent(jPanel1);
}/ Set all the Text /
private void InitText() {
jLabel1.setText(“帐号”);
jLabel2.setText(“密码”);
jLabel3.setText(“ @PYZYXY.GZ”);
jProgressBar1.setText(“已就绪!”);
jRadioButton1.setText(“手动设置IP地址 [解决多网卡的IP异常]”);
jRadioButton2.setText(“访问 小树技术博客 [www.qiushurong.cn]”);
jRadioButton3.setText(“设置开机自启方法”);
jRadioButton4.setText(“软件漏洞:请联系作者,不甚感激!”);
jRadioButton5.setText(“作者:番职院 信工 12软测 小树 2013 09 01”);
}/ Set All ToolTip Text /
private void InitToolTipText() {
jTextField1.setToolTipText(“请输入宽带帐号:学号/手机号(需开通)”);
jTextField2.setToolTipText(“请输入宽带密码(8位以上)”);
jCheckBox3.setToolTipText(“拨号成功后自动退出程序释放内存”);
jCheckBox4.setToolTipText(“配合‘锐捷开机自启’可以在开机后完全自动拨号上网”);
jCheckBox2.setToolTipText(“下次启动程序后自动开始拨号连接”);
jCheckBox1.setToolTipText(“记住密码,下次启动程序无需输入密码”);
jProgressBar1.setToolTipText(“提示栏”);
}/ Set the JPanel’s Layout /
private void InitLayout(JPanel jPanel1, JPanel jPanel2, Container contentPanel) {GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
GroupLayout layout = new GroupLayout(contentPanel);
jPanel1.setLayout(jPanel1Layout);
jPanel2.setLayout(jPanel2Layout);
contentPanel.setLayout(layout);jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jCheckBox2) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox3) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox4) .addGap(8, 8, 8)) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(jButton1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(jLabel1) .addComponent(jLabel2)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jTextField1) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jCheckBox1))))) .addGap(72, 72, 72))
);
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1) .addComponent(jLabel3)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jCheckBox1) .addComponent(jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(2, 2, 2) .addComponent(jButton1) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jCheckBox3) .addComponent(jCheckBox2) .addComponent(jCheckBox4)) .addContainerGap(13, Short.MAX_VALUE))
);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jRadioButton3) .addComponent(jRadioButton1) .addComponent(jRadioButton2) .addComponent(jRadioButton4) .addComponent(jRadioButton5)) .addContainerGap(20, Short.MAX_VALUE)) );
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jRadioButton3) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jRadioButton1) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jRadioButton2) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jRadioButton4) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton5)) );
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jTabbedPane1, GroupLayout.PREFERRED_SIZE, 263, GroupLayout.PREFERRED_SIZE) .addComponent(jProgressBar1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jTabbedPane1, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jProgressBar1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );
}
/ Set the Nimbus look and feel /
public static void InitLookAndFeel(){
try {for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } }
} catch (Exception e) {
e.printStackTrace();
}
}/ Main /
public static void main(String[] args) {}
public JButton getjButton1() {
return jButton1;
}public JCheckBox getjCheckBox1() {
return jCheckBox1;
}public JCheckBox getjCheckBox2() {
return jCheckBox2;
}public JCheckBox getjCheckBox3() {
return jCheckBox3;
}public JCheckBox getjCheckBox4() {
return jCheckBox4;
}public JTextField getjTextField1() {
return jTextField1;
}public JPasswordField getjTextField2() {
return jTextField2;
}public JLabel getjProgressBar1() {
return jProgressBar1;
}public JRadioButton getjRadioButton1() {
return jRadioButton1;
}public JRadioButton getjRadioButton2() {
return jRadioButton2;
}public JRadioButton getjRadioButton3() {
return jRadioButton3;
}public JRadioButton getjRadioButton4() {
return jRadioButton4;
}public JRadioButton getjRadioButton5() {
return jRadioButton5;
}public JTabbedPane getjTabbedPane1() {
return jTabbedPane1;
}/**
- 关闭程序提示框
@return
*/
public int showCloseDial() {
return JOptionPane.showConfirmDialog(this, “是否完全退出软件?”,"系统提示", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
}
/**
- IP设置输入框
@return
*/
public String showIpDial() {
return JOptionPane.showInputDialog(“输入您的IP地址: 192.168.???.??? .”);
}// Build MsgBox
public void messageBox(String s){
JDialog dialog = new JDialog(this,true);
dialog.setTitle(“提示信息”);dialog.add(new JLabel(“ “),BorderLayout.NORTH);
dialog.add(new JLabel(“ “+s+” “,SwingConstants.CENTER),BorderLayout.CENTER);
dialog.add(new JLabel(“ “),BorderLayout.SOUTH);
dialog.setLocation(width+10,height+50);
dialog.setResizable(false);
dialog.pack();
dialog.setVisible(true);
}
}
源码下载地址在上一页中已经给出。