2007年3月12日星期一

研发中心的新路由


以前师兄给研发中心做了一个路由,然后就走了,想想时间,他当时也是处于想我这样的阶段(大三下学期)。

不知道为什么,忽然之间很想把那个路由重新做,因为是在是太不稳定了,用着好好的的ip居然会被别人抢掉,重启之后要人工动手去搞,用简单的ittables充当router功能,担心其吃不消。管理麻烦。

于是想重新给研发中心安装一个路由。

在网上,找到了一些资料,发现软路由还不少。coyoteLinux只支持软盘,晕,去哪儿找个软盘来?最后还是发现,routerOS最合要求,方便。


记录一下安装配置过程。

把光盘放进光驱,启动,选择全部组件安装。其中发现了一个问题,认不出scsi硬盘。无奈,换了一块500MB的古董硬盘。装好后,不知道是网卡问题还是系统问题,一开始有两块网卡就开始配置有点问题,只好把一块网卡摘下来,先配好一块内网的网卡。然后再把剩下的网卡放上,继续配置。然后添加网关,注意手工添加的网关应该是AS的。然后就是进行nat装换,把内网的ip伪装成外网的ipwinbox里,ip->firewall->nat 添加一条actionmasqueradeoutput interface 为外网网卡的规则.

现在已经可以上网了.至于余下的设置,就要再以后看要限制什么了.

2006年12月26日星期二

java6的启动界面

Splash screens are a standard part of any modern graphical user interface (GUI) application. Their primary purpose is to let the user know that the application is starting up. An application that displays a polished and professional-looking splash screen can occupy the user's attention and gain the user's confidence that the application is starting. In addition, splash screens may provide marketing information. And they are sometimes required for legal reasons: to present copyright information, third-party logos, and so forth.

You can use Java Foundation Classes/Swing (JFC/Swing) or AWT to create splash screens in Java technology applications. However, because the main purpose of a splash screen is to provide the user with feedback about the application's startup, the delay between the application's startup and the moment when the splash screen pops up should be minimal. Before the splash screen can pop up, the application has to load and initialize the JVM*, AWT, usually Swing, and perhaps some application-dependent libraries. The resulting delay of several seconds has made use of a Java technology-based splash screen less than desirable. Until now.

Java Platform, Standard Edition (Java SE, formerly known as J2SE) version 6, provides a solution that allows the application to show the splash screen much earlier, even before the virtual machine starts. Now, a Java application launcher is able to decode an image and display it in a simple nondecorated window (see Figure 1).

Note: To run the code in this article, you must download and install Java SE 6.

Use of an option in the manifest file can allow a JAR-packaged application to display a splash screen. Other types of applications can use a command-line option. You can use a desktop shortcut or a script to provide the command-line option to the Java application launcher. The splash screen can display any GIF, PNG, or JPEG image, with transparency, translucency, and animation.

There are two ways to show the native splash screen:

  • If your application is run from the command line or from a shortcut, use the -splash: Java application launcher option to show a splash screen:

      java -splash:filename.gif SplashTest

  • If your application is packaged in a JAR file, you can use the SplashScreen-Image option in a manifest file to show a splash screen. Place the image in the JAR archive and specify the path in the option. For example, use this code in the manifest.mf file:

         Manifest-Version: 1.0
    Main-Class: SplashTest
    SplashScreen-Image: filename.gif

    The command-line interface has precedence over the manifest setting.

The feature is extremely easy to use. In most cases, all you need to do is provide the image and use a launcher option. The splash screen will close automatically when the first AWT or Swing window is displayed.

In certain cases, you might want to provide some additional dynamic information in the splash screen. The SplashScreen class may be used to close the splash screen, change the splash-screen image, get the image position or size, and paint in the splash screen. The class cannot be used to create the splash screen. You should use the command-line or manifest-file option for that.

In addition, this class cannot be instantiated. Only a single instance of this class can exist, and it may be obtained using the getSplashScreen() static method. If the application has not created the splash screen at startup through the command-line or manifest-file option, the getSplashScreen method returns null.

Typically, you want to keep the splash-screen image on the screen and display something over the image, such as a progress indicator. The splash-screen window has an overlay surface with an alpha channel, and you can access this surface with a traditional Graphics or Graphics2D interface.

The following code sample demonstrates how you first obtain the SplashScreen object, then obtain a graphic handle with the getGraphics() method. Next, obtain the size of the splash screen, and clear the image if you already have drawn anything there. Set an AlphaComposite.Clear composite mode, and paint a rectangle over the whole splash screen. Restore the painting mode and paint whatever you want. Lastly, call the update() method to display what you have drawn.

SplashScreen splash = SplashScreen.getSplashScreen();
Graphics2D g = (Graphics2D)splash.getGraphics();
Dimension size = splash.getDimension();
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, size.width, size.height);
g.setPaintMode();

Also, you might want to replace the splash screen with an AWT or Swing window:

SplashScreen splash = SplashScreen.getSplashScreen();
// Obtain the splash-screen bounds.
Rectangle splashBounds = splash.getBounds();

Now show your new hand-coded splash-screen window at exactly the same location as specified in splashBounds. The original splash screen closes automatically.

You may change the image in the splash screen with the setImageURL method. If the user wants to close the splash screen before the first AWT or Swing window is displayed (or in the rare case that AWT or Swing is not used for the application GUI), this may be done with the SplashScreen.close method.

The following application is an example of how the new splash screen works.

import java.awt.*;
import java.awt.event.*;

