Java 类javax.swing.Timer 实例源码

项目:incubator-netbeans    文件:BalloonManager.java   
synchronized void startDismissTimer (int timeout) {
    stopDismissTimer();
    currentAlpha = 1.0f;
    dismissTimer = new Timer(DISMISS_REPAINT_REPEAT, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            currentAlpha -= ALPHA_DECREMENT;
            if( currentAlpha <= ALPHA_DECREMENT ) {
                stopDismissTimer();
                dismiss();
            }
            repaint();
        }
    });
    dismissTimer.setInitialDelay (timeout);
    dismissTimer.start();
}
项目:incubator-netbeans    文件:WeakTimerListener.java   
public void actionPerformed(ActionEvent evt) {
    ActionListener src = (ActionListener)ref.get();
    if (src != null) {
        src.actionPerformed(evt);

    } else { // source listener was garbage collected
        if (evt.getSource() instanceof Timer) {
            Timer timer = (Timer)evt.getSource();
            timer.removeActionListener(this);

            if (stopTimer) {
                timer.stop();
            }
        }
    }
}
项目:incubator-netbeans    文件:MemoryView.java   
/**
 * Initializes the Form
 */
public MemoryView() {
    initComponents();

    setTitle(bundle.getString("TXT_TITLE"));
    doGarbage.setText(bundle.getString("TXT_GARBAGE"));
    doRefresh.setText(bundle.getString("TXT_REFRESH"));
    doClose.setText(bundle.getString("TXT_CLOSE"));

    txtTime.setText(bundle.getString("TXT_TIME"));
    doTime.setText(bundle.getString("TXT_SET_TIME"));
    time.setText(String.valueOf(UPDATE_TIME));
    time.selectAll();
    time.requestFocus();

    updateStatus();

    timer = new Timer(UPDATE_TIME, new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            updateStatus();
        }
    });
    timer.setRepeats(true);

    pack();
}
项目:incubator-netbeans    文件:AnnotationBar.java   
void annotate(final List<Location> locations) {
    doc.render(new Runnable() {
        @Override
        public void run() {
            StyledDocument sd = (StyledDocument) doc;
            elementAnnotations = new HashMap<Integer, Location>();
            for (Location loc : locations) {
                int line = NbDocument.findLineNumber(sd, loc.startOffset);
                elementAnnotations.put(line, loc);
                //for multiline values like <parent> or <organization>
                int endline = NbDocument.findLineNumber(sd, loc.endOffset);
                if (endline != line && !elementAnnotations.containsKey(endline)) {
                    elementAnnotations.put(endline, loc);
                }
            }
        }
    });
    caret.addChangeListener(this);
    this.caretTimer = new Timer(500, this);
    caretTimer.setRepeats(false);

    onCurrentLine();
    revalidate();        
}
项目:incubator-netbeans    文件:SearchHistoryPanel.java   
/** Creates new form SearchHistoryPanel */
public SearchHistoryPanel(File [] roots, SearchCriteriaPanel criteria) {
    this.roots = roots;
    this.repositoryUrl = null;
    this.criteria = criteria;
    this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory();
    criteriaVisible = true;
    explorerManager = new ExplorerManager ();
    initComponents();
    initializeFilter();
    filterTimer = new Timer(500, this);
    filterTimer.setRepeats(false);
    filterTimer.stop();
    aquaBackgroundWorkaround();
    setupComponents();
    refreshComponents(true);
}
项目:incubator-netbeans    文件:TooltipHack.java   
/** Hack to invoke tooltip on given JComponent, with given dismiss delay.
 * Triggers <br>
 * <code>comp.getToolTipText(MouseEvent)</code> and 
 * <code>comp.getToolTipLocation(MouseEvent)</code> with fake mousemoved 
 * MouseEvent, set to given coordinates.
 */
