【问题标题】:Is there a useable DateTime widget for SWT?SWT 是否有可用的 DateTime 小部件?
【发布时间】:2010-06-24 12:41:58
【问题描述】:

Nebula CDateTime 几乎无法用于输入日期和时间。是否有明智的开源替代方案?

【问题讨论】:

    标签: java eclipse swt datetimepicker


    【解决方案1】:

    使用org.eclipse.swt.widgets.DateTime ...

    来源: http://www.eclipse.org/swt/snippets/

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.layout.RowLayout;
    import org.eclipse.swt.widgets.DateTime;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    
    
    public class SWTExample 
    {
    public static void main (String [] args) 
    {
        Display display = new Display ();
        Shell shell = new Shell (display);
        shell.setLayout (new RowLayout ());
    
        DateTime calendar = new DateTime (shell, SWT.CALENDAR);
        calendar.addSelectionListener (new SelectionAdapter() {
            public void widgetSelected (SelectionEvent e) {
                System.out.println ("calendar date changed");
            }
        });
    
        DateTime time = new DateTime (shell, SWT.TIME);
        time.addSelectionListener (new SelectionAdapter () {
            public void widgetSelected (SelectionEvent e) {
                System.out.println ("time changed");
            }
        });
    
        shell.pack ();
        shell.open ();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
    }
    
    }
    

    真的很好。比星云小部件好多了...

    问候,

    【讨论】:

    • 我只是不喜欢这个小部件。还有其他想法吗?
    • SWT.DROP_DOWN代替SWT.CALENDAR,看起来好多了!
    猜你喜欢
    • 2010-09-10
    • 1970-01-01
    • 2012-11-15
    • 2019-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多