public class SplashTest extends Frame implements ActionListener {
static void renderSplashFrame(Graphics2D g, int frame) {
final String[] comps = {"foo", "bar", "baz"};
g.setComposite(AlphaComposite.Clear);
g.fillRect(130,250,280,40);
g.setPaintMode();
g.setColor(Color.BLACK);
g.drawString("Loading "+comps[(frame/5)%3]+"...", 130, 260);
g.fillRect(130,270,(frame*10)%280,20);
}
public SplashTest() {
super("SplashScreen demo");
setSize(500, 300);
setLayout(new BorderLayout());
Menu m1 = new Menu("File");
MenuItem mi1 = new MenuItem("Exit");
m1.add(mi1);
mi1.addActionListener(this);

MenuBar mb = new MenuBar();
setMenuBar(mb);
mb.add(m1);
final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash == null) {
System.out.println("SplashScreen.getSplashScreen() returned null");
return;
}
Graphics2D g = (Graphics2D)splash.getGraphics();
if (g == null) {
System.out.println("g is null");
return;
}
for(int i=0; i<100; i++) {
renderSplashFrame(g, i);
splash.update();
try {
Thread.sleep(200);
}
catch(InterruptedException e) {
}
}
splash.close();
setVisible(true);
toFront();
}
public void actionPerformed(ActionEvent ae) {
System.exit(0);
}
public static void main (String args[]) {
SplashTest test = new SplashTest();
}
}

Note that getGraphics creates a graphics context (as a Graphics object) for the splash-screen overlay image, which allows you to draw over the splash screen. Rather than drawing on the main image, you draw instead on the image that is displayed over the main image, using alpha blending. Also note that drawing on the overlay image does not necessarily update the contents of the splash-screen window. You should call update() on the SplashScreen when you want the splash screen to be updated immediately.

2006年12月10日星期日

实现某个程序只可以打开一个的思路

反正使用任何一个特定的系统共有资源;
  • 往一个固定的位置写一个文件;
  • 打开一个固定的port;
  • 又或者每一次程序启动都必须给你发条短信,你回答Y才可以启动.
但只是思路,想一想,其实是第一个方法是最好的,derby也是这样实现的,如果用derby的emdeb模式,每次打开derby数据库,它都在数据库的目录下生成一个*.loc的文件.这样就是表示数据库已经被打开了.
第二种方法,打开一个固定的port,是比较容易实现,可是比较容易出问题,如果固定的port被占用了呢?
第三种,可能会比较烦一点.

2006年12月9日星期六

[转帖]如何才算掌握Java(J2SE篇)

时常看到一些人说掌握了Java,但是让他们用Java做一个实际的项目可能又困难重重,在这里,笔者根据自己的一点理解斗胆提出自己的一些对掌握Java这个说法的标准,当然对于新手,也可以提供一个需要学习哪些内容的参考。另外这个标准仅限于J2SE部分,J2EE部分的内容有时间再另说。

1、语法:必须比较熟悉,在写代码的时候IDE的编辑器对某一行报错应该能够根据报错信息知道是什么样的语法错误并且知道任何修正。

2、命令:必须熟悉JDK带的一些常用命令及其常用选项,命令至少需要熟悉:appletviewer、HtmlConverter、jar、java、javac、javadoc、javap、javaw、native2ascii、serialver,如果这些命令你没有全部使用过,那么你对java实际上还很不了解。

3、工具:必须至少熟练使用一种IDE的开发工具,例如Eclipse、Netbeans、JBuilder、Jdeveloper、IDEA、JCreator或者Workshop,包括进行工程管理、常用选项的设置、插件的安装配置以及进行调试。

4、API:Java的核心API是非常庞大的,但是有一些内容笔者认为是必须熟悉的,否则不可能熟练的运用Java,包括:

1)、java.lang包下的80%以上的类的功能的灵活运用。

2)、java.util包下的80%以上的类的灵活运用,特别是集合类体系、规则表达式、zip、以及时间、随机数、属性、资源和Timer。

3)、java.io包下的60%以上的类的使用,理解IO体系的基于管道模型的设计思路以及常用IO类的特性和使用场合。

4)、java.math包下的100%的内容。

5)、java.net包下的60%以上的内容,对各个类的功能比较熟悉。

6)、java.text包下的60%以上的内容,特别是各种格式化类。

7)、熟练运用JDBC。

8)、java.security包下40%以上的内容,如果对于安全没有接触的话根本就不可能掌握java。

9)、AWT的基本内容,包括各种组件事件、监听器、布局管理器、常用组件、打印。

10)、Swing的基本内容,和AWT的要求类似。

11)、XML处理,熟悉SAX、DOM以及JDOM的优缺点并且能够使用其中的一种完成XML的解析及内容处理。

5、测试:必须熟悉使用junit编写测试用例完成代码的自动测试。

6、管理:必须熟悉使用ant完成工程管理的常用任务,例如工程编译、生成javadoc、生成jar、版本控制、自动测试。

7、排错:应该可以根据异常信息比较快速的定位问题的原因和大致位置。

8、思想:必须掌握OOP的主要要求,这样使用Java开发的系统才能是真正的Java系统。

9、规范:编写的代码必须符合流行的编码规范,例如类名首字母大写,成员和方法名首字母小写,方法名的第一个单词一般是动词,包名全部小写等,这样程序的可读性才比较好。

2006年11月27日星期一

wonuy猪猪基本完成

呼.bogger又可以上了,不过不知道哪天又会撞墙.在那段bogger撞墙的日子,真的不知道去哪儿写blog好. 昨天,写给女朋友的开支管理swing版终于基本上完成功能了,不过还要继续完善,不过已经不想化太多时间搞了,毕竟要考试了. ok,现在把wonuly开支管理的架构mark下来先: 用到的包:
jdk1.6RC