??xml version="1.0" encoding="utf-8" standalone="yes"?> 引用 引用 引用 众所周知QEclipse无法方便快速的开发SwingE序。因为Eclipse没有自带囑Ş化编码窗口,如果要开发图形化E序Q只有手动敲代码非常不方ѝ现在有一个插件Jigloo提供囑Ş化程序开发窗口,可以xx。如何将它安装到Eclipse当中呢? 安装插g一般用Link方式QLink意味链接QEclipse加蝲旉过链接扑ֈ安装的插?BR> 插g安装位置正确后,p链接?Link)。在Eclipse路径C:\Program Files\Eclipse下徏立一?FONT color=#ff0000>links目录(必须q个名字)Qƈ在links目录下徏立一个Jigloo.link的文?文g名必d插g目录名相同,后缀名必Llink)。最后用C本打开Jigloo.link文gQ填入path = Jigloo(path = 插g目录?。保存后Q重新启动Eclipse。如下图 写在最后:(x)蒋委员长 ?如何class打包exe文g
class文g打包exe文g要经q两个步骤:(x)
W一步:(x)class文g打包成jar文gQ请参见我的上一文章:(x)http://maidini.blog.163.com/blog/static/37762704200848910573/
W二步:(x)jar文g打包成exe文g。这是今天的重点
jar打包exe 有许多工P我以exe4jZ详解打包q程Q?BR>W一步:(x)下蝲exe4j,最新版本ؓ(f)4.1 如下?exe4j的官方网?/A>
W二步:(x)q行exe4j.exe 我用的是免安装?zip) 如下?BR>
W三步:(x)q行软gexe4jQ然后点击Next
W四步:(x)选择W二?JAR in EXE mode"Q然后点击Next
W五步:(x)在General中填入名Uͼ在Directories填入生成exe的目录位|。如下图Q我生成exe目录讄为C:\ok Q然后点Next
W六步:(x)Executable name处填入生成exe文g的名UͼIcon File处填写图标文件位|,再点Next
W七步:(x)首先讄Class Path的位|,即jar文g的位|。然后点OK
W八步:(x)接着讄Main-Class 的位|,即mainҎ(gu)所在的位置。然后点OK 如下?BR>
讄完成后,如下图:(x) 一定要先设|Class PathQ再讄Main class
W九(ji)步:(x)填写版本P最好不要填写第二项。否则可能造成错误(见后?Q最后点击Finish卛_
错误内容QNo JVM could be found on your system. Please define EXE4J_JAVA_HOME to point to an installed JDK or JRE or download a JRE from www.java.com
当时出现q个错误Q查看了(jin)JDK和JRE都没有问题,exe4j也是最新版。后来才发现是设|?Maximum version"。如果不填写"Maximum version"Q就不报错。也不知道是不是exe4j的BUG
W十步:(x)完成所有设|,点击“Click Here to Start the Application”可以运行测试生成的EXE文g
生成的最l的EXEE序Q双ȝ接运行。现在可以把自己写的程序发l朋友们玩玩啦,呵呵
文章来源:http://wxq594808632.blog.163.com/blog/static/10907975520093842753860
]]>蒋委员长 ?如何Class打包Jar文g--Eclipse
开发环境:(x)Eclipse + Win XP SP2
使用插gQFatjar、Jigloo
闲话说Q直接切入正题。首先打开EclipseQ创Z个Java工程。如下图Q我机子上的是JDK1.6
W二步:(x)用Jigloo插g创徏一个窗体,Z(jin)更明显演C我窗体名字修改ؓ(f)“这是一个测试程序”。如下图Q?A>
W三步:(x)现在p运行正常的javaE序打包成jar文g。我使用Fatjar插g打包相当方便、傻瓜。直接右键选择要打包的工程Q弹出的菜单中选择“Build Fat Jar”。如下图Q?BR>
W四步:(x)弹出对话框,需要将引导路径修改Q其他选项使用默认讄Q然后点击Finish?SPAN style="COLOR: rgb(255,0,0)">“Main-Class”这修改ؓ(f)MainҎ(gu)所在的文g。此步不可缺,否则打包的Jar文g双击不可q行?/SPAN>
E等一下,打包成功如下图Q出C个testexe_fat.jar文g?BR>
q入工程所在的目录也可以看C个testexe_fat.jar文gQ双dQ就q行?jin)。如果无误应该弹出像?的界?/A>。如下图:
选择jar文g右键Q点击open。相当于双击jar文g如下?
ȝQ打包Jar文g是将分散Class文gl一装的好办法。双击运行速度与没打包前运行速度没有区别。打包一定要讄好Main-Class的\径,否则JVM找不到入口程序?BR>
如果不知道如何在Eclipse中安装插Ӟ请参见我的另一文章:(x)http://maidini.blog.163.com/blog/static/37762704200832671334860/
文章来源:http://wxq594808632.blog.163.com/blog/static/1090797552009384273607
]]>蒋委员长 ?Eclipse的插件安?/A>
如上图所C:(x)我的Eclipse路径C:\Program Files\Eclipse 然后Jigloo解压到Eclipse安装目录中?FONT color=#ff0000>q里需要注意Jigloo目录下必要有个叫Eclipse的目录,Eclipse的目录下才是攑օfeatures和plugins目录?/FONT>以上图ؓ(f)例:(x)C:\Program Files\Eclipse\Jigloo\Eclipse 路径?/FONT>攑օfeatures和plugins目录Q即features目录路径为:(x)C:\Program Files\Eclipse\Jigloo\Eclipse\featuresQplugins目录路径为:(x)C:\Program Files\Eclipse\Jigloo\Eclipse\plugins q里必须要强调目录\径,因ؓ(f)我用的是Link方式安装插g?/FONT>
在新建项目中出现?jin)一个叫GUI Forms的项目,说明插g安装成功Q这是Jigloo插g提供的图形化开发工兗?/FONT>
向大家推荐一个插件AptanaQ这个插件可以调试Javascript代码和HTML代码。此插gq是W一ƾ支持ajax调试的程序。详?A >http://www.aptana.com/
因ؓ(f)新版本要收费(只有一个月免费试用)Q我使用的老版本,安装到Eclipse中有3个按钮(如上图,黄色惊叹号和U色叉)(j)
如题Q废话不多说?/P>
JSP面
hello.jsp
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>AJAX提交面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
function doso(){
var url = "actAction.do";
var s="武晓强斯蒂芬34-*(&_(*!$^_*!&#!^$+!*#&&";
s=encodeURIComponent(s); //转换Ҏ(gu)字符
var parameter ="name="+s+"&email=abc@abc.com&www=http://wxq594808632.blog.163.com/";
var method = "POST";
function callBack(text){ //回调函数
alert("调用成功!\n名字?"+text);
}
new Ajax().ajaxRequest(url,parameter,method,callBack); //调用Ҏ(gu)发送Request
}
</script>
</head>
<body>
<input type="button" value="提交" onclick="doso()"/>
</body>
</html>
javac?/FONT>
ActAction.java
package ajaxpost;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.io.PrintWriter;
public class ActAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
UnsupportedEncodingException {
//讄字符~码q回的编?BR> response.setContentType("text/html;charset=UTF-8");
//接收字符的编?BR> try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException ex) {
ex.printStackTrace();
}
String name = request.getParameter("name");
String email = request.getParameter("email");
String www = request.getParameter("www");
System.out.println(email);
System.out.println(name);
System.out.println(www);
// out.print(name+"\n"+email+"\n"+www);
out.print(name); //q回?/FONT>
return null;
}
}
最重要?/FONT>
ajax.js
我用别h的。感谢这位大哥。?/P>
/*
author zhangshuling
email zhangshuling1214@126.com
*/
function Ajax(){
var _xmlHttp = null;
this.createXMLHttpRequest = function(){
try{
if (window.ActiveXObject) {
_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
_xmlHttp = new XMLHttpRequest();
}
}catch(e){
alert(e.name +" : " + e.message);
}
}
this.backFunction = function(_backFunction){
if(_xmlHttp.readyState == 4) {
if(_xmlHttp.status == 200) {
_backFunction(_xmlHttp.responseText);//q里可以讄q回cd
}
}
_xmlHttp.onreadystatechange = null;
}
this.doPost = function(_url,_parameter,_backFunction){
try{
_xmlHttp.open("POST",_url, false);
_xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
_xmlHttp.send(_parameter);
}catch(e){
alert(e.name +" : " + e.message);
}
}
this.doGet = function(_url,_parameter,_backFunction){
try{
var _random = Math.round(Math.random()*10000);
_xmlHttp.open("GET", (_url+"?random=" +_random +"&" + _parameter), false);
_xmlHttp.send(null);
}catch(e){
alert(e.name +" : " + e.message);
}
}
this.ajaxRequest = function(_url,_parameter,_method,_backFunction){
try{
this.createXMLHttpRequest();
if(_method.toLowerCase() == "post"){
this.doPost(_url,_parameter,_backFunction);
}else{
this.doGet(_url,_parameter,_backFunction);
}
try{
_xmlHttp.onreadystatechange = this.backFunction(_backFunction);
}catch(err){
//??????IE?????????????????
}
}catch(e){
alert(e.name +" : " + e.message);
}
}
}
/*
var url = "ajax.do";
var parameter = "parameter=parameter";
var method = "post"
function callBack(text){
....
}
new Ajax().ajaxRequest(url,parameter,method,callBack);
*/
l过本hFFQIE6QIE7Q测试。完全好?/P>
文章来源:http://wxq594808632.blog.163.com/blog/static/109079755200923121054225
import java.io.IOException;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.io.BufferedInputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.File;
import javax.imageio.ImageIO;
public class Img2 {
//dq程url囄,得到宽高
public int[] returnImgWH(String imgurl) {
boolean b=false;
try {
//实例化url
URL url = new URL(imgurl);
//载入囄到输入流
java.io.BufferedInputStream bis = new BufferedInputStream(url.openStream());
//实例化存储字节数l?BR> byte[] bytes = new byte[100];
//讄写入路径以及(qing)囄名称
OutputStream bos = new FileOutputStream(new File( "C:\\thetempimg.gif"));
int len;
while ((len = bis.read(bytes)) > 0) {
bos.write(bytes, 0, len);
}
bis.close();
bos.flush();
bos.close();
//关闭输出?BR> b=true;
} catch (Exception e) {
//如果囄未找?BR> b=false;
}
int[] a = new int[2];
if(b){ //囄存在
//得到文g
java.io.File file = new java.io.File("C:\\thetempimg.gif");
BufferedImage bi = null;
try {
//d囄
bi = javax.imageio.ImageIO.read(file);
} catch (IOException ex) {
ex.printStackTrace();
}
a[0] = bi.getWidth(); //获得 宽度
a[1] = bi.getHeight(); //获得 高度
//删除文g
file.delete();
}else{ //囄不存?/FONT>
a=null;
}
return a;
}
public static void main(String[] args) {
Img2 i = new Img2();
int[] a=i.returnImgWH(" if(a==null){
System.out.println("囄未找?");
}else{
System.out.println("宽ؓ(f)" + a[0]);
System.out.println("高ؓ(f)" + a[1]);
}
}
}
如题
默认排序方式为asc,可省?..
select * from table order by t1 desc, t2 desc , t3 desc;
function jsTrim(value)
{
var reg=/^\S$/;
if (!value) return "";
if(value.length==0)
return value;
else
{
var lp,rp;
lp=0;rp=value.length-1;
while ((value.charAt(lp)==" "||(value.charCodeAt(lp)<128?(reg.test(value.charAt(lp))==false?true:false):false)||value.charAt(rp)==" "||(value.charCodeAt(rp)<128?(reg.test(value.charAt(rp))==false?true:false):false))&&rp>=lp)
{
if (value.charAt(lp)==" "||value.charCodeAt(lp)<128?(reg.test(value.charAt(lp))==false?true:false):false)
lp++;
if (value.charAt(rp)==" "||value.charCodeAt(rp)<128?(reg.test(value.charAt(rp))==false?true:false):false)
rp--;
}
if(lp>rp)
return "";
else
return (value.substring(lp,rp+1));
}
}
引用
邉|L的空?/A> ?Java实现l图片添加水?/A>
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
import com.sun.image.codec.jpeg.*;public class WaterMark ...{
/** *//**
* l图片添加水?BR>* @param filePath 需要添加水印的囄的\?BR>* @param markContent 水印的文?BR>* @param markContentColor 水印文字的颜?BR>* @param qualNum 囄质量
* @return
*/
public boolean createMark(String filePath,String markContent,Color markContentColor,float qualNum,String watermark)
...{
ImageIcon imgIcon=new ImageIcon(filePath);
Image theImg =imgIcon.getImage();
int width=theImg.getWidth(null);
int height= theImg.getHeight(null);
//ImageIcon waterIcon=new ImageIcon(watermark);
//Image waterImg =waterIcon.getImage();
BufferedImage bimage = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
Graphics2D g=bimage.createGraphics();
g.setColor(markContentColor);
g.setBackground(Color.white);
g.drawImage(theImg, 0, 0, null );
//g.drawImage(waterImg, width*2, height, null );
g.drawString(markContent,width-100,height-30); //d水印的文字和讄水印文字出现的内?BR>g.dispose();
try...{
FileOutputStream out=new FileOutputStream(filePath);
JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bimage);
param.setQuality(qualNum, true);
encoder.encode(bimage, param);
out.close();
}catch(Exception e)
...{ return false; }
return true;
}
public static void main(String arg[])
...{
WaterMark wk=new WaterMark();
if(wk.createMark("D:\1.jpg","Welcome!",Color.WHITE,70f,""))...{
System.out.println("制作成功");
}else...{
System.out.println("p|?jin)?);
}
}
}
引用
邉|L的空?/A> ?如何防止同一个̎戯多个人同时登?
1.用session时,session为nullpCZU了(jin)
2.也可以采用数据库中设|? 临时? 来处?
一个用L(fng)陆时向表中插q一条记录,用户d时候删除该记录
如想l计在线人数Q简单地执行
select count(*) from table... 卛_
3.application对象中可以记住现在的人数Qapplication的生命周期和服务器的生命周期一样长?
4.q有一U方法要用到一个文件global.jsa Q方法是Q在JSP中)(j)是sessionDestroy(),其中它是以session对象为参数的。还有要把global.jsa文g必须房子和JSP E序 相同的文件目录内才行?
5.|页自动h的代码是Q?
在文件头部加?
<meta http-equiv="refresh" content="15">
h间隔旉?5U?
6.在session中加入监听类,cȝCZ代码如下:onLineUser.java-------------------------------------------------------------------------------------------
package com.shaobo.struts.action;
import javax.servlet.http.*;
import javax.servlet.*;
import java.util.*;public class onLineUser implements HttpSessionBindingListener {
public onLineUser() {
}private Vector users = new Vector();
public int getCount() {
users.trimToSize();
return users.capacity();
}public boolean existUser(String userName) {
users.trimToSize();
boolean existUser = false;
for (int i = 0; i < users.capacity(); i++) {
if (userName.equals((String) users.get(i))) {
existUser = true;
break;
}
}
return existUser;
}public boolean deleteUser(String userName) {
users.trimToSize();
if (existUser(userName)) {
int currUserIndex = -1;
for (int i = 0; i < users.capacity(); i++) {
if (userName.equals((String) users.get(i))) {
currUserIndex = i;
break;
}
}
if (currUserIndex != -1) {
users.remove(currUserIndex);
users.trimToSize();
return true;
}
}
return false;
}public Vector getOnLineUser() {
return users;
}public void valueBound(HttpSessionBindingEvent e) {
users.trimToSize();
if (!existUser(e.getName())) {
users.add(e.getName());
System.out.print(e.getName() + "\td到系l\t"
+ (new Date()));
System.out.println("在线用户Cؓ(f)Q? + getCount());
} else
System.out.println(e.getName() + "已经存在");
}public void valueUnbound(HttpSessionBindingEvent e) {
users.trimToSize();
String userName = e.getName();
deleteUser(userName);
System.out.print(userName + "\t退出系l\t" + (new Date()));
System.out.println("在线用户Cؓ(f)Q? + getCount());
}
}login.jsp--------------------------------------------------------------------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><jsp:useBean id="onlineuser" class="com.shaobo.struts.action.onLineUser"
scope="application" />
<html>
<head>
</head>
<body onUnload="postMessage()">
<center>
<p>
<h1>
登陆成功Q欢q访?BR> </h1>
</p>
</center>
<%
session = request.getSession(false);
%>
<%
String username = request.getParameter("username");
if (onlineuser.existUser(username)) {
out.println("用户<font color=red>" + username
+ "</font>已经登陆Q?);
} else {
session.setMaxInactiveInterval(50); //Sesion有效旉Q以Uؓ(f)单位
session.setAttribute(username, onlineuser);
out.println("Ƣ迎新用?<font color=red>" + username
+ "</font>登陆到系l!");
}
out.println("<br>当前在线用户人数:<font color=red>"
+ onlineuser.getCount() + "</font><br>");
String ip = request.getRemoteAddr();
out.println("<br>IP:<font color=red>" + ip + "</font><br>");
Vector vt = onlineuser.getOnLineUser();
Enumeration e = vt.elements();
out.println("在线用户列表");
out.println("<table border=1>");
out.println("<tr><td>用户?lt;/td></tr>");
while (e.hasMoreElements()) {
out.println("<tr><td>");
out.println((String) e.nextElement() + "<br>");
out.println("</td></tr>");
}
out.println("</table>");
%>
<center>
<p>
</p>
[
<a href="javascript:window.close()">关闭H口</a>]
<%
out.println("<p><a href='index.jsp'>退出系l?lt;/a></p>");
%>
</center>
<Script>
function postMessage(){
<%onlineuser.deleteUser(request.getParameter("username"));%>
}
</Script>
</body>
</html>Ƣ迎光(f)邉|L的空间` http://blog.sina.com.cn/shaobolive
QQ:343269876