最简单实现类似html select选项的jcombobox

July 5, 2009 – 3:36 pm

参考:http://kylixs.blog.163.com/blog/static/1358330200711582516490/

package components.jcombobox;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JFrame;

public class ListItemComboBoxTest {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

阅读全文 »

运行Ant报Out of Memory错误

June 28, 2009 – 7:49 pm Tags: ,

执行ant时报Out of Memory错误。

解决办法:

设置环境变量ANT_OPTS指定JVM使用的内存。

Bash:

% export ANT_OPTS=”-Xms128m -Xmx256m”

Windows cmd:

C:> set ANT_OPTS=-Xms128m -Xmx1024m

>ant jar

jpa 使用toplink,整合spring的问题

June 28, 2009 – 7:23 pm Tags: , ,

  <bean id=”entityManagerFactory” class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean”>
     <property name=”persistenceXmlLocation” value=”persistence.xml”/>
   <property name=”persistenceUnitName” value=”demo35PU”/>
     <property name=”dataSource” ref=”dataSource”/>
    <property name=”jpaVendorAdapter”>

阅读全文 »

derby新版本支持offset了

June 24, 2009 – 11:55 pm Tags:

The new clauses can be added to any SELECT statement, and they’re defined like this:

[ OFFSET integer-literal {ROW | ROWS} ]
[ FETCH { FIRST | NEXT } [integer-literal] {ROW | ROWS} ONLY ]

(No, I’m not kidding, the standard actually requires you to type all those seemingly redundant keywords…)

You can use FETCH and OFFSET both alone and in combination with each other. For example, to select the three persons with the highest score from a table, you’d use a FETCH clause and no OFFSET clause, like this:


阅读全文 »

Derby的基本使用

June 21, 2009 – 11:05 pm Tags:

Derby是开源的基于Java的关系型数据库,采用Apache License 2.0,目前已经包括在jdk6 update6中。

它有2种发布模式:
1、嵌入式方式
单个用户使用,Derby数据库和Java程序运行在同一个JVM中。在这种情况下,用户几乎不直接操作数据库,因为它的启动和终止都是由程序来完成的,几乎不需要管理。
2、服务器方式:
Derby数据库由一个程序启动并通过网络提供多个用户的访问。在这种方式下,Derby运行在服务器JVM上,应用程序从不同的JVM上通过网络连接访问数据库。


阅读全文 »

jasperreport 通过java生成子报表

June 9, 2009 – 9:25 pm Tags:

public class SubReportsDemo {
static String fileName=”E:/JasperReport/customer_detail_rp.jrxml”;
public static void main(String[] args)throws Exception{
new SubReportsDemo().genRep();
}
public void genRep()throws Exception{
long startTime=System.currentTimeMillis();

Class.forName(”org.apache.derby.jdbc.ClientDriver”);
Connection con = DriverManager.getConnection(
“jdbc:derby://localhost:1527/crmyatsun”, “”, “”);

阅读全文 »

svn Item is not readable

May 30, 2009 – 11:44 am Tags:

今天配置SVN出现以下现象
配置目录权限时如:
[/]
adminstrator = rw
[/ytsource]
Group_yt = rw
结果两组的用户分别在根目录和/ytsource目录下可以正常show log,而在分别在其子目录中show log都会提示 Item is not readable.
最后在svnserve.conf 文件中,设置anon-access = none就可以了

阅读全文 »

解决Graphics2D..drawString(message, px, py)的乱码问题

May 29, 2009 – 10:46 pm Tags: ,

是否打印过程发生了问题

查看了JDK API的说明,发现在使用字体的时候,我没有特别设定,使用了默认字体。写了一个简单的输出平台默认字体的类,得到的字体却是一样的信息:

Default font:java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12]

1) 指定打印到图片的字体为中文

g2d.setFont(new Font(”宋体”, Font.PLAIN, 12));

2) 上传WinXp 中的宋体字体文件到服务器(Solaris)


阅读全文 »

proguard设置

May 29, 2009 – 12:07 am Tags:

使用jpa时特别要注意keep的class,包括方法名称,及keep属性设置

http://proguard.sourceforge.net/manual/examples.html#annotations

选项如下:

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keepnames class * implements java.io.Serializable

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;

阅读全文 »

解决 Eclipse 下使用 Ant 编译出现问题: 警告:编码 GBK 的不可映射字符

May 28, 2009 – 6:16 pm Tags: ,
在使用ant编译项目的时候经常会遇到“警告:编码 GBK 的不可映射字符”这样的信息,这个主要是因为我们在写代码的时候加入了一些中文注释,而导致编译时候出现的问题。要处理这个问题,仅仅只需要在 build.xml文件中的调用javac的地方加入encoding的参数。
如下所示:
<javac
encoding=”utf-8″
destdir=”${compile.dir}”

阅读全文 »