javax.swing.Timer#stop ( )源码实例Demo

下面列出了javax.swing.Timer#stop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: visualvm   文件: DataSourceCaption.java
private void createTimer() {
    final Icon[] busyIcons = new Icon[15];

    for (int i = 0; i < busyIcons.length; i++) busyIcons[i] = new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/busy-icon" + i + ".png"));    // NOI18N
    busyIconTimer = new Timer(ANIMATION_RATE, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!ANIMATE) {
                if (busyIconTimer != null) busyIconTimer.stop(); // Stop animation
                presenter1.setIcon(new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/busy-icon4.png")));   // NOI18N
            } else {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                if (!DataSourceCaption.this.isShowing()) return;
                presenter1.setIcon(busyIcons[busyIconIndex]);
            }
        }
    });
}
 
源代码2 项目: 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();
            }
        }
    }
}
 
源代码3 项目: netbeans   文件: SearchHistoryPanel.java
/** Creates new form SearchHistoryPanel */
public SearchHistoryPanel(File repository, RepositoryInfo info, File [] roots, SearchCriteriaPanel criteria) {
    this.roots = roots;
    this.repository = repository;
    this.info = info;
    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();
    setupComponents();
    info.addPropertyChangeListener(list = WeakListeners.propertyChange(this, info));
    aquaBackgroundWorkaround();
    refreshComponents(true);
}
 
源代码4 项目: netbeans   文件: SearchHistoryPanel.java
/** Creates new form SearchHistoryPanel */
public SearchHistoryPanel(File [] roots, SearchCriteriaPanel criteria) {
    this.bOutSearch = false;
    this.bIncomingSearch = false;
    this.roots = roots;
    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();
    setupComponents();
    aquaBackgroundWorkaround();
    refreshComponents(true);
}
 
