显示标签为“java”的博文。显示所有博文
显示标签为“java”的博文。显示所有博文

2009年4月8日星期三

Google App Engine开始支持Java

一开始google就表示Google App Engine会支持更多的语言,除了Python之后,第一个将是Java,今天终于出现在Google App Engine的主页上了,想用GAE玩Java的赶紧喽,有人数限制的的哦,详细:

An Early Look at Java™ Language Support New!
App Engine is unveiling its second language: Java. Today's release includes an early look at our Java runtime, integration with Google Web Toolkit, and a Google Plugin for Eclipse, giving you an end-to-end Java solution for AJAX web applications. Our support for the Java language is still under development and we're eager to get your help and input. For now, access will be limited to the first 10,000 developers who sign up, but we'll be including more as soon as possible. Give it a try and send us your feedback.

2008年12月6日星期六

java 中函数参数个数未知的两种实现形式

java 中函数参数个数未知的两种实现形式


//:initialization/VarArgs.java

class A {}

public class VarArgs
{
static void printArray(Object[] args) {
for (Object obj : args)
System.out.print(obj +" ");
System.out.println();
}
public static void main(String[] args) {
printArray(new Object[] {
new Integer(47),
new Float(3.14),
new Double(11.11)
});
printArray(new Object[] {"one","two","three"});
printArray(new Object[] {new A(),new A(),new A()});
}
}
/*output:
47 3.14 11.11
one two three
A@1a46e30 A@3e25a5 A@19821f
*/

以上是JavaSE5以前的做法,下边的是JavaSE5中新增的特性,更加方便使用

//:initialization/NewVarArgs.java

public class NewVarArgs {
static void printArray(Object... args) {
for(Object obj : args)
System.out.print(obj + " ");
System.out.println();
}
public static void main(String[] args) {
printArray(new Integer(47),
new Float(3.14),
new Double(11.11));
printArray(47,3.14F,11,11);
printArray("one","two","three");
printArray(new A(),new A(),new A());
//or an array
printArray((Object[])new Integer[] {1,2,3,4});
printArray();//Empty list is OK
}
}
/*output
47 3.14 11.11
47 3.14 11 11
one two three
A@1a46e30 A@3e25a5 A@19821f
1 2 3 4
*/


此篇文章为阅读Thinking in Java摘抄

2008年10月19日星期日

Ubunt下Java中文字体的支持

Java程序是夸平台的,但是在ubuntu要解决中文字题问题,
方法就是给jre中添加一个中文字体

cd /usr/lib/jvm/java-6-sun/jre/lib/fonts

  sudo mkdir fallback

  cd fallback

  sudo ln -s /usr/share/fonts/truetype/wqy/wqy-zenhei.ttf(这里选择的是文泉驿正黑)

  sudo mkfontdir

  sudo mkfontscale

eclipse安装插件的三种方法

1 Install from Update Manager
比如安装VE这个可视化编辑UI的插件,其步骤为
  Help > Software Updates... > Available Software
Add Site... >
add the VE 1.4 Update site:
http://update.soyatec.org/Ganymede/ve/1.4

2 下载相应的插件解压后扔进去,
直接按照相应的目录扔到对应的eclipse目录的features跟plugins目录下
3 在eclipse目录下新建一个links目录
在eclipse/links目录下信件一个文本文件,比如link.ini,编辑如下
path=PLUGINS1_HOME
path=PLUGINS2_HOME
,其中PLUGINS1_HOME就是你插件所在的位置,
可以是相对位置,比如说将Visual Editor这个插件
直接解压到eclipse目录下重命名为VE,link.ini里就该添加这么一行
path=VE
,也可以是绝对位置,比如说我将插件解压重命名为/home/user/plugins/VE,
那么eclipse/links/link.ini就应给添加这么一行
path=/home/user/plugins/VE。
eclise在启动的时候会自动搜索eclipse/links目录下文本文件,
并加载path所指向的所有插件

ps:安装VE的话还需要GEF,EMF这两个插件

2008年10月18日星期六

修改Swing组件JButton

把JButton修改成只在鼠标经过时才绘制边框,从而在按钮上创建悬浮效果

import javax.swing.JButton;
import java.awt.event.*;
public class JCoolButton extends JButton {
public JCoolButton() {
super();
init();
}

public void init() {
setBorderPainted(false);
addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent arg0){
setBorderPainted(true);
}
public void mouseExited(MouseEvent arg0) {
setBorderPainted(false);
}
});
}
}

有鼠标经过时,无鼠标经过时