2006年12月20日

第一个ITEXT的程序

最近因为工作需要在看iText,以前都没接触过报表这一块,从头学习中。。。
第一个ITEXT的程序
//Step 1: define document
Rectangle rectPageSize = new Rectangle(PageSize.A4);
Document document 
= new Document(rectPageSize,50,50,40,40);

Paragraph paragraph1 
= new Paragraph("Welcome to IText");
paragraph1.setAlignment(Paragraph.ALIGN_CENTER);
PdfPTable table 
= new PdfPTable(2);
PdfPCell cell 
= new PdfPCell();
cell.addElement(paragraph1);
cell.setColspan(
2);
table.addCell(cell);
cell 
= new PdfPCell();
cell.addElement(
new Paragraph("Test1"));
table.addCell(cell);
cell 
= new PdfPCell();
cell.addElement(
new Paragraph("Test2"));
table.addCell(cell);

//Step 2: define output
PdfWriter.getInstance(document,new FileOutputStream("test.pdf"));

//Step 3: open document
document.open();

//Step 4: add elements
document.add(table);

//Step 5: close document
document.close();

posted @ 2006-12-27 16:24 EdwinWang 阅读(422) | 评论 (0)编辑 收藏

试用Netbeans5.5

今天尝试了下Netbeans 5.5版本,个人感觉很不错。一直都不太喜欢Eclipse,也许Eclipse给开发人员带来了最灵活的IDE,可灵活是有代价的,装个其他开发环境大概十到二十分钟就好了,装Eclipse加上捣鼓那些插件估计能搞上一天。
试了下在Netbeans5.5下开发Swing,web,web service,JSF等一些功能,感觉还不错。虽然一些图形化的拖拉效果做的还不尽如人意,但已经很不错了。据说还可以可视化开发Mobile程序,改天要试一下。
虽然Netbeans的灵活性不如eclipse,但是功能还是很强大的,值得使用。个人感觉eclipse更适合玩IDE的人而不是用IDE的人使用。Just 个人意见,呵呵~~

posted @ 2006-12-21 11:10 EdwinWang 阅读(260) | 评论 (0)编辑 收藏

如何在JAVA程序中调用windows其他程序

虽然JAVA是平台无关性的,但是在企业中很多时候还是在为特定的系统在开发,会要求调用一些当前系统的其他程序或命令。最常见的是在WINDOWS中。其实JAVA是可以通过Runtime去调用系统中的一些程序的,下面是一个例子:

try {
            ps 
=  Runtime.getRuntime().exec( " E:\\test.exe " );
            
// ps = Runtime.getRuntime().exec("ipconfig");  ---- For execute windows commands
            
// ps = Runtime.getRuntime().exec("E:\\test.bat"); ---- For run BAT files
            BufferedReader in  =   new  BufferedReader( new    InputStreamReader(ps.getInputStream()));
            String inputLine; 
            
while ((inputLine    =    in.readLine())    !=     null {  
                result   
+=    inputLine + " \n " ;
            }

            in.close();
            System.out.println(
" Output: "   +  result);
            
        }
catch (Exception ex) {
            System.out.println(
" Error "   +  ex.getMessage());
        }

上面的代码片断中后面一部分是在取返回的参数,如果不需要可以不取。不取的话可能也就不需要取得到Process了。用这个方法可以运行windows中的exe或者bat文件。

posted @ 2006-12-20 10:49 EdwinWang 阅读(1148) | 评论 (1)编辑 收藏

<2006年12月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