惭愧惭愧
今天才领略了一下HashMap的代码,原来HashMap是一个双重hash码为索引的数组,数组里放的是Entry的链表(也就是拥有相同hashcode的对象会存储于这个链表里,而不是被覆盖掉)。
因为上次被人问到,居然没有答上来。记录在此。
今天才领略了一下HashMap的代码,原来HashMap是一个双重hash码为索引的数组,数组里放的是Entry的链表(也就是拥有相同hashcode的对象会存储于这个链表里,而不是被覆盖掉)。
因为上次被人问到,居然没有答上来。记录在此。
SWT的布局管理
FillLayout组件填满整个容器,当容器大小变化时,组件同时跟随变化。如果同时添加多个组件,则每个组件将平均分配容器空间。默认情况下filllayout会水平添加多个组件。可以通过设置来达到垂直加入。s.setLayout(new FillLayout(SWT.VERTICAL));
RowLayout组件会按行排列,当容器大小不够排列时,组件会自动排到第二排。如果不希望容器自动排列,可以通过设置wrap:rl.wrap = false;如果想要让一排中所有组件都同宽,可以通过设置pack:rl.pack = false;设置纵向排列RowLayout rl = new RowLayout(SWT.VERTICAL);
GridLayout可以设置参数决定组件加入容器时占多少行、列单元格,如何填充.设置列数:GridLayout gl = new GridLayout( ); gl.numColumns=3; s.setLayout(gl);控制组件的尺寸和对齐方式:对齐方式:GridData gd = new GridData( );gd.horizontalAlignment = GridData.CENTER;//GridData.BEGINNING,GridData.ENDl1.setLayoutData(gd);组件填充方向:gd = new GridData(GridData.FILL_HORIZONTAL); //FILL_VERTICAL,FILL_BOTHt1.setLayoutData(gd);
FormLayout用来布局表单,也是最复杂的布局管理,在FormLayout中FormData和FormAttachment的设置是必需的。 FormData fd = new FormData( ); fd.top = new FormAttachment(10, 10); fd.left = new FormAttachment(0, 10); fd.bottom = new FormAttachment(30,0); fd.right = new FormAttachment(40,0); l1.setLayoutData(fd);上面这几行代码首先设置了组件的上下左右边缘的距离 – 上端位于整个容器的10%处,
(翻出来的一篇老文,备份上来)
14:09 2006-7-14
一.从eclipse输出项目jar包 — 注意main-class的设置
二.将所有依赖包签名
a.怎么创建签名:
1.创建密钥库
keytool -genkey -keystore myKeystore -alias myself
myKeystore 密钥库的名字(这里会生成一个以它为文件名的文件,该文件不能移动位置)
myself 密钥的别名
2.根据创建好的密钥库创建自己的证书
keytool -selfcert -alias myself -keystore myKeystore
3.查看密钥库中是否创建了相应的证书
keytool -list -keystore myKeystore
Keystore 类型: jks
Keystore 提供者: SUN
您的 keystore 包含 1 输入
myself, 2006-7-13, keyEntry,
认证指纹 (MD5): A7:BB:42:89:15:B4:4E:7A:2E:A4:4F:E5:89:24:06:55
b.怎样给jar文件签名
jarsigner -keystore myKeystore test.jar myself
myKeystore 指定密钥库
myself 指定要使用的密钥的别名
test.jar 要签名的jar文件
(所有要发布的jar包都要签名)
三.创建jnlp文件(jws的部署描述文件)
jnlp文件中使用的标签参考:http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html
例子:
<?xml version=”1.0″ encoding=”utf-8″?>
<jnlp spec=”1.0+” codebase=”http://localhost:8080/” href=”rssreader.jnlp”>
<information>
<title>**title**</title>
<vendor>**vendor**</vendor>
<description>**description**</description>
<description kind=”short”>**anther description**</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version=”1.4+”/>
<jar href=”rssreader.jar”/>
</resources>
<resources os=”Windows”>
<jar href=”jdic.jar”/>
<jar href=”lib/commons-collections-3.1.jar”/>
<jar href=”lib/commons-configuration-1.2.jar”/>
<nativelib href=”jdic-native.jar”/>
</resources>
<application-desc main-class=”com.zhangv.rss.RssReader”/>
</jnlp>
四:发布
将所有文件(jnlp,jar)放到服务器上,注意相对路径
五:使用jdic的程序发布还是有问题
难道客户端一定还要配置那些(dll,exe)到path吗?
nativelib为什么没有起作用?
很早前在学校时候写的一个生成目录文件列表的东西,因为那时候自己开了一个ftp服务器。
import java.util.Date;
import java.util.Arrays;
import java.io.*;
/**
* Time: 2003-12-23 20:46:42
*/
public class FileManager {
private String ListFilename = "@list.txt";
private String root;
private String updatetime;
public FileManager(String root) {
this.root = root;
updatetime=new Date().toString();
}
private void getList(String dir) {
File tmp = new File(dir);
File[] files = tmp.listFiles(new ffilter());
File[] dirs = tmp.listFiles(new dfilter());
if (files.length != 0) {
writeListFile(files);
}
if (dirs.length != 0) {
for (int i = 0; i < dirs.length; [...]
推荐swing上的calendar组件 – toedter
推荐swt上的calendar组件 – swtcalendar
放到这里留作备份.还有一个pdf版的更详细.
当用sun的odbc-jdbc driver去连接access时会出现这个问题(用ibatis)
因为这个driver不支持long类型的字段,解决办法:
在类中把相应字段类型改为bigdecimal或者int。
今天用httpunit写一个测试时候发现无法设置select框,报错是:
com.meterware.httpunit.IllegalParameterValueException: May not set parameter ‘userInfo.processingUnit’ to ‘BOM’. Value must be one of: { }
at com.meterware.httpunit.SelectionFormControl$Options.reportNoMatches(FormControl.java:1186)
at com.meterware.httpunit.SelectionFormControl$SingleSelectOptions.claimUniqueValues(FormControl.java:1360)
at com.meterware.httpunit.SelectionFormControl$Options.claimUniqueValues(FormControl.java:1178)
at com.meterware.httpunit.SelectionFormControl.claimUniqueValue(FormControl.java:1059)
…
跟进发现,webform无法通过getOptions来获取选择项.google后发现有人建议把页面中的
<html xmlns=”http://www.w3.org/1999/xhtml”>
改成
<html>
果然管用. 为什么会影响到httpunit? 指定上述的命名空间的意思是说这个html文档是遵守xhtml规范.通过下面的方法打开httpunit的解析详情 – httpunit会在得到html内容后告诉你这个文档是否遵守了你所指定的规范.(这里是xhtml).
HttpUnitOptions.setParserWarningsEnabled(true);
结果会得到这样的信息:
At line 121, column 1: Element <BODY> not closed properly.
At line 121, column 1: Element <HTML> not closed properly.
At line 1249, column 1: Element <BODY> not closed properly.
At line 1249, column [...]
Javablog » How MIDlet Signing is Killing J2ME
TODO: 翻译
偶然的灵感, 能否以后编程就和写作文一样呢? 这也应该是面向对象的终极目标吧.下面这个是经常出现在教科书上的例子.
Person tom = new Person() – > tom is a Person
Dog trigger = new Dog() -> trigger is a Dog
List<Person> friends = new ArrayList<Person> – > Person have Person friends
Person implements Emotianal,HumanBehave -> Person behave Emotional and surely behave as a human.
interface Emotional{ sadly(); happily();} ->Emotional including sadly and happily doing things.
interface [...]