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

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

源代码1 项目: RipplePower   文件: SwingUtils.java
public static void fadeIn(final Dialog win) {
	if (!win.isUndecorated()) {
		return;
	}
	final Timer timer = new Timer(30, null);
	timer.setRepeats(true);
	timer.addActionListener(new ActionListener() {
		private float opacity = 0;

		@Override
		public void actionPerformed(ActionEvent e) {
			opacity += 0.05f;
			win.setOpacity(Math.min(opacity, 1f));
			if (opacity >= 1) {
				timer.stop();
			}
		}
	});
	win.setOpacity(0);
	timer.start();
	win.setVisible(true);
}
 
源代码2 项目: osp   文件: DataToolTab.java
/**
 * Initializes this panel.
 */
private void init() {
  if(isInitialized) {
    return;
  }

  splitPanes[1].setDividerLocation(1.0);
  propsAndStatsAction.actionPerformed(null);
// kludge: do propsAndStatsAction again after a few milliseconds!
  Timer timer = new Timer(5, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      propsAndStatsAction.actionPerformed(null);
    }
  });
timer.setRepeats(false);
timer.start();
  for(int i = 0; i<dataTable.getColumnCount(); i++) {
    String colName = dataTable.getColumnName(i);
    dataTable.getWorkingData(colName);
  }
  refreshPlot();
  refreshGUI();
  isInitialized = true;
}
 
源代码3 项目: 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();
}
 
源代码4 项目: RemoteSupportTool   文件: StaffApplication.java
@Override
public void start() {
    monitoringTimer = new Timer(1000, e -> {
        if (uploadMonitor == null || downloadMonitor == null)
            return;
        try {
            frame.setRates(downloadMonitor.getAverageRate(), uploadMonitor.getAverageRate());

            Date minAge = new Date(System.currentTimeMillis() - 2000);
            downloadMonitor.removeOldSamples(minAge);
            uploadMonitor.removeOldSamples(minAge);
        } catch (Exception ex) {
            LOGGER.warn("Can't upload monitoring!", ex);
        }
    });
    monitoringTimer.setRepeats(true);
    monitoringTimer.start();

    super.start();
}
 
源代码5 项目: RipplePower   文件: RPToast.java
public void fadeOut() {
	final Timer timer = new Timer(FADE_REFRESH_RATE, null);
	timer.setRepeats(true);
	timer.addActionListener(new ActionListener() {
		private float opacity = MAX_OPACITY;

		@Override
		public void actionPerformed(ActionEvent e) {
			opacity -= OPACITY_INCREMENT;
			setOpacity(Math.max(opacity, 0));
			if (opacity <= 0) {
				timer.stop();
				setVisible(false);
				dispose();
			}
		}
	});
	setOpacity(MAX_OPACITY);
	timer.start();
}
 
源代码6 项目: amidst   文件: WorldGenerationBencher.java
private void launchMainWindow(Application app, RunningLauncherProfile profile) {
	MainWindow window = app.displayMainWindow(profile);
	window.getWorldSwitcher().displayWorld(WORLD_OPTIONS);

	for(int i = 0; i < 10; i++) {
		window.getViewerFacade().adjustZoom(1);
	}
	window.getViewerFacade().centerOn(CoordinatesInWorld.origin());

	Timer timer = new Timer(1000, e -> {});
	timer.setRepeats(true);
	timer.setInitialDelay(1000);
	timer.addActionListener(e -> {
		if(window.getViewerFacade().isFullyLoaded()) {
			timer.stop();
			fullyLoadedBarrier.release();
		}
	});
	timer.start();
}
 
源代码7 项目: jdk8u-dev-jdk   文件: 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);
}
 
源代码8 项目: openjdk-jdk9   文件: 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);
}
 
源代码9 项目: RipplePower   文件: AnimationIcon.java
public AnimationIcon(Icon icon, final JComponent component, final boolean repeat) {

		delegateIcon = icon;

		width = delegateIcon.getIconWidth();
		height = delegateIcon.getIconHeight();

		timer = new Timer(100, new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				incrementRotation(component);
			}
		});

		LSystem.invokeLater(new Runnable() {

			@Override
			public void run() {
				component.repaint();
			}
		});

		timer.setRepeats(repeat);
		timer.start();

	}
 
源代码10 项目: chipster   文件: ServerAdminAPI.java
public void query() throws JMSException, InterruptedException {

			mutex.lock();
			try {				
				statuses = new ArrayList<ServerStatusMessage>();
				
				CommandMessage request = new CommandMessage(CommandMessage.COMMAND_GET_COMP_STATUS);
				getTopic().sendReplyableMessage(request, this);
				
			} finally {
				mutex.unlock();
			}
			
			// clean up the topic simply after a fixed delay, because
			// we don't know when all the serves have replied
			Timer cleanUpTimer = new Timer(cleanUpDelay * 1000, new ActionListener() {				
				@Override
				public void actionPerformed(ActionEvent e) {
					mutex.lock();
					try {
						cleanUp();
					} finally {
						mutex.unlock();
					}		
				}
			});				
			cleanUpTimer.setRepeats(false);
			cleanUpTimer.start();
		}
 
源代码11 项目: minicraft-plus-revived   文件: LoadingDisplay.java
public LoadingDisplay() {
	super(true, false);
	t = new Timer(500, e -> {
		World.initWorld();
		Game.setMenu(null);
	});
	t.setRepeats(false);
}
 