public static void invokeTip (JComponent comp, int x, int y, int dismissDelay) {
    final ToolTipManager ttm = ToolTipManager.sharedInstance();
    final int prevInit = ttm.getInitialDelay();
    prevDismiss = ttm.getDismissDelay();
    ttm.setInitialDelay(0);
    ttm.setDismissDelay(dismissDelay);

    MouseEvent fakeEvt = new MouseEvent(
            comp, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 
            0, x, y, 0, false);
    ttm.mouseMoved(fakeEvt);

    ttm.setInitialDelay(prevInit);
    Timer timer = new Timer(20, instance());
    timer.setRepeats(false);
    timer.start();
}
项目:incubator-netbeans    文件:DragWindow.java   
private Timer createInitialEffect() {
    final Timer timer = new Timer(100, null);
    timer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if( contentAlpha < 1.0f ) {
                contentAlpha += ALPHA_INCREMENT;
            } else {
                timer.stop();
            }
            if( contentAlpha > 1.0f )
                contentAlpha = 1.0f;
            repaintImageBuffer();
            repaint();
        }
    });
    timer.setInitialDelay(0);
    return timer;
}
项目:incubator-netbeans    文件:DragWindow.java   
private Timer createNoDropEffect() {
    final Timer timer = new Timer(100, null);
    timer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if( contentAlpha > NO_DROP_ALPHA ) {
                contentAlpha -= ALPHA_INCREMENT;
            } else {
                timer.stop();
            }
            if( contentAlpha < NO_DROP_ALPHA )
                contentAlpha = NO_DROP_ALPHA;
            repaintImageBuffer();
            repaint();
        }
    });
    timer.setInitialDelay(0);
    return timer;
}
项目:java-course    文件:LJStatusBar.java   
/**
 * Initializes status bar GUI.
 */
