Package javax.swing

Examples of javax.swing.Timer


                    if ( e.getKeyCode() == KeyEvent.VK_ENTER ) {
                        okButt.doClick();
                        return;
                    }

                    javax.swing.Timer timer = new Timer( 50,
                                                         new ActionListener() {
                                                             public void actionPerformed(ActionEvent e)
                                                             {
                                                                 String constr = tf.getText();
                                                                 try {
                                                                     if ( tf == layoutConstrTF ) {
                                                                         ConstraintParser.parseLayoutConstraint( constr );
                                                                     } else if ( tf == rowsConstrTF ) {
                                                                         ConstraintParser.parseRowConstraints( constr );
                                                                     } else if ( tf == colsConstrTF ) {
                                                                         ConstraintParser.parseColumnConstraints( constr );
                                                                     } else if ( tf == componentConstrTF ) {
                                                                         ConstraintParser.parseComponentConstraint( constr );
                                                                     }

                                                                     tf.setBackground( Color.WHITE );
                                                                     okButt.setEnabled( true );
                                                                 } catch ( Exception ex ) {
                                                                     tf.setBackground( ERROR_COLOR );
                                                                     okButt.setEnabled( false );
                                                                 }
                                                             }
                                                         } );
                    timer.setRepeats( false );
                    timer.start();
                }
            } );

            return tf;
        }
View Full Code Here


    stopButton = transportControlPanel.getButton(TransportControlPanel.STOP_BUTTON);
    stopButton.addActionListener(this);

    this.add(southernPanel, BorderLayout.SOUTH);

    progressTimer = new Timer(1000, this);

    performanceQueryTimer = new Timer(2000, this);

    initFileChoosers();

    //create file selectors (used to populate CR and CI panels later)
    readerFileSelector = new FileSelector(null, "Collection Reader Descriptor",
View Full Code Here

    // );

    // load user preferences
    restorePreferences();

    progressTimer = new Timer(100, new ActionListener() {
      public void actionPerformed(ActionEvent ee) {
        checkProgressMonitor();
      }
    });
  }
View Full Code Here

  public TransparentSplitter(JSplitPane splitPane) {
    this.splitPane = splitPane;
    addMouseListener(this);
    addMouseMotionListener(this);
    timer = new Timer(500, this);
    listeners = new ArrayList<ChangeListener>();
  }
View Full Code Here

{
  int fired;
  public void test(TestHarness harness)
  {
    fired = 0;
    Timer timer = new Timer(50, this);
    timer.setRepeats(false);
    timer.start();
    try
      {
        Thread.sleep(400);
      }
    catch (InterruptedException ex)
    {
    }
    harness.check(fired, 1, "Must be fired exactly once.");
    harness.check(timer.isRunning(), false, "Must not be terminated");
  }
View Full Code Here

    // ignore     
  }

  public void test(TestHarness harness)
  {
    Timer t = new Timer(100, this);
    t.setDelay(123);
    harness.check(t.getDelay(), 123);
    
    // try zero
    t.setDelay(0);
    harness.check(t.getDelay(), 0);
     
    // try negative
    boolean pass = false;
    try
    {
      t.setDelay(-1);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
View Full Code Here

  Timer object = new Timer(DELAY, null);

  /* Test the InitialDelay(). */
  public void test_InitialDelay(TestHarness harness)
  {
    Timer t = new Timer(DELAY, null);

    harness.check(t.getInitialDelay(), DELAY,
    "Initial delay must be be a default value from constructor, "+
     DELAY+", not "+object.getInitialDelay());

    t.setInitialDelay(1);
    harness.check(t.getInitialDelay(), 1,
     "Initial delay must be set to 1 by setInitialDelay(1)");

    t.setDelay(DELAY);
    harness.check(t.getInitialDelay(), 1, "If the initial delay is "+
    "explicitly set, setDelay() must not alter it.");
  }
View Full Code Here

  /* Test removeActionListener(java.awt.event.ActionListener). */
  public void test_add_removeActionListener(TestHarness harness)
  {
    harness.checkPoint("Adding/removing listeners");

    Timer t = new Timer(1, this);
    ActionListener other = new otherListener();
    t.addActionListener(other);

    harness.check(t.getActionListeners().length, 2, "must be 2 listeners");
    t.removeActionListener(this);

    harness.check(t.getActionListeners().length, 1, "must be 1 listener");

    t.removeActionListener(new otherListener());

    harness.check(t.getActionListeners().length, 1, "must still be 1 listener");

    t.removeActionListener(other);
    harness.check(t.getActionListeners().length, 0, "must be no listeners");
  }
View Full Code Here

  public void test(TestHarness harness)
  {
    main = Thread.currentThread();

    Timer t = new Timer(EXPECTED_DELAY, this);

    t.setCoalesce(false);

    t.setInitialDelay(EXPECTED_INITIAL_DELAY);
    t.setDelay(EXPECTED_DELAY);

    System.gc();

    history [ 0 ] = System.currentTimeMillis();

    t.start();

    try
      {
        Thread.sleep(5000);
      }
    catch (InterruptedException iex)
      {
      }

    t.stop();

    double S = 0;
    long d;
    StringBuffer series = new StringBuffer();
View Full Code Here

    // ignore     
  }

  public void test(TestHarness harness)
  {
    Timer t = new Timer(100, this);
    t.setInitialDelay(123);
    harness.check(t.getInitialDelay(), 123);
    
    // try zero
    t.setInitialDelay(0);
    harness.check(t.getInitialDelay(), 0);
     
    // try negative
    boolean pass = false;
    try
    {
      t.setInitialDelay(-1);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
View Full Code Here

TOP

Related Classes of javax.swing.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.