@SuppressWarnings("LeakingThisInConstructor")
private DelayedDocumentChangeListener(Document doc, final ChangeListener l, int delay) {
    this.doc = doc;
    this.doc.addDocumentListener(this);
    this.chEvt = new ChangeEvent(doc);
    changeTimer = new Timer(delay, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            l.stateChanged(chEvt);
        }
    });
    changeTimer.setRepeats(false);
}
 
源代码13 项目: tn5250j   文件: SessionBean.java
private void doVisibility()
{
  if (!isVisible() && (visibilityInterval > 0))
  {
    Timer t = new Timer(visibilityInterval, new DoVisible());
    t.setRepeats(false);
    t.start();
  }
  else if (!isVisible())
  {
    new DoVisible().run();
  }
}
 
源代码14 项目: jclic   文件: Player.java
/**
 * Creates and initializes the members {@link timer}, {@link delayedTimer} and
 * {@link delayedAction}
 */
protected void initTimers() {
  timer = new Timer(1000, this);
  delayedTimer = new Timer(1000, this);
  delayedTimer.setRepeats(false);
  delayedAction = null;
}
 
源代码15 项目: niftyeditor   文件: GuiSelectionListener.java
@Override
public void mousePressed(MouseEvent e) {
     if(enable){
       e.getComponent().requestFocusInWindow();
       toServe = e;
       hold = new Timer(225, this);
       hold.setRepeats(false);
       hold.start();
     }
     if(e.isPopupTrigger()){
          this.p.show(e.getComponent(), e.getX(), e.getY());
     }
     
 }
 
源代码16 项目: netbeans   文件: SelectUriStep.java
public SelectUriStep (File repositoryFile, Map<String, GitRemoteConfig> remotes, Mode mode) {
    this.repositoryFile = repositoryFile;
    this.repository = new RemoteRepository(null);
    this.panel = new SelectUriPanel(repository.getPanel());
    this.remotes = remotes;
    this.inputFields = new JComponent[] {
        panel.cmbConfiguredRepositories,
        panel.rbConfiguredUri,
        panel.rbCreateNew,
        panel.lblRemoteNames,
        panel.cbPersistRemote,
        panel.cmbRemoteNames
    };
    this.mode = mode;
    remoteNameEditTimer = new Timer(300, this);
    remoteNameEditTimer.setRepeats(false);
    remoteNameEditTimer.stop();
    fillPanel();
    attachListeners();
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run () {
            enableFields();
            validateBeforeNext();
        }
    });
}
 
源代码17 项目: osp   文件: DataToolTab.java
/**
 * Sets the font level.
 *
 * @param level the level
 */
protected void setFontLevel(int level) {
  FontSizer.setFonts(this, level);
  plot.setFontLevel(level);
  
  FontSizer.setFonts(statsTable, level);
  FontSizer.setFonts(propsTable, level);
  
  curveFitter.setFontLevel(level);
  
  double factor = FontSizer.getFactor(level);
  plot.getAxes().resizeFonts(factor, plot);
  FontSizer.setFonts(plot.getPopupMenu(), level);
  if(propsTable.styleDialog!=null) {
    FontSizer.setFonts(propsTable.styleDialog, level);
    propsTable.styleDialog.pack();
  }
  if(dataBuilder!=null) {
    dataBuilder.setFontLevel(level);
  }
  fitterAction.actionPerformed(null);
  propsTable.refreshTable();
  
  // set shift field and label fonts in case they are not currently displayed
  FontSizer.setFonts(shiftXLabel, level);
  FontSizer.setFonts(shiftYLabel, level);
  FontSizer.setFonts(selectedXLabel, level);
  FontSizer.setFonts(selectedYLabel, level);
  FontSizer.setFonts(shiftXField, level);
  FontSizer.setFonts(shiftYField, level);
  FontSizer.setFonts(selectedXField, level);
  FontSizer.setFonts(selectedYField, level);
  shiftXField.refreshPreferredWidth();
  shiftYField.refreshPreferredWidth();
  selectedXField.refreshPreferredWidth();
  selectedYField.refreshPreferredWidth();
  toolbar.revalidate();

refreshStatusBar(null);
// kludge to display tables correctly: do propsAndStatsAction now and again after a millisecond!
  propsAndStatsAction.actionPerformed(null);
  Timer timer = new Timer(1, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      propsAndStatsAction.actionPerformed(null);
    }
  });
timer.setRepeats(false);
timer.start();
}
 
源代码18 项目: netbeans   文件: SlideGestureRecognizer.java
AutoSlideTrigger() {
    super();
    slideInTimer = new Timer(200, this);
    slideInTimer.setRepeats(true);
    slideInTimer.setCoalesce(true);
}
 
public AbstractPatchedTransferHandler() {
	hideTimer = new Timer(HIDE_DELAY, new hidePopupAction());
	hideTimer.setRepeats(false);
	showTimer = new Timer(SHOW_DELAY, new showPopupAction());
	showTimer.setRepeats(false);
}
 
源代码20 项目: radiance   文件: SwingBugUtilities.java
/** 
 * Runs the supplied class after a certain period of time, the thread
 * will be executed in the EDT. 
 *
 * @param execute The runnable object whose method will be called after the
 * specified delay
 * @param after The delay in ms before the event will be called
 */
public static void invokeAfter(final Runnable execute, int after){
    Timer timer = new Timer(after, (ActionEvent actionEvent) -> execute.run());
    timer.setRepeats(false);
    timer.start();
}