private void initGUI() {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    length = new JLabel(lp.getString("length") + ": 0");
    line = new JLabel(lp.getString("line") + ": 1");
    column = new JLabel(lp.getString("column") + ": 0");
    selection = new JLabel(lp.getString("length") + ": 0");
    time = new JLabel();

    add(length);
    add(Box.createHorizontalGlue());

    add(line);
    add(Box.createRigidArea(new Dimension(5, 0)));
    add(column);
    add(Box.createRigidArea(new Dimension(5, 0)));
    add(selection);
    add(Box.createHorizontalGlue());
    add(time);

    timer = new Timer(500, timerListener);
    timer.start();
}
项目:incubator-netbeans    文件:GraphPanel.java   
private void disableSelection() {
    // Another disableSelection() in progress?
    if (timerRunning) return;
    timerRunning = true;

    // Tooltip is hidden when its location changes, let's wait for a while
    Timer timer = new Timer(50, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!isTooltipShowing()) {
                chart.getSelectionModel().
                           setHoverMode(ChartSelectionModel.HOVER_NONE);
                chart.setToolTipText(NO_DATA_TOOLTIP);
            }
            timerRunning = false;
        }
    });
    timer.setRepeats(false);
    timer.start();
}
项目:incubator-netbeans    文件:BalloonManager.java   
synchronized void startDismissTimer (int timeout) {
    stopDismissTimer();
    currentAlpha = 1.0f;
    dismissTimer = new Timer(DISMISS_REPAINT_REPEAT, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            currentAlpha -= ALPHA_DECREMENT;
            if( currentAlpha <= ALPHA_DECREMENT ) {
                stopDismissTimer();
                dismiss();
            }
            repaint();
        }
    });
    dismissTimer.setInitialDelay (timeout);
    dismissTimer.start();
}
项目:chipKIT-importer    文件:ImportWorker.java   
@Override
public Set<FileObject> doInBackground() {
    try {
        return invokeImporterTasks();
    } catch (Exception ex) {
        this.exception = ex;
        LOGGER.log( Level.SEVERE, "Failed to import project", ex );
        final File projectDir = (File) wizardDescriptor.getProperty(WizardProperty.PROJECT_DIR.key());
        // Delete the project directory after a short delay so that the import process releases all project files.
        Timer t = new Timer(2000, (a) -> {                
            try {
                deleteExistingProject(projectDir);
            } catch (IOException ex1) {
                LOGGER.log( Level.SEVERE, "Failed to delete an incompletely imported project", ex1 );
            }
        });
        t.setRepeats(false);
        t.start();
        return new HashSet<>();
    }
}
项目:incubator-netbeans    文件:BranchSelector.java   
public BranchSelector (File repository) {
    this.repository = repository;
    panel = new BranchSelectorPanel();
    panel.branchList.setCellRenderer(new RevisionRenderer());

    filterTimer = new Timer(300, new ActionListener() {
        @Override
        public void actionPerformed (ActionEvent e) {
            filterTimer.stop();
            applyFilter();
        }
    });
    panel.txtFilter.getDocument().addDocumentListener(this);
    panel.branchList.addListSelectionListener(this);
    panel.jPanel1.setVisible(false);
    cancelButton = new JButton();
    org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(BranchSelector.class, "CTL_BranchSelector_Action_Cancel")); // NOI18N
    cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BranchSelector.class, "ACSD_BranchSelector_Action_Cancel")); // NOI18N
    cancelButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BranchSelector.class, "ACSN_BranchSelector_Action_Cancel")); // NOI18N
}
项目:rapidminer    文件:SystemMonitor.java   
public void startMonitorThread() {
    new Timer(DELAY, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!SystemMonitor.this.isShowing()) {
                return;
            }
            // memory
            SystemMonitor.this.currentlyUsed = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
            SystemMonitor.this.memory[SystemMonitor.this.currentMeasurement] = (long) currentlyUsed;
            SystemMonitor.this.currentMeasurement = (SystemMonitor.this.currentMeasurement + 1)
                    % SystemMonitor.this.memory.length;
            SystemMonitor.this.repaint();
        }
    }).start();
}
项目:rapidminer    文件:SplashScreen.java   
public SplashScreen(Image productLogo, Properties properties) {
    this.properties = properties;
    this.productLogo = productLogo;
    this.productName = I18N.getGUIMessage("gui.splash.product_name");

    splashScreenFrame = new JFrame(properties.getProperty("name"));
    splashScreenFrame.getContentPane().add(this);
    SwingTools.setFrameIcon(splashScreenFrame);

    splashScreenFrame.setUndecorated(true);
    if (backgroundImage != null) {
        splashScreenFrame.setSize(backgroundImage.getWidth(this), backgroundImage.getHeight(this));
    } else {
        splashScreenFrame.setSize(550, 400);
    }
    splashScreenFrame.setLocationRelativeTo(null);

    animationTimer = new Timer(10, this);
    animationTimer.setRepeats(true);
    animationTimer.start();
}
项目:routerapp    文件:LineHighlightEffect.java   
/**
 * 
 */
