本文整理汇总了Java中javax.swing.Timer类的典型用法代码示例。如果您正苦于以下问题:Java Timer类的具体用法?Java Timer怎么用?Java Timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timer类属于javax.swing包,在下文中一共展示了Timer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import javax.swing.Timer; //导入依赖的package包/类
/**
* {@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);
}
}
示例2: startDismissTimer
import javax.swing.Timer; //导入依赖的package包/类
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();
}
示例3: actionPerformed
import javax.swing.Timer; //导入依赖的package包/类
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();
}
}
}
}
示例4: MemoryView
import javax.swing.Timer; //导入依赖的package包/类
/**
* 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();
}
示例5: annotate
import javax.swing.Timer; //导入依赖的package包/类
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();
}
示例6: SearchHistoryPanel
import javax.swing.Timer; //导入依赖的package包/类
/** 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);
}
示例7: invokeTip
import javax.swing.Timer; //导入依赖的package包/类
/** 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();
}
示例8: createInitialEffect
import javax.swing.Timer; //导入依赖的package包/类
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;
}
示例9: createNoDropEffect
import javax.swing.Timer; //导入依赖的package包/类
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;
}
示例10: initGUI
import javax.swing.Timer; //导入依赖的package包/类
/**
* 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();
}
示例11: disableSelection
import javax.swing.Timer; //导入依赖的package包/类
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();
}
示例12: doInBackground
import javax.swing.Timer; //导入依赖的package包/类
@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<>();
}
}
示例13: BranchSelector
import javax.swing.Timer; //导入依赖的package包/类
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
}
示例14: startMonitorThread
import javax.swing.Timer; //导入依赖的package包/类
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();
}
示例15: SplashScreen
import javax.swing.Timer; //导入依赖的package包/类
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();
}