源代码5 项目: WorldPainter   文件: ThreeDeeView.java
@Override
    public void hierarchyChanged(HierarchyEvent event) {
        if ((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
            if (isDisplayable()) {
//                for (Tile tile: dimension.getTiles()) {
//                    threeDeeRenderManager.renderTile(tile);
//                }
                timer = new Timer(250, this);
                timer.start();
            } else {
                timer.stop();
                timer = null;
                threeDeeRenderManager.stop();
                for (Tile tile : dimension.getTiles()) {
                    tile.removeListener(this);
                }
                dimension.removeDimensionListener(this);
            }
        }
    }
 
源代码6 项目: pumpernickel   文件: AnimatedLayout.java
public void actionPerformed(ActionEvent e) {
	Timer timer = (Timer) e.getSource();

	boolean workToDo = false;

	synchronized (container.getTreeLock()) {
		Map<JComponent, Rectangle> destinationMap = getDestinationMap(container);
		for (Entry<JComponent, Rectangle> entry : destinationMap
				.entrySet()) {
			if (nudge(entry.getKey(), entry.getValue()) == false) {
				workToDo = true;
			}
		}
	}
	// on Windows, Ladislav pointed out there's a repaint problem
	container.repaint();

	if (workToDo == false)
		timer.stop();
}
 
源代码7 项目: CQL   文件: ProgressMonitorWrapper.java
public ProgressMonitorWrapper(String msg, Runnable task) {
	pbar = new ProgressMonitor(null, msg, "Elapsed: 0 secs", 0, 4);
	start_time = System.currentTimeMillis();
	timer = new Timer(500, this);
	timer.start();

	thread = new Thread(() -> {
		task.run();
		timer.stop();
		pbar.close();
	});
	thread.start();
}
 
源代码8 项目: MogwaiERDesignerNG   文件: FadeInFadeOutHelper.java
public FadeInFadeOutHelper() {
    componentToHighlightTimer = new Timer(50, e -> {

        if (componentToHighlightFadeOut) {
            if (componentToHighlightPosition > 0) {
                componentToHighlightPosition -= 40;
            } else {
                componentToHighlightFadeOut = false;
                componentToHighlight = componentToHighlightNext;
            }
        } else {
            if (componentToHighlightNext != null) {
                componentToHighlight = componentToHighlightNext;
                componentToHighlightNext = null;
            }
            if (componentToHighlight != null) {
                Dimension theSize = componentToHighlight.getSize();
                if (componentToHighlightPosition < theSize.width + 10) {
                    int theStep = theSize.width + 10 - componentToHighlightPosition;
                    if (theStep > 40) {
                        theStep = 40;
                    }
                    componentToHighlightPosition += theStep;
                } else {
                    componentToHighlightTimer.stop();
                }
            } else {
                componentToHighlightTimer.stop();
            }
        }

        doRepaint();
    });
    componentToHighlightWaitTimer = new Timer(1000, e -> componentToHighlightTimer.start());
    componentToHighlightWaitTimer.setRepeats(false);
}
 
源代码9 项目: Spark   文件: ShakeWindow.java
/**
    * punishes the User by moving the Chatwindow around for 10 seconds
    */
   public void startRandomMovement(final int seconds)
   {
if(window instanceof JFrame){
           JFrame f = (JFrame)window;
           f.setState(Frame.NORMAL);
           f.setVisible(true);
       }
       SparkManager.getNativeManager().flashWindow(window);
       
       final long startTime = System.currentTimeMillis()/1000L;
       
moveTimer = new Timer(5, e -> {
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

   double x = Math.random()*10000 % d.getWidth();
   double y = Math.random()*10000 % d.getHeight();
   int xx = Math.round(Math.round(x));
   int yy = Math.round(Math.round(y));
   window.setLocation(xx,yy);
   window.repaint();

   long now = System.currentTimeMillis()/1000L;
   long diff = now-startTime;
   System.out.println(diff);
   if(diff > seconds)
   {
       moveTimer.stop();
   }

       } );

moveTimer.start();

   }
 
源代码10 项目: ghidra   文件: AnimatedIcon.java
public AnimatedIcon(List<? extends Icon> icons, int frameDelay, int framesToSkip) {
	this.iconList = icons;
	this.skipFrames = framesToSkip;
	timer = new Timer(frameDelay, new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			if (--paintCounter <= 0) {
				timer.stop();
				return;
			}

			if (skipFrameCount > 0) {
				skipFrameCount--;
				return;
			}
			if (++currentIconIndex >= iconList.size()) {
				currentIconIndex = 0;
				skipFrameCount = skipFrames;
			}
			if (component != null) {
				component.repaint();
			}
		}
	});

	for (Icon icon : iconList) {
		width = Math.max(width, icon.getIconWidth());
		height = Math.max(height, icon.getIconHeight());
	}
}
 
源代码11 项目: visualvm   文件: XPlottingViewer.java
@Override
public void actionPerformed(ActionEvent evt) {
    plotterCache.remove(key);
    Timer t = timerCache.remove(key);
    t.stop();
    ((XMBeanAttributes) table).collapse(attributeName, this);
}
 
源代码12 项目: 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);
}
 
源代码13 项目: AndrOBD   文件: KLHandlerGeneric.java
/**
 * Default constructor
 */
public KLHandlerGeneric()
{
	// set the logger object
	log = Logger.getLogger("com.fr3ts0n.prot.kl");

	commTimer = new Timer(commTimeoutTime, commTimeoutHandler);
	commTimer.setInitialDelay(commTimeoutTime);
	commTimer.stop();
}
 
源代码14 项目: mapper   文件: AwtEventDispatchThread.java
private Registration timerReg(final Timer timer) {
  return new Registration() {
    @Override
    protected void doRemove() {
      if (timer.isRunning()) {
        timer.stop();
      }
    }
  };
}
 
源代码15 项目: AndrOBD   文件: KLHandlerGeneric.java
/**
 * construct with connecting to device
 *
 * @param device device to connect
 */
