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

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

源代码1 项目: ghidra   文件: CursorBlinker.java
public CursorBlinker(FieldPanel panel) {
	this.fieldPanel = panel;

	timer = new Timer(500, new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			if (paintBounds != null) {
				showCursor = !showCursor;
				fieldPanel.paintImmediately(paintBounds);
			}
			else {
				timer.stop();
			}
		}
	});

	// the initial painting is laggy for some reason, so shorten the delay
	timer.setInitialDelay(100);
	timer.start();

}
 
源代码2 项目: ghidra   文件: DialogComponentProvider.java
protected void showProgressBar(String localTitle, boolean hasProgress, boolean canCancel,
		int delay) {
	taskMonitorComponent.reset();
	Runnable r = () -> {
		if (delay <= 0) {
			showProgressBar(localTitle, hasProgress, canCancel);
		}
		else {
			showTimer = new Timer(delay, ev -> {
				if (taskScheduler.isBusy()) {
					showProgressBar(localTitle, hasProgress, canCancel);
					showTimer = null;
				}
			});
			showTimer.setInitialDelay(delay);
			showTimer.setRepeats(false);
			showTimer.start();
		}
	};

	SystemUtilities.runSwingNow(r);
}
 
源代码3 项目: 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();
}
 
源代码4 项目: 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();
}
 
源代码5 项目: netbeans   文件: TextEditorSupport.java
/**
 * Initialize timers and handle their ticks.
 */
private void initTimer() {
    timer = new Timer(0, new java.awt.event.ActionListener() {
        // we are called from the AWT thread so put itno other one
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("$$ TextEditorSupport::initTimer::actionPerformed: event = " + e);

            RequestProcessor.postRequest( new Runnable() {
                public void run() {
                    syncDocument(false);
                }
            });
        }
    });

    timer.setInitialDelay(getAutoParsingDelay());
    timer.setRepeats(false);
}
 
源代码6 项目: dragonwell8_jdk   文件: AquaScrollBarUI.java
protected void installListeners() {
    fTrackListener = createTrackListener();
    fModelListener = createModelListener();
    fPropertyChangeListener = createPropertyChangeListener();
    fScrollBar.addMouseListener(fTrackListener);
    fScrollBar.addMouseMotionListener(fTrackListener);
    fScrollBar.getModel().addChangeListener(fModelListener);
    fScrollBar.addPropertyChangeListener(fPropertyChangeListener);
    fScrollListener = createScrollListener();
    fScrollTimer = new Timer(kNormalDelay, fScrollListener);
    fScrollTimer.setInitialDelay(kInitialDelay); // default InitialDelay?
}
 
源代码7 项目: TencentKona-8   文件: AquaScrollBarUI.java
protected void installListeners() {
    fTrackListener = createTrackListener();
    fModelListener = createModelListener();
    fPropertyChangeListener = createPropertyChangeListener();
    fScrollBar.addMouseListener(fTrackListener);
    fScrollBar.addMouseMotionListener(fTrackListener);
    fScrollBar.getModel().addChangeListener(fModelListener);
    fScrollBar.addPropertyChangeListener(fPropertyChangeListener);
    fScrollListener = createScrollListener();
    fScrollTimer = new Timer(kNormalDelay, fScrollListener);
    fScrollTimer.setInitialDelay(kInitialDelay); // default InitialDelay?
}
 
源代码8 项目: openjdk-8-source   文件: AquaScrollBarUI.java
protected void installListeners() {
    fTrackListener = createTrackListener();
    fModelListener = createModelListener();
    fPropertyChangeListener = createPropertyChangeListener();
    fScrollBar.addMouseListener(fTrackListener);
    fScrollBar.addMouseMotionListener(fTrackListener);
    fScrollBar.getModel().addChangeListener(fModelListener);
    fScrollBar.addPropertyChangeListener(fPropertyChangeListener);
    fScrollListener = createScrollListener();
    fScrollTimer = new Timer(kNormalDelay, fScrollListener);
    fScrollTimer.setInitialDelay(kInitialDelay); // default InitialDelay?
}
 
源代码9 项目: filthy-rich-clients   文件: AnimatedGraphics.java
/**
 * Set up and start the timer
 */
public AnimatedGraphics() {
    Timer timer = new Timer(30, this);
    // initial delay while window gets set up
    timer.setInitialDelay(1000);
    animStartTime = 1000 + System.nanoTime() / 1000000;
    timer.start();
}
 
源代码10 项目: 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();
}
 
源代码11 项目: azure-devops-intellij   文件: ImportForm.java
private void createUIComponents() {
    userAccountPanel = new UserAccountPanel();
    refreshButton = new JButton(AllIcons.Actions.Refresh);

    // Create timer for filtering the list
    timer = new Timer(400, null);
    timer.setInitialDelay(400);
    timer.setActionCommand(CMD_PROJECT_FILTER_CHANGED);
    timer.setRepeats(false);
}
 