public LineHighlightEffect(Shape shape, Graphics2D graphics,
        int length, ViselPane viselPane, boolean continuous) {
    this.shape = shape;
    this.length = length;
    this.graphics = graphics;
    this.viselPane = viselPane;
    this.continuous = continuous;

    timer = new Timer(length/10, this);
    duration = 0;
    stroke = (BasicStroke) graphics.getStroke();
    currentLineWidth =
        initialLineWidth = stroke.getLineWidth();

}
项目:marathonv5    文件:TumbleItem.java   
public void init() {
    loadAppletParameters();

    // Execute a job on the event-dispatching thread:
    // creating this applet's GUI.
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                createGUI();
            }
        });
    } catch (Exception e) {
        System.err.println("createGUI didn't successfully complete");
    }

    // Set up timer to drive animation events.
    timer = new Timer(speed, this);
    timer.setInitialDelay(pause);
    timer.start();

    // Start loading the images in the background.
    worker.execute();
}
项目:CRS    文件:ControllerPrincipal.java   
private void destacarCampo(JFormattedTextField field) {
  final int timerDelay = 500;
  final int totalTime = 2000;

  final int totalCount = totalTime / timerDelay;
  Timer timer = new Timer(timerDelay, new ActionListener(){
    int count = 0;

    public void actionPerformed(ActionEvent evt) {
      if (count % 2 == 0) {
        field.setBorder(new LineBorder(Color.RED, 2, true));
        field.requestFocus();
      } else {
            field.setBorder(new LineBorder(Color.GRAY, 1, false));
        if (count >= totalCount) { 
          ((Timer)evt.getSource()).stop();
        }
      }
      count++;
    }
  });
  timer.start();
}
项目:VASSAL-src    文件:BugDialog.java   
@Override
protected Void doInBackground() throws Exception {
  final CountDownLatch latch = new CountDownLatch(1);

  // Wait 3 seconds before counting down the latch to ensure
  // that the user has sufficient time to read the message on
  // the first pane.
  timer = new Timer(2000, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      latch.countDown();
    }
  });
  timer.start();

  // Make the request to the server and wait for the latch.
  BugUtils.sendBugReport(
    emailField.getText(),
    descriptionArea.getText(),
    errorLog,
    thrown
  );

  latch.await();
  return null;
}
项目:DecompiledMinecraft    文件:StatsComponent.java   
public StatsComponent(MinecraftServer p_i2367_1_)
{
    this.field_120037_e = p_i2367_1_;
    this.setPreferredSize(new Dimension(456, 246));
    this.setMinimumSize(new Dimension(456, 246));
    this.setMaximumSize(new Dimension(456, 246));
    (new Timer(500, new ActionListener()
    {
        public void actionPerformed(ActionEvent p_actionPerformed_1_)
        {
            StatsComponent.this.func_120034_a();
        }
    })).start();
    this.setBackground(Color.BLACK);
}
项目:FreeCol    文件:DeclarationPanel.java   
/**
 * Starts the animation of the signature.  An
 * {@code ActionEvent} gets sent to the registered
 * listeners when the animation has stopped.
 * 
 * @see #addActionListener(ActionListener)
 */
public void startAnimation() {
    ActionListener taskPerformer = (ActionEvent ae) -> {
        if (counter < points.length - 1) {
            counter += 20;
            if (counter > points.length) {
                counter = points.length - 1;
                ((Timer)ae.getSource()).stop();
                notifyStopped();
            }
            validate();
            repaint();
        } else {
            ((Timer)ae.getSource()).stop();
            notifyStopped();
        }
    };
    new Timer(ANIMATION_DELAY, taskPerformer).start();
}
项目:incubator-netbeans    文件:NotificationCenterTopComponent.java   
public NotificationCenterTopComponent() {
    notificationManager = NotificationCenterManager.getInstance();
    filterCallback = new QuickFilterCallback();
    tableRefreshTimer = new Timer(TABLE_REFRESH_PERIOD, new RefreshTimerListener());
    tableRefreshTimer.stop();
    tableKeyListener = new TableKeyListener();
    italicFont = new JLabel().getFont().deriveFont(Font.ITALIC);
    setName(NbBundle.getMessage(NotificationCenterTopComponent.class, "CTL_NotificationCenterTopComponent"));
    setToolTipText(NbBundle.getMessage(NotificationCenterTopComponent.class, "HINT_NotificationCenterTopComponent"));
}
项目:incubator-netbeans    文件:ProgressLabel.java   
private void setupProgress() {
    setIcon(createProgressIcon());
    t = new Timer(100, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Component comp = refComp.get();
            TreeListNode nd = refNode.get();
            if (nd == null && comp == null) {
                t.stop();
                Container p = getParent();
                if (p != null) {
                    p.remove(ProgressLabel.this);
                }
            } else {
                busyIcon.tick();
                ProgressLabel.this.repaint();
                if (nd != null) {
                    nd.fireContentChanged();
                } else {
                    comp.repaint();
                }
            }
        }
    });
    t.setRepeats(true);
    super.setVisible(false);
}
项目:incubator-netbeans    文件:ToolTipSupport.java   
/** Construct new support for tooltips.
     */