private KLHandlerGeneric(String device)
{
	try
	{
		setDeviceName(device);
	} catch (Exception ex)
	{
		log.log(Level.SEVERE,"", ex);
	}
	commTimer = new Timer(commTimeoutTime, commTimeoutHandler);
	commTimer.setInitialDelay(commTimeoutTime);
	commTimer.stop();
}
 
源代码16 项目: netbeans   文件: ShelveChangesSupport.java
private PatchNameListener (ShelveChangesPanel panel, JButton okButton, Dialog dialog) {
    this.panel = panel;
    this.button = okButton;
    this.dialog = dialog;
    timer = new Timer(300, this);
    timer.stop();
}
 
源代码17 项目: magarena   文件: CardDecksPanel.java
public CardDecksPanel() {

        decksJList.setOpaque(false);
        decksJList.setBackground(new Color(0, 0, 0, 1));
        decksJList.setForeground(Color.BLACK);
        decksJList.setFocusable(true);
        decksJList.setCellRenderer(new CardDecksListCellRenderer());
        decksJList.setFont(FontsAndBorders.FONT1);

        // scroll pane for deck names list
        scroller.setViewportView(decksJList);
        scroller.setBorder(null);
        scroller.setOpaque(false);
        scroller.getViewport().setOpaque(false);
        scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        decksJList.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent evt) {
                if (isDoubleClick(evt)) {
                    showSelectedDeck(decksJList.locationToIndex(evt.getPoint()));
                }
            }
        });

        miglayout.setLayoutConstraints("insets 0, flowy");
        setLayout(miglayout);

        // these constraints fix decksButton in CardPanel not resizing correctly
        // when full screen and decksbutton is clicked to re-show image. Ensure you
        // test if these constraints are updated especially if you add an 'h' constraint.
        add(scroller, "w 100%, growy, pushy");

        cooldownTimer = new Timer(TIMER_DELAY_MSECS, e -> {
            cooldownTimer.stop();
            showDecksContainingCard(CardDecksPanel.this.card);
        });

    }
 
源代码18 项目: netbeans   文件: TagManager.java
TagManager (File repository) {
    this.repository = repository;
    this.panel = new TagManagerPanel();
    panel.tagList.setCellRenderer(new TagRenderer());
    filterTimer = new Timer(300, new ActionListener() {
        @Override
        public void actionPerformed (ActionEvent e) {
            filterTimer.stop();
            applyFilter();
        }
    });
    attachListeners();
}
 
源代码19 项目: MtgDesktopCompanion   文件: CardsPicPanel.java
private void initGUI() {
	renderer = new ReflectionRenderer();
	setBackgroundPainter(new MattePainter(PaintUtils.NIGHT_GRAY, true));

	GestionnaireEvenements interactionManager = new GestionnaireEvenements(this);
	this.addMouseListener(interactionManager);
	this.addMouseMotionListener(interactionManager);
	this.addMouseWheelListener(interactionManager);

	timer = new Timer(30, e -> {
		repaint();

		xScale += xDelta;

		if (xScale > 1 || xScale < -1) {
			xDelta *= -1;

		}

		if (loop > 0 && ((int) xScale == 1 || (int) xScale == -1)) {
			timer.stop();
			launched = false;

		}
		loop++;
	});
}
 
源代码20 项目: myqq   文件: PublicMessageFrame.java
/**
 * 显示窗体
 */
public void showFrame()
{
	this.setAlwaysOnTop(true);
	if(chat==null)
		btn打开.setVisible(false);
	int width=350;
	int height=266;
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	setBounds(screenSize.width-width-3,screenSize.height,width,height);
	setVisible(true);
	Timer timer=new Timer(10, new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			setLocation(getLocation().x, getLocation().y-10);
		}
	});
	timer.start();
	while(true)
	{
		// 25表示任务栏的高度,好奇怪,有的电脑注释掉下面的输出语句就会出现弹窗不停止的奇怪现象
		System.out.println("当前高度:"+getLocation().y+",屏幕高度:"+screenSize.height);
		if(getLocation().y+height<screenSize.height-25)
		{
			timer.stop();
			break;
		}
	}
}