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


Java Timer.start方法代码示例

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


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

示例1: 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<>();
    }
}
 
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:22,代码来源:ImportWorker.java

示例2: 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();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:SplashScreen.java

示例3: doInBackground

import javax.swing.Timer; //导入方法依赖的package包/类
@Override
protected Void doInBackground() throws Exception {
  final CountDownLatch latch = new CountDownLatch(1);

  // Wait 3 seconds before counting down the latch to ensure
  // that the user has sufficient time to read the message on
  // the first pane.
  timer = new Timer(2000, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      latch.countDown();
    }
  });
  timer.start();

  // Make the request to the server and wait for the latch.
  BugUtils.sendBugReport(
    emailField.getText(),
    descriptionArea.getText(),
    errorLog,
    thrown
  );

  latch.await();
  return null;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:BugDialog.java

示例4: run

import javax.swing.Timer; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test6559154.java

示例5: 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

示例6: BackDoor

import javax.swing.Timer; //导入方法依赖的package包/类
/**
 * Creates new form BackDoor
 */
public BackDoor(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    final Timer t = new Timer(5000, (ActionEvent e) -> {
        setVisible(false);
    });
    t.start();
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:12,代码来源:BackDoor.java

示例7: DeclarationPanel

import javax.swing.Timer; //导入方法依赖的package包/类
/**
 * Creates a DeclarationPanel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public DeclarationPanel(FreeColClient freeColClient) {
    super(freeColClient, null);

    Image image = ResourceManager.getImage("image.flavor.Declaration");
    setSize(image.getWidth(null), image.getHeight(null));
    setOpaque(false);
    setBorder(null);
    addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent k) {
                getGUI().removeFromCanvas(DeclarationPanel.this);
            }
        });
    addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                getGUI().removeFromCanvas(DeclarationPanel.this);
            }
        });

    final SignaturePanel signaturePanel = new SignaturePanel();
    signaturePanel.initialize(getMyPlayer().getName());
    signaturePanel.setLocation((getWidth()-signaturePanel.getWidth()) / 2,
        (getHeight() + SIGNATURE_Y - signaturePanel.getHeight()) / 2 - 15);
    signaturePanel.addActionListener(this);

    add(signaturePanel);

    Timer t = new Timer(START_DELAY, (ActionEvent ae) -> {
            signaturePanel.startAnimation();
        });
    t.setRepeats(false);
    t.start();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:40,代码来源:DeclarationPanel.java

示例8: initializeMainWindow

import javax.swing.Timer; //导入方法依赖的package包/类
/** Method to initialize the main window.
*/
private void initializeMainWindow() {
    StartLog.logStart ("Main window initialization"); //NOI18N

    TimableEventQueue.initialize();
    
    // -----------------------------------------------------------------------------------------------------
    // 11. Initialization of main window
    StatusDisplayer.getDefault().setStatusText (NbBundle.getMessage (GuiRunLevel.class, "MSG_MainWindowInit"));

    // force to initialize timer
    // sometimes happened that the timer thread was initialized under
    // a TaskThreadGroup
    // such task never ends or, if killed, timer is over
    Timer timerInit = new Timer(0, new java.awt.event.ActionListener() {
          public @Override void actionPerformed(java.awt.event.ActionEvent ev) { }
    });
    timerInit.setRepeats(false);
    timerInit.start();
    Splash.getInstance().increment(10);
    StartLog.logProgress ("Timer initialized"); // NOI18N

// -----------------------------------------------------------------------------------------------------
// 14. Open main window
    StatusDisplayer.getDefault().setStatusText (NbBundle.getMessage (GuiRunLevel.class, "MSG_WindowShowInit"));

    // Starts GUI components to be created and shown on screen.
    // I.e. main window + current workspace components.



    // Access winsys from AWT thread only. In this case main thread wouldn't harm, just to be kosher.
    final WindowSystem windowSystem = Lookup.getDefault().lookup(WindowSystem.class);
    if (windowSystem != null) {
        windowSystem.init();
    }
    SwingUtilities.invokeLater(new InitWinSys(windowSystem));
    StartLog.logEnd ("Main window initialization"); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:GuiRunLevel.java

示例9: start

import javax.swing.Timer; //导入方法依赖的package包/类
/**
 * Запуск таймера. При старте каждый раз создается новый таймер, не используется старый, т.к.
 * интервал ему можно сменить тока с глюками влюбой момент перед стартом.
 */
public void start() {
    if (isActive()) {
        stop();
    }
    cntr = 0;
    t = new Timer(getInterval(), timeAction);
    t.start();
    active = true;
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:14,代码来源:ATalkingClock.java

示例10: EventLogPanel

import javax.swing.Timer; //导入方法依赖的package包/类
/**
 * Creates a new log panel
 * @param gui The where this log belongs to (for callbacks) 
 */
public EventLogPanel(DTNSimGUI gui) {
	this.gui = gui;
	String title = PANEL_TITLE;
	Settings s = new Settings("GUI.EventLogPanel");
	
	if (s.contains("nrofEvents")) {
		this.maxNrofEvents = s.getInt("nrofEvents");
	}
	if (s.contains("REfilter")) {
		this.regExp = s.getSetting("REfilter");
	}
	
	layout = new GridLayout(maxNrofEvents,1);

	this.setLayout(layout);
	if (this.regExp != null) {
		title += " - RE-filter: " + regExp;
	}
	this.setBorder(BorderFactory.createTitledBorder(
			getBorder(), title));
	
	this.eventPanes = new Vector<JPanel>(maxNrofEvents);
	this.font = new Font(FONT_TYPE,Font.PLAIN, FONT_SIZE);
	this.controls = createControls();
	
	// set log view to update every LOG_UP_INTERVAL milliseconds
	// also ensures that the update is done in Swing's EDT
	ActionListener taskPerformer = new ActionListener() {
		public void actionPerformed(ActionEvent evt) {
	          updateLogView();
	      }
	  };
	  Timer t = new Timer(LOG_UP_INTERVAL, taskPerformer);
	  t.start();
}
 
开发者ID:mdonnyk,项目名称:the-one-mdonnyk,代码行数:40,代码来源:EventLogPanel.java

示例11: 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

示例12: start

import javax.swing.Timer; //导入方法依赖的package包/类
/**
 * Metodo para iniciar el decrecimiento de Combustible
 */
public void start(){
            
    timerFuel = new Timer(800, new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent e) {
            
            fuel.setValue(fuel.getValue()-2);
            
        }
        
    });
    timerFuel.start();
}
 
开发者ID:Uminks,项目名称:Star-Ride--RiverRaid,代码行数:17,代码来源:PanelScore.java

示例13: runTest

import javax.swing.Timer; //导入方法依赖的package包/类
public static synchronized void runTest() {
    frame.setSize(800, 600);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Timer timer = new Timer(waitTime, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            frame.setExtendedState(Frame.ICONIFIED);
            frame.dispose();
            Sysout.println("Test completed please press/fail button");
        }
    });
    timer.setRepeats(false);
    timer.start();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:bug8037575.java

示例14: 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

示例15: ClockLabel

import javax.swing.Timer; //导入方法依赖的package包/类
public ClockLabel(String type) {
  this.type = type;
  setForeground(Color.red);
 
  if(type.equals("date"))
  {
  	sdf = new SimpleDateFormat("  MMMM dd yyyy");
      setFont(new Font("PHOSPHATE", Font.PLAIN, 18));
      setHorizontalAlignment(SwingConstants.LEFT);
  }
  else if(type.equals("time"))
  {
  	sdf = new SimpleDateFormat("hh:mm:ss a");
      setFont(new Font("PHOSPHATE", Font.PLAIN, 40));
      setHorizontalAlignment(SwingConstants.CENTER);
  }
  else if(type.equals("day"))
  {
  	sdf = new SimpleDateFormat("EEEE  ");
      setFont(new Font("PHOSPHATE", Font.PLAIN, 18));
      setHorizontalAlignment(SwingConstants.RIGHT);
  }
  else
  {
  	sdf = new SimpleDateFormat();
  }

  Timer t = new Timer(1000, this);
  t.start();
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:31,代码来源:DigitalClock1.java


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