//    @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) //NOI18N
    @PatchedPublic
    /* package */ ToolTipSupport(EditorUI extEditorUI) {
        this.extEditorUI = extEditorUI;

        enterTimer = new Timer(INITIAL_DELAY, new WeakTimerListener(listener));
        enterTimer.setRepeats(false);
        exitTimer = new Timer(DISMISS_DELAY, new WeakTimerListener(listener));
        exitTimer.setRepeats(false);

        extEditorUI.addPropertyChangeListener(listener);

        setEnabled(true);
    }
项目:jdk8u-jdk    文件:AquaScrollBarUI.java   
public void actionPerformed(final ActionEvent e) {
    if (fUseBlockIncrement) {
        Hit newPart = getPartHit(fTrackListener.fCurrentMouseX, fTrackListener.fCurrentMouseY);

        if (newPart == ScrollBarHit.TRACK_MIN || newPart == ScrollBarHit.TRACK_MAX) {
            final int newDirection = (newPart == ScrollBarHit.TRACK_MAX ? 1 : -1);
            if (fDirection != newDirection) {
                fDirection = newDirection;
            }
        }

        scrollByBlock(fDirection);
        newPart = getPartHit(fTrackListener.fCurrentMouseX, fTrackListener.fCurrentMouseY);

        if (newPart == ScrollBarHit.THUMB) {
            ((Timer)e.getSource()).stop();
        }
    } else {
        scrollByUnit(fDirection);
    }

    if (fDirection > 0 && fScrollBar.getValue() + fScrollBar.getVisibleAmount() >= fScrollBar.getMaximum()) {
        ((Timer)e.getSource()).stop();
    } else if (fDirection < 0 && fScrollBar.getValue() <= fScrollBar.getMinimum()) {
        ((Timer)e.getSource()).stop();
    }
}
项目:komodoGUI    文件:WalletTabPanel.java   
public WalletTabPanel()
    throws IOException, InterruptedException, WalletCallException
{       
    super();

    this.timers = new ArrayList<Timer>();
    this.threads = new ArrayList<DataGatheringThread<?>>();
}
项目:openjdk-jdk10    文件:Test6559154.java   
public void run() {
    Timer timer = new Timer(1000, this);
    timer.setRepeats(false);
    timer.start();

    JColorChooser chooser = new JColorChooser();
    setEnabledRecursive(chooser, false);

    this.dialog = new JDialog();
    this.dialog.add(chooser);
    this.dialog.setVisible(true);
}
项目:OpenJSharp    文件:AquaScrollBarUI.java   
public void actionPerformed(final ActionEvent e) {
    if (fUseBlockIncrement) {
        Hit newPart = getPartHit(fTrackListener.fCurrentMouseX, fTrackListener.fCurrentMouseY);

        if (newPart == ScrollBarHit.TRACK_MIN || newPart == ScrollBarHit.TRACK_MAX) {
            final int newDirection = (newPart == ScrollBarHit.TRACK_MAX ? 1 : -1);
            if (fDirection != newDirection) {
                fDirection = newDirection;
            }
        }

        scrollByBlock(fDirection);
        newPart = getPartHit(fTrackListener.fCurrentMouseX, fTrackListener.fCurrentMouseY);

        if (newPart == ScrollBarHit.THUMB) {
            ((Timer)e.getSource()).stop();
        }
    } else {
        scrollByUnit(fDirection);
    }

    if (fDirection > 0 && fScrollBar.getValue() + fScrollBar.getVisibleAmount() >= fScrollBar.getMaximum()) {
        ((Timer)e.getSource()).stop();
    } else if (fDirection < 0 && fScrollBar.getValue() <= fScrollBar.getMinimum()) {
        ((Timer)e.getSource()).stop();
    }
}
项目:incubator-netbeans    文件:TTVTest.java   
private void cleanAndCheckTTV () {
    // make nodes and props gc'able
    replaceTTVContent();
    nodeStructure = null;
    props = null;
    // assure that weak hash map cache in TreeViewCell is busy a bit,
    // so that it really releases refs to its values
    repaintTimer = new Timer(1000, new ActionListener () {
        public void actionPerformed (ActionEvent evt) {
            if (repaintCount < 10) {
                ep.invalidate();
                ep.validate();
                ep.repaint();
                repaintCount++;
                // test if nodes were released correctly
                // invokeLater so that it comes really after explorer
                // panel repaint
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        System.gc();
                        repaintTimer.stop();
                        result = repaintCount;
                        // wake up testNodeReleasing method, so that it can finish properly
                        synchronized (TTVTest.this) {
                            TTVTest.this.notifyAll();
                        }
                    }
                });
            } else {
                repaintTimer.stop();
                result = -1;
                // wake up testNodeReleasing method, so that it can finish properly
                synchronized (TTVTest.this) {
                    TTVTest.this.notifyAll();
                }
            }
        }
    });
    repaintTimer.start();
}
项目:incubator-netbeans    文件:TabControlButtonFactory.java   
private void startTimer() {
    Timer t = getTimer();
    if (t.isRunning()) {
        return;
    }
    repaint();
    t.setDelay(400);
    t.start();
}
项目:SER316-Munich    文件:DigitalClock1.java   
public ClockLabel(String type) {
  this.type = type;
  setForeground(Color.red);

  if(type.equals("date"))
  {
    sdf = new SimpleDateFormat("  MMMM dd yyyy");
      setFont(new Font("PHOSPHATE", Font.PLAIN, 18));
      setHorizontalAlignment(SwingConstants.LEFT);
  }
  else if(type.equals("time"))
  {
    sdf = new SimpleDateFormat("hh:mm:ss a");
      setFont(new Font("PHOSPHATE", Font.PLAIN, 40));
      setHorizontalAlignment(SwingConstants.CENTER);
  }
  else if(type.equals("day"))
  {
    sdf = new SimpleDateFormat("EEEE  ");
      setFont(new Font("PHOSPHATE", Font.PLAIN, 18));
      setHorizontalAlignment(SwingConstants.RIGHT);
  }
  else
  {
    sdf = new SimpleDateFormat();
  }

  Timer t = new Timer(1000, this);
  t.start();
}
项目:incubator-netbeans    文件:SearchHistoryPanel.java   
public SearchHistoryPanel(SVNUrl repositoryUrl, File localRoot, SearchCriteriaPanel criteria) {
    this.repositoryUrl = repositoryUrl;
    this.roots = new File[] { localRoot };
    this.criteria = criteria;
    this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory();
    criteriaVisible = true;
    explorerManager = new ExplorerManager ();
    initComponents();
    initializeFilter();
    filterTimer = new Timer(500, this);
    filterTimer.stop();
    aquaBackgroundWorkaround();
    setupComponents();
    refreshComponents(true);
}
项目:java-swing-template    文件:Dashboard.java   
/**
 * Creates new form Dashboard
 */
