企业架构师成长之路

一些心得体会..

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  3 Posts :: 1 Stories :: 3 Comments :: 0 Trackbacks

2005年12月19日 #

文章很长的话...显示在列表上基本上会占整页,如何只显示几句,点进去后才阅读全文呢?
posted @ 2005-12-19 09:45 风风 阅读(487) | 评论 (2)编辑 收藏

现象:

  JBuilder启动时有一个启动画面,在Jbuilder所有的初始化工作都完成之后,启动画面消失,继而JBuilder可以开始使用。

  解决方案:

  该方案基于我所做过的一个项目。

  1、新建一个启动画面Window类

  java.awt.Window windowSplash;

  2、调用prepareSplash()函数,初始化启动界面

  private void prepareSplash()
 {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    windowSplash = new Window( this );
    Image image = toolkit.getImage( "images" + File.separator + "splash.gif" );
    ImageCanvas canvas = new ImageCanvas( image );
    windowSplash.add( canvas, "Center" );
    Dimension scmSize = toolkit.getScreenSize();
    int imgWidth = image.getWidth( this );
    int imgHeight = image.getHeight( this );
    windowSplash.setLocation( scmSize.width/2 - (imgWidth/2), scmSize.height/2 - (imgHeight/2) );
   windowSplash.setSize( imgWidth, imgHeight );
  }

  3、在Application的JFrame类(主界面)中调用startSplash(),显示启动界面,然后初试化JFrame的各个可视化组件,初始化后台数据库等(如数据
库的连接)

  private void startSplash()
  {
    windowSplash.setVisible( true );
   windowSplash.toFront();
  }

  4、在所有的初始化工作完成之后,调用stopSplash()函数,停止显示启动画面

  private void stopSplash()
{
   windowSplash.dispose();
 }
posted @ 2005-12-19 08:51 风风 阅读(409) | 评论 (1)编辑 收藏

import java.io.*;
public class StringTest
{
public static void main(String[] args)
{
String aString = "这是一个测试串,This is a test string.";
String anotherString = null;
try {
anotherString = new String(aString.getBytes("GBK"), "ISO8859_1");
}
catch (UnsupportedEncodingException ex) {
}
System.out.println(aString.length() + "," + anotherString.length());
}
}
posted @ 2005-12-19 08:49 风风 阅读(337) | 评论 (0)编辑 收藏