源代码12 项目: AndrOBD   文件: KLHandler.java
/**
 * Default constructor
 */
public KLHandler()
{
	// set the logger object
	log = Logger.getLogger("com.fr3ts0n.prot.kl");

	commTimer = new Timer(commTimeoutTime, commTimeoutHandler);
	commTimer.setInitialDelay(commTimeoutTime);
	commTimer.stop();
}
 
源代码13 项目: jdk8u-dev-jdk   文件: AquaScrollBarUI.java
protected void installListeners() {
    fTrackListener = createTrackListener();
    fModelListener = createModelListener();
    fPropertyChangeListener = createPropertyChangeListener();
    fScrollBar.addMouseListener(fTrackListener);
    fScrollBar.addMouseMotionListener(fTrackListener);
    fScrollBar.getModel().addChangeListener(fModelListener);
    fScrollBar.addPropertyChangeListener(fPropertyChangeListener);
    fScrollListener = createScrollListener();
    fScrollTimer = new Timer(kNormalDelay, fScrollListener);
    fScrollTimer.setInitialDelay(kInitialDelay); // default InitialDelay?
}
 
源代码14 项目: zencash-swing-wallet-ui   文件: DashboardPanel.java
public LatestTransactionsPanel()
	throws InterruptedException, IOException, WalletCallException
{
	final JPanel content = new JPanel();
	content.setLayout(new BorderLayout(3,  3));
	content.add(new JLabel(langUtil.getString("panel.dashboard.transactions.label")),
			    BorderLayout.NORTH);
	transactionList = new LatestTransactionsList();
	JPanel tempPanel = new JPanel(new BorderLayout(0,  0));
	tempPanel.add(transactionList, BorderLayout.NORTH);
	content.add(tempPanel, BorderLayout.CENTER); 
	
	// Pre-fill transaction list once
	this.transactions = getTransactionsDataFromWallet();
	transactionList.updateTransactions(this.transactions);
	
	ActionListener al = new ActionListener() 
	{
		@Override
		public void actionPerformed(ActionEvent e) 
		{
			LatestTransactionsPanel.this.transactions = transactionGatheringThread.getLastData();
			if (LatestTransactionsPanel.this.transactions != null)
			{
				transactionList.updateTransactions(LatestTransactionsPanel.this.transactions);
			}
		}
	};
	
	Timer latestTransactionsTimer =  new Timer(8000, al);
	latestTransactionsTimer.setInitialDelay(8000);
	latestTransactionsTimer.start();
				
	this.setLayout(new GridLayout(1, 1));
	this.add(content);
}
 
源代码15 项目: azure-devops-intellij   文件: BusySpinnerPanel.java
public BusySpinnerPanel() {
    timer = new Timer(40, new TimerListener(this));
    timer.setRepeats(true);
    timer.setInitialDelay(40);
    timer.setDelay(40);
    start(false);
}
 
源代码16 项目: hottub   文件: AquaScrollBarUI.java
protected void installListeners() {
    fTrackListener = createTrackListener();
    fModelListener = createModelListener();
    fPropertyChangeListener = createPropertyChangeListener();
    fScrollBar.addMouseListener(fTrackListener);
    fScrollBar.addMouseMotionListener(fTrackListener);
    fScrollBar.getModel().addChangeListener(fModelListener);
    fScrollBar.addPropertyChangeListener(fPropertyChangeListener);
    fScrollListener = createScrollListener();
    fScrollTimer = new Timer(kNormalDelay, fScrollListener);
    fScrollTimer.setInitialDelay(kInitialDelay); // default InitialDelay?
}
 
源代码17 项目: chipster   文件: SessionManager.java
/**
 * @param dataManager
 * @param taskExecutor 
 * @param fileBrokerClient
 * @param callback
 *            if null, SessionChangedEvents are ignored and error messages
 *            are thrown as RuntimeExceptions
 * @throws IOException
 */