public Dashboard() {
    initComponents();
    Dashboard.this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    initButtons();
    initBackground();
    Utilities.setWindowIcon(Dashboard.this);

    Timer t = new Timer(3000, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (new File("updater.exe").exists()) {
                Thread th = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        Utilities.runShellCommand(Updator.COMMAND_UPDATECHECK);
                    }
                });
                th.start();
            } else {
                JOptionPane.showMessageDialog(Dashboard.this, "Your software version is not equipped with the automatic update funcationality.\nPlease install the latest software to get updater facility.\nThank you.", "Outdated software", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    t.setRepeats(false);
    t.start();
}
项目:incubator-netbeans    文件:GuiRunLevel.java   
/** Method to initialize the main window.
*/
private void initializeMainWindow() {
    StartLog.logStart ("Main window initialization"); //NOI18N

    TimableEventQueue.initialize();

    // -----------------------------------------------------------------------------------------------------
    // 11. Initialization of main window
    StatusDisplayer.getDefault().setStatusText (NbBundle.getMessage (GuiRunLevel.class, "MSG_MainWindowInit"));

    // force to initialize timer
    // sometimes happened that the timer thread was initialized under
    // a TaskThreadGroup
    // such task never ends or, if killed, timer is over
    Timer timerInit = new Timer(0, new java.awt.event.ActionListener() {
          public @Override void actionPerformed(java.awt.event.ActionEvent ev) { }
    });
    timerInit.setRepeats(false);
    timerInit.start();
    Splash.getInstance().increment(10);
    StartLog.logProgress ("Timer initialized"); // NOI18N

// -----------------------------------------------------------------------------------------------------
// 14. Open main window
    StatusDisplayer.getDefault().setStatusText (NbBundle.getMessage (GuiRunLevel.class, "MSG_WindowShowInit"));

    // Starts GUI components to be created and shown on screen.
    // I.e. main window + current workspace components.



    // Access winsys from AWT thread only. In this case main thread wouldn't harm, just to be kosher.
    final WindowSystem windowSystem = Lookup.getDefault().lookup(WindowSystem.class);
    if (windowSystem != null) {
        windowSystem.init();
    }
    SwingUtilities.invokeLater(new InitWinSys(windowSystem));
    StartLog.logEnd ("Main window initialization"); //NOI18N
}
项目:freecol    文件:DeclarationPanel.java   
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(ActionEvent ae) {
    final String command = ae.getActionCommand();
    if (ANIMATION_STOPPED.equals(command)) {
        Timer t = new Timer(FINISH_DELAY, (x) -> {
                getGUI().removeFromCanvas(DeclarationPanel.this);
            });
        t.setRepeats(false);
        t.start();
    } else {
        super.actionPerformed(ae);
    }
}
项目:Star-Ride--RiverRaid    文件:Shoot.java   
/**
 * Metodo encargado de generar el disparo proveniente del player
 */
public void Disparar(){
    timerDisparo = new Timer(10, new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent e) {

               shoot.setLocation(shoot.getX(), shoot.getY()-4);
               detenerDisparo();           
        }
    });  
    timerDisparo.start();         
}
项目:FreeCol    文件:DeclarationPanel.java   
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(ActionEvent ae) {
    final String command = ae.getActionCommand();
    if (ANIMATION_STOPPED.equals(command)) {
        Timer t = new Timer(FINISH_DELAY, (x) -> {
                getGUI().removeFromCanvas(DeclarationPanel.this);
            });
        t.setRepeats(false);
        t.start();
    } else {
        super.actionPerformed(ae);
    }
}
项目:AWGW    文件:GridPanel.java   
/**
 * Show a tool tip.
 *
 * @param tipText the tool tip text
 * @param pt      the pixel position over which to show the tip
 */
