随笔-9  评论-2  文章-0  trackbacks-0
  2011年6月22日
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ComboTest {

    
public static void main(String[] args) {
        String[] WEEK 
= { "Monday""Tuesday""Wednesday"};
        Display display 
= new Display();
        Shell shell 
= new Shell(display);
        shell.setBounds(
500100500300);
        shell.setText(
"Combo");
        shell.setLayout(
new GridLayout(3true));
        
        
//创建Combo组件,为下拉列表样式
        final Combo dc = new Combo(shell, SWT.DROP_DOWN);
        dc.setItems(WEEK);
        dc.addSelectionListener(
new SelectionAdapter(){
            @Override
            
public void widgetSelected(SelectionEvent e) {
                String key 
= ""+dc.getSelectionIndex();
                String value 
= dc.getText();
                System.out.println(
"key:"+key+"    value:"+value);
            }
        });
        
        
//创建Combo组件,为下拉列表样式,且只读
        final Combo rc = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
        
//在界面中显示的是123
        rc.add("123");
        
//第一个值是key从0开始 ,第二个值为value
        rc.setData("0""321");
        
        rc.add(
"456");
        rc.setData(
"1""654");
        
        rc.addSelectionListener(
new SelectionAdapter(){
            @Override
            
public void widgetSelected(SelectionEvent e) {
                String key 
= ""+rc.getSelectionIndex();
                System.out.println(
"key:"+key);
                String value 
= (String) rc.getData(key);
                System.out.println(
"key:"+key+"    value:"+value);
            }
        });
        
//rc.setItems(MONTHS);
        
//创建Combo组件,为List组件样式
        Combo sc = new Combo(shell, SWT.SIMPLE);
        sc.setItems(WEEK);
        shell.open();
        
while (!shell.isDisposed()) {
           
if (!display.readAndDispatch()) {
               display.sleep();
          }
     }

     display.dispose();

    }

}
posted @ 2011-08-02 14:22 secret_x15 阅读(12820) | 评论 (0)编辑 收藏
 Eclipse添加DTD文件实现xml的自动提示功能

1.点击 window -->Preferences -->XML -->XML Catalog  -->Add..

2.点击Add 弹出一个对话框,如图所示



3.填写文本框中的内容

Location : dtd的路径。可以是eclipse工作空间的dtd,也可以是文件中的dtd。
Key type:选择 Public ID
Key:为ibatis xml文件头中<!DOCTYPE sqlMapConfig PUBLIC 后面的一段。即:-//ibatis.apache.org//DTD SQL Map Config 2.0//EN

4. 点击OK 按钮,重启eclipse.
posted @ 2011-06-29 18:18 secret_x15 阅读(5435) | 评论 (0)编辑 收藏
"window.location.href"、"location.href"是本页面跳转.
"parent.location.href" 是上一层页面跳转.
"top.location.href" 是最外层的页面跳转.
举例说明:
    如果A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写
    "window.location.href"、"location.href":D页面跳转
    "parent.location.href":C页面跳转
    "top.location.href":A页面跳转
如果D页面中有form的话,
    <form>:  form提交后D页面跳转
    <form target="_blank">:  form提交后弹出新页面
    <form target="_parent">:  form提交后C页面跳转
    <form target="_top"> :  form提交后A页面跳转

如果访问的是iframe里面的页面,重新加载最外层的页面
<html>
<head>
<title></title>
<script language="javascript">
function escapeFrame(){
      
if (window.top.location.href != window.location.href) {
        window.top.location.reload();
      }
}
</script>
</head>

<body onload="escapeFrame()">
<iframe src="b.html" ></iframe>
</body>
</html>
posted @ 2011-06-28 10:25 secret_x15 阅读(5457) | 评论 (1)编辑 收藏
main方法:
public class Test {

    
public static void main(String[] args) {
        
/**
         * 
         * sort()方法详解
         * 1.Collections.sort(List<T> list) 
         *         根据元素的自然顺序 对指定列表按升序进行排序。
         * 2.Collections.sort(List<T> list, Comparator<? super T> c) 
         *         根据指定比较器产生的顺序对指定列表进行排序。
         * 
         
*/
        List
<Integer> list = new ArrayList<Integer>();
        list.add(
3);
        list.add(
1);
        list.add(
2);
        
//自然顺序
        Collections.sort(list);
        
for(Integer i:list){
            System.out.println(i);
        }
        
        System.out.println(
"===============================================");
        
        Point point2 
= new Point(2,2,2);
        Point point1 
= new Point(1,1,1);
        Point point3 
= new Point(3,1,2);
        
        List
<Point> points = new ArrayList<Point>();
        points.add(point2);
        points.add(point1);
        points.add(point3);
        
        System.out.println(
"===============================================");
        
//根据point中的升序输出
        Collections.sort(points, new SortByXdesc());
        
for(Point point:points){
            System.out.println(
"x:"+point.getX()+" y:"+point.getY()+" z:"+point.getZ());
        }
        
        System.out.println(
"===============================================");
        
//根据point中的x降序输出
        Collections.sort(points, new SortByXasc());
        
for(Point point:points){
            System.out.println(
"x:"+point.getX()+" y:"+point.getY()+" z:"+point.getZ());
        }
    }

}

降序输出类SortByXdesc:

public class SortByXdesc implements Comparator<Object> {

    
//根据point中的x降序输出
    @Override
    
public int compare(Object o1, Object o2) {
        Point point1 
=(Point)o1;
        Point point2 
=(Point)o2;
        
if(point1.getX()>point2.getX()){
            
return 1;
        }
else{
            
return 0;
        }
    }

}

升序输出类SortByXasc:

public class SortByXasc implements Comparator<Object> {

    
//根据point中的x升序输出
    @Override
    
public int compare(Object o1, Object o2) {
        Point point1 
=(Point)o1;
        Point point2 
=(Point)o2;
        
if(point1.getX()>point2.getX()){
            
return 0;
        }
else{
            
return 1;
        }
    }
}

posted @ 2011-06-22 16:03 secret_x15 阅读(6463) | 评论 (1)编辑 收藏