public SessionManager(final DataManager dataManager,
		TaskExecutor taskExecutor, FileBrokerClient fileBrokerClient, SessionManagerCallback callback)
		throws IOException {
	this.dataManager = dataManager;
	this.taskExecutor = taskExecutor;
	this.fileBrokerClient = fileBrokerClient;
	if (callback == null) {
		this.callback = new BasicSessionManagerCallback();
	} else {
		this.callback = callback;
	}

	// Remember changes to confirm close only when necessary and to backup
	// when necessary
	dataManager.addDataChangeListener(new DataChangeListener() {
		public void dataChanged(DataChangeEvent event) {
			unsavedChanges = true;
			unbackuppedChanges = true;
		}
	});

	// Start checking if background backup is needed
	aliveSignalFile = new File(dataManager.getRepository(), "i_am_alive");
	aliveSignalFile.createNewFile();
	aliveSignalFile.deleteOnExit();

	Timer timer = new Timer(SESSION_BACKUP_INTERVAL, new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			aliveSignalFile.setLastModified(System.currentTimeMillis()); // touch
																			// the
																			// file
			if (unbackuppedChanges) {

				File sessionFile = UserSession.findBackupFile(
						dataManager.getRepository(), true);
				sessionFile.deleteOnExit();

				try {
					saveLightweightSession(sessionFile);

				} catch (Exception e1) {
					logger.warn(e1); // do not care that much about failing
										// session backups
				}
			}
			unbackuppedChanges = false;
		}
	});

	timer.setCoalesce(true);
	timer.setRepeats(true);
	timer.setInitialDelay(SESSION_BACKUP_INTERVAL);
	timer.start();
}
 
源代码18 项目: ghidra   文件: GhidraSwingTimer.java
public GhidraSwingTimer(int initialDelay, int delay, TimerCallback callback) {
	this.callback = callback;
	timer = new Timer(delay, this);
	timer.setInitialDelay(initialDelay);
}
 
源代码19 项目: gate-core   文件: TextualDocumentView.java
@Override
protected void initGUI() {
  // textView = new JEditorPane();
  // textView.setContentType("text/plain");
  // textView.setEditorKit(new RawEditorKit());

  textView = new JTextArea();
  textView.setAutoscrolls(false);
  textView.setLineWrap(true);
  textView.setWrapStyleWord(true);
  // the selection is hidden when the focus is lost for some system
  // like Linux, so we make sure it stays
  // it is needed when doing a selection in the search textfield
  textView.setCaret(new PermanentSelectionCaret());
  scroller = new JScrollPane(textView);

  textView.setText(document.getContent().toString());
  textView.getDocument().addDocumentListener(swingDocListener);
  // display and put the caret at the beginning of the file
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        if(textView.modelToView(0) != null) {
          textView.scrollRectToVisible(textView.modelToView(0));
        }
        textView.select(0, 0);
        textView.requestFocus();
      } catch(BadLocationException e) {
        e.printStackTrace();
      }
    }
  });
  // contentPane = new JPanel(new BorderLayout());
  // contentPane.add(scroller, BorderLayout.CENTER);

  // //get a pointer to the annotation list view used to display
  // //the highlighted annotations
  // Iterator horizViewsIter = owner.getHorizontalViews().iterator();
  // while(annotationListView == null && horizViewsIter.hasNext()){
  // DocumentView aView = (DocumentView)horizViewsIter.next();
  // if(aView instanceof AnnotationListView)
  // annotationListView = (AnnotationListView)aView;
  // }
  highlightsMinder = new Timer(BLINK_DELAY, new UpdateHighlightsAction());
  highlightsMinder.setInitialDelay(HIGHLIGHT_DELAY);
  highlightsMinder.setDelay(BLINK_DELAY);
  highlightsMinder.setRepeats(true);
  highlightsMinder.setCoalesce(true);
  highlightsMinder.start();

  // blinker = new Timer(this.getClass().getCanonicalName() +
  // "_blink_timer",
  // true);
  // final BlinkAction blinkAction = new BlinkAction();
  // blinker.scheduleAtFixedRate(new TimerTask(){
  // public void run() {
  // blinkAction.actionPerformed(null);
  // }
  // }, 0, BLINK_DELAY);
  initListeners();
}
 
源代码20 项目: zencash-swing-wallet-ui   文件: DashboardPanel.java
public ExchangeRatePanel(StatusUpdateErrorReporter errorReporter)
{			
	// Start the thread to gather the exchange data
	this.zenDataGatheringThread = new DataGatheringThread<JsonObject>(
		new DataGatheringThread.DataGatherer<JsonObject>() 
		{
			public JsonObject gatherData()
				throws Exception
			{
				long start = System.currentTimeMillis();
				JsonObject exchangeData = ExchangeRatePanel.this.getExchangeDataFromRemoteService();
				long end = System.currentTimeMillis();
				Log.info("Gathering of ZEN Exchange data done in " + (end - start) + "ms." );
					
				return exchangeData;
			}
		}, 
		errorReporter, 60000, true);
	
	this.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 18));
	this.recreateExchangeTable();
	
	// Start the timer to update the table
	ActionListener alExchange = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e)
		{
			try
			{					
				ExchangeRatePanel.this.recreateExchangeTable();
			} catch (Exception ex)
			{
				Log.error("Unexpected error: ", ex);
				DashboardPanel.this.errorReporter.reportError(ex);
			}
		}
	};
	Timer t = new Timer(30000, alExchange); // TODO: add timer for disposal ???
	t.setInitialDelay(1000);
	t.start();
}