public void showTip(String tipText, Point pt) {
    if (getRootPane() == null)
        return;
    // draw in glass pane to appear on top of other components
    if (glassPane == null) {
        getRootPane().setGlassPane(glassPane = new JPanel());
        glassPane.setOpaque(false);
        glassPane.setLayout(null); // will control layout manually
        glassPane.add(tip = new JToolTip());
        tipTimer = new Timer(TIP_DELAY, new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                glassPane.setVisible(false);
            }
        });
        tipTimer.setRepeats(false);
    }
    if (tipText == null)
        return;

    // set tip text to identify current origin of pannable view
    tip.setTipText(tipText);

    // position tip to appear at upper left corner of viewport
    tip.setLocation(SwingUtilities.convertPoint(this, pt, glassPane));
    tip.setSize(tip.getPreferredSize());

    // show glass pane (it contains tip)
    glassPane.setVisible(true);
    glassPane.repaint();

    // this timer will hide the glass pane after a short delay
    tipTimer.restart();
}
项目:incubator-netbeans    文件:LineFilter.java   
public LineProcessorBridge(LineFilter lineProcessor, int delay) {
    super();

    if (delay == 0)
        this.timer = null;
    else {
        this.timer = new Timer(delay, this);
        timer.setRepeats(false);
    }
    this.lineProcessor = lineProcessor;
}
项目:scorekeeperfrontend    文件:MyIpLabel.java   
public MyIpLabel()
{
    super("");
    setHorizontalAlignment(CENTER);
    actionPerformed(null);
    new Timer(3000, this).start();
}