代码之家  ›  专栏  ›  技术社区  ›  Mauli

SWT有可用的DateTime小部件吗?

  •  1
  • Mauli  · 技术社区  · 16 年前

    1 回复  |  直到 16 年前
        1
  •  7
  •   Favonius    16 年前

    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 ();
    }
    
    }
    

    这真的很好。比星云小部件好得多。。。

    当做