当前位置: 首页>>代码示例>>Java>>正文


Java Timer.addActionListener方法代码示例

本文整理汇总了Java中javax.swing.Timer.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java Timer.addActionListener方法的具体用法?Java Timer.addActionListener怎么用?Java Timer.addActionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.Timer的用法示例。


在下文中一共展示了Timer.addActionListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DragWindow.java

示例2: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DragWindow.java

示例3: BarcodeScannerWatcher

import javax.swing.Timer; //导入方法依赖的package包/类
public BarcodeScannerWatcher()
{
    queuePush = new Timer(1, null);
    queuePush.setCoalesce(true);
    queuePush.setRepeats(false);
    queuePush.addActionListener(new ActionListener() {
        @Override public void actionPerformed(ActionEvent ae) { 
            timeout(); 
        }
    });

    applyConfig();
    Messenger.register(MT.SCANNER_OPTIONS_CHANGED, new MessageListener() {
        @Override public void event(MT type, Object data) {
            applyConfig();
        }
    });
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:19,代码来源:BarcodeScannerWatcher.java

示例4: makeVisible

import javax.swing.Timer; //导入方法依赖的package包/类
private synchronized void makeVisible(boolean animate, final boolean top, final Item lastTop) {
    if (animationRunning) {
        return;
    }
    int height = top ? preferredHeight - tapPanelMinimumHeight : preferredHeight;
    if (!animate) {
        setTop(top);
        if (top && lastTop != null) {
            lastTop.setTop(false);
        }
        scrollPane.setPreferredSize(new Dimension(0, height));
        outerPanel.setPreferredSize(new Dimension(0, height));
        scrollPane.setVisible(true);
        separator.setVisible(true);
    } else {
        scrollPane.setPreferredSize(new Dimension(0, 1));
        outerPanel.setPreferredSize(new Dimension(0, height));
        animationRunning = true;
        isTop = top;
        if (isTop && lastTop != null) {
            lastTop.setTop(false);
        }
        topGapPanel.setVisible(!isTop);
        if (animationRunning) {
            scrollPane.setVisible(true);
            separator.setVisible(true);
            tapPanel.revalidate();
        }
        if (isTop) {
            tapPanel.setBackground(backgroundColor);
        }
        int delta = 1;
        int currHeight = 1;
        Timer animationTimer = new Timer(20, null);
        animationTimer.addActionListener(new AnimationTimerListener(animationTimer, delta, currHeight));
        animationTimer.setCoalesce(false);
        animationTimer.start();
    } // else
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:InfoPanel.java

示例5: addJumpListEntry

import javax.swing.Timer; //导入方法依赖的package包/类
/** Add the jump-list entry for the for the component that's opened
* over the given dataobject if any.
*/
public static void addJumpListEntry(DataObject dob) {
    final EditorCookie ec = (EditorCookie)dob.getCookie(EditorCookie.class);
    if (ec != null) {
        final Timer timer = new Timer(500, null);
        timer.addActionListener(
            new ActionListener() {

                private int countDown = 10;

                public void actionPerformed(ActionEvent evt) {
                    SwingUtilities.invokeLater(
                        new Runnable() {
                            public void run() {
                                if (--countDown >= 0) {
                                    JEditorPane[] panes = ec.getOpenedPanes();
                                    if (panes != null && panes.length > 0) {
                                        JumpList.checkAddEntry(panes[0]);
                                        timer.stop();
                                    }
                                } else {
                                    timer.stop();
                                }
                            }
                        }
                    );
                }
            }
        );
        timer.start();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:NbEditorUtilities.java

示例6: startAnimation

import javax.swing.Timer; //导入方法依赖的package包/类
void startAnimation(){

		int delay = 10;
		final Timer timer = new Timer(delay, null);
		timer.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {

				if(!animation.animationRunning){
					timer.stop();
				}
				else
				{
					boolean rotate = false;
					int lastToothY = Frame.this.animation.wheelTeeth.get(Frame.this.animation.wheelTeeth.size()-1).y;
					for(WheelTooth t : Frame.this.animation.wheelTeeth)
						if(lastToothY != t.moveTooth(Frame.this.animation.vel,lastToothY)) {
							rotate = true;
							lastToothY = t.moveTooth(Frame.this.animation.vel,lastToothY);
						}
					if(rotate){
						Frame.this.animation.wheelTeeth.add(Frame.this.animation.wheelTeeth.remove(0));
					}

					SwingUtilities.invokeLater(new Runnable(){
						@Override
						public void run(){
							Frame.this.animation.repaint();
							Frame.this.bottom.detectorPanel.detectorImage.repaint();
						}
					});
				}

			}
		});

		if(!timer.isRunning()) { timer.start(); }
	}
 
开发者ID:Tosbert,项目名称:FizeauExperimentSimulation,代码行数:39,代码来源:Frame.java

示例7: performImport

import javax.swing.Timer; //导入方法依赖的package包/类
public static void performImport(List<EclipseProject> eclProjects, String destination, List<WizardDescriptor.Panel<WizardDescriptor>> extraPanels, int numberOfImportedProject, final boolean showReport, final boolean openProjects, final List<String> importProblems, final List<Project> createdProjects) {
    
    final Importer importer = new Importer(eclProjects, destination, extraPanels);
    
    // prepare progress dialog
    final ProgressPanel progressPanel = new ProgressPanel();
    DialogDescriptor desc = new DialogDescriptor(progressPanel,
            NbBundle.getMessage(ImportProjectAction.class, "CTL_ProgressDialogTitle"),
            true, new Object[]{}, null, 0, null, null);
    desc.setClosingOptions(new Object[]{});
    final Dialog progressDialog = DialogDisplayer.getDefault().createDialog(desc);
    ((JDialog) progressDialog).setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    progressPanel.start(numberOfImportedProject);
    
    // progress timer for periodically update progress
    final Timer progressTimer = new Timer(250, null);
    progressTimer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            progressPanel.setProgress(importer.getNOfProcessed(), importer.getProgressInfo());
            if (importer.isDone()) {
                progressTimer.stop();
                progressDialog.setVisible(false);
                progressDialog.dispose();
                if (importProblems != null) {
                    importProblems.addAll(importer.getWarnings());
                }
                if (showReport) {
                    ImportProblemsPanel.showReport(org.openide.util.NbBundle.getMessage(ImportProjectAction.class, "MSG_ImportIssues"), importer.getWarnings());
                }
                // open created projects when importing finished
                if (importer.getProjects().length > 0) {
                    if (createdProjects != null) {
                        createdProjects.addAll(Arrays.<Project>asList(importer.getProjects()));
                    }
                    if (openProjects) {
                        OpenProjects.getDefault().open(importer.getProjects(), true);
                    }
                }
            }
        }
    });
    importer.startImporting(); // runs importing in separate thread
    progressTimer.start();
    progressDialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:ImportProjectAction.java


注:本文中的javax.swing.Timer.addActionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。