/** constructor */ public DanceQueuePanel() { // flow layout setLayout(new FlowLayout()); // uses buffer to draw arrows based on queues in an array myImage = new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB); myBuffer = myImage.getGraphics(); // uses timer to queue buffer changes time = 0; timer = new Timer(5, new Listener()); timer.start(); setFocusable(true); // picks instructions based on song & level if (Danceoff.getSong() == -1 && Danceoff.getDifficulty() == 0) { arrows = new Arrow[] {new UpArrow(1000), new DownArrow(2000), new LeftArrow(3000)}; } // setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 3), // "DanceQueuePanel")); // load images for arrows rightArrowImg = null; leftArrowImg = null; upArrowImg = null; downArrowImg = null; try { rightArrowImg = ImageIO.read(new File("arrowB right.png")); leftArrowImg = ImageIO.read(new File("arrowB left.png")); upArrowImg = ImageIO.read(new File("arrowB up copy.png")); downArrowImg = ImageIO.read(new File("arrowB down.png")); } catch (IOException e) { warn("YOU FAIL", e); System.exit(2); } }
private void startCurrentMethodClock(double a, double b) { An.clear(); Bn.clear(); Cn.clear(); switch (type) { case 0: // bisectiei An.add(new PointDP(a, 0.0)); Bn.add(new PointDP(b, 0.0)); Cn.add(new PointDP(((An.lastElement()).x + (Bn.lastElement()).x) / 2, 0.0)); break; case 1: // coardei case 2: // secantei An.add(new PointDP(a, 0.0)); An.add(new PointDP(b, 0.0)); break; case 3: // newton An.add(new PointDP(a, 0.0)); break; } theTimer.start(); repaint(); }
/** * Expands or collapses this <code>JCollapsiblePane</code>. * * <p> * * <p>If the component is collapsed and <code>val</code> is false, then this call expands the * JCollapsiblePane, such that the entire JCollapsiblePane will be visible. If {@link * #isAnimated()} returns true, the expansion will be accompanied by an animation. * * <p> * * <p>However, if the component is expanded and <code>val</code> is true, then this call collapses * the JCollapsiblePane, such that the entire JCollapsiblePane will be invisible. If {@link * #isAnimated()} returns true, the collapse will be accompanied by an animation. * * @javabean.property bound="true" preferred="true" * @see #isAnimated() * @see #setAnimated(boolean) */ public void setCollapsed(boolean val) { if (collapsed != val) { collapsed = val; if (isAnimated()) { if (collapsed) { setAnimationParams( new AnimationParams(30, Math.max(8, wrapper.getHeight() / 10), 1.0f, 0.01f)); animator.reinit(wrapper.getHeight(), 0); animateTimer.start(); } else { setAnimationParams( new AnimationParams( 30, Math.max(8, getContentPane().getPreferredSize().height / 10), 0.01f, 1.0f)); animator.reinit(wrapper.getHeight(), getContentPane().getPreferredSize().height); animateTimer.start(); } } else { wrapper.c.setVisible(!collapsed); invalidate(); doLayout(); } repaint(); firePropertyChange("collapsed", !collapsed, collapsed); } }
public void paintComponent(Graphics g) { if (m.isPressed()) { t = colorCount - 1; g.setColor(pressed[t]); g.fillRect(0, 0, getSize().width - 1, getSize().height - 1); g.setColor(border[t]); } else { g.setColor(rollOver[t]); g.fillRect(0, 0, getSize().width - 1, getSize().height - 1); g.setColor(border[t]); if (m.isRollover()) { if (t < colorCount - 1 && !fadeIn.isRunning()) { fadeOut.stop(); fadeIn.start(); } } else { if (t > 0 && !fadeOut.isRunning()) { fadeIn.stop(); fadeOut.start(); } } } super.paintComponent(g); }
public void start() { if (paused) return; started = true; finishedFalling = false; turnAmount = 0; score = 0; clearBoard(); makeNewPiece(); timer.start(); timer1.start(); }
public GamePanel() { bird = new Bird(); bottomWall = new Wall(600); topWall = new Wall(1000); score = 0; isDead = false; moverTimer = new Timer(30, new GameMotion()); moverTimer.start(); scoreTimer = new Timer(2400, new ScoreCounter()); scoreTimer.start(); addKeyListener(new KeyAdapter()); setFocusable(true); }
/** Constructs a new Sceen with given height & width (in words) and amount of bits per word. */ public ScreenComponent() { setOpaque(true); setBackground(Color.white); setBorder(BorderFactory.createEtchedBorder()); Insets borderInsets = getBorder().getBorderInsets(this); int borderWidth = borderInsets.left + borderInsets.right; int borderHeight = borderInsets.top + borderInsets.bottom; setPreferredSize( new Dimension( Definitions.SCREEN_WIDTH + borderWidth, Definitions.SCREEN_HEIGHT + borderHeight)); setSize(Definitions.SCREEN_WIDTH + borderWidth, Definitions.SCREEN_HEIGHT + borderHeight); data = new short[Definitions.SCREEN_SIZE]; x = new int[Definitions.SCREEN_SIZE]; y = new int[Definitions.SCREEN_SIZE]; x[0] = borderInsets.left; y[0] = borderInsets.top; // updates pixels indice for (int i = 1; i < Definitions.SCREEN_SIZE; i++) { x[i] = x[i - 1] + Definitions.BITS_PER_WORD; y[i] = y[i - 1]; if (x[i] == Definitions.SCREEN_WIDTH + borderInsets.left) { x[i] = borderInsets.left; y[i]++; } } timer = new Timer(STATIC_CLOCK_INTERVALS, this); timer.start(); }
public void start() { timer = new Timer( INITIAL_DELAY, new ActionListener() { public void actionPerformed(ActionEvent ae) { synchronized (timer) { if (cur_piece.canStepDown()) { cur_piece.cut(); cur_piece.stepDown(); cur_piece.paste(); if (timer.isFast()) score_label.addValue(1); } else { timer.setFast(false); if (!cur_piece.isTotallyOnGrid()) gameOver(); else { removeFullRows(); installNewPiece(); } } } game_grid.repaint(); } }); timer.start(); }
public void gameover() { ImageIcon bombss = new ImageIcon("bomb.png"); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (bombs[i][j] == true) { gbuttons[i][j].setBackground(Color.red); gbuttons[i][j].setIcon(bombss); } } } int delay = 2000; // milliseconds ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { Lost lost = new Lost(); lost.setLocationRelativeTo(null); lost.setVisible(true); dispose(); } }; Timer timer = new Timer(delay, taskPerformer); timer.setRepeats(false); timer.start(); }
private void create() { JFrame f = new JFrame("JSplitPane"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MyPanel p1 = new MyPanel(Color.red); MyPanel p2 = new MyPanel(Color.blue); final JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, p1, p2); Timer timer = new Timer( 200, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ratio += delta; if (ratio >= 1.0) { ratio = 1.0; delta = -delta; } else if (ratio <= 0) { delta = -delta; ratio = 0; } jsp.setDividerLocation(ratio); } }); f.add(jsp); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); timer.start(); }
public void startGame() { image = createImage(SIZE.width, SIZE.height); graph = image.getGraphics(); for (int i = 0; i < balls.length; i++) balls[i].start(); Timer timer = new Timer(REFRESH, this); timer.start(); }
protected final void restartTimer() { if (!myAutoSelectionTimer.isRunning()) { myAutoSelectionTimer.start(); } else { myAutoSelectionTimer.restart(); } }
public void atualizacaoAutomaticaTabela() { ActionListener acao = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { final Progress p = new Progress(); p.setVisible(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { atualizaTabela(); return null; } @Override protected void done() { p.setVisible(false); } }; worker.execute(); } }; timerTelaExclusao = new Timer(5000 * 60, acao); // a cada 5 minutos executa o metodo timerTelaExclusao.start(); }
public Clock() { main_panel.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { System.exit(0); } }); Timer timer = new Timer( 1000, new ActionListener() { public void actionPerformed(ActionEvent e) { Calendar curTime = Calendar.getInstance(); curTime.setTimeInMillis(System.currentTimeMillis()); hour.setText(setTimeString(curTime.get(Calendar.HOUR_OF_DAY) + "")); minutes.setText(setTimeString(curTime.get(Calendar.MINUTE) + "")); second.setText(setTimeString(curTime.get(Calendar.SECOND) + "")); } }); timer.setInitialDelay(0); timer.start(); }
private void jBFecharActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBFecharActionPerformed // TODO add your handling code here: this.setVisible(false); timerPCP.start(); timer.stop(); } // GEN-LAST:event_jBFecharActionPerformed
public void mouseMoved(MouseEvent e) { if (enabled && enableMouseMoves && !readOnly) { if (timer == null) { timer = new Timer(mouseMoveDelay, this); timer.setRepeats(false); timer.start(); } else { timer.stop(); timer.start(); } lastMouseMoveEvent = e; mouseMovesList.add(0, e); if (mouseMovesList.size() > mouseMoveInsertPrevious) { mouseMovesList.remove(mouseMovesList.size() - 1); } } }
@Override public void actionPerformed(ActionEvent e) { if (tcheck.isSelected()) { timer.start(); } else { timer.stop(); } }
private void jBFecharActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBFecharActionPerformed timerTelaExclusao.stop(); timer.start(); this.setVisible(false); atualizar.doClick(); } // GEN-LAST:event_jBFecharActionPerformed
public void unPause() { pause = false; moveTime.start(); fallTime.start(); bulletMoveTime.start(); waterTime.start(); bulletTime.start(); grenadeTime.start(); laserTime.start(); shotgunTime.start(); if (shapeAI.getAI()) { aiMove.start(); } }
public Board() { p = new Player(); addKeyListener(new AL()); setFocusable(true); ImageIcon i = new ImageIcon("C:/background.png"); img = i.getImage(); time = new Timer(1, this); time.start(); }
public MainPanel() { super(new BorderLayout()); vcheck.setSelected(true); echeck.setSelected(true); tcheck.setSelected(true); JTabbedPane tab = new JTabbedPane(); tab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); button.addHierarchyListener( new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { printInfo("SHOWING_CHANGED"); } if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) { printInfo("DISPLAYABILITY_CHANGED"); } } }); printInfo("after: new JButton, before: add(button); frame.setVisible(true)"); JPanel panel = new JPanel(); panel.add(button); for (int i = 0; i < 5; i++) { panel.add(new JLabel("<html>asfasfdasdfasdfsa<br>asfdd134123fgh")); } tab.addTab("Main", new JScrollPane(panel)); tab.addTab("JTree", new JScrollPane(new JTree())); tab.addTab("JLabel", new JLabel("Test")); JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); p1.add(new JLabel("JButton:")); p1.add(vcheck); p1.add(echeck); JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); p2.add(new JLabel("Timer:")); p2.add(tcheck); JPanel p = new JPanel(new GridLayout(2, 1)); p.add(p1); p.add(p2); add(p, BorderLayout.NORTH); add(tab); timer = new Timer( 4000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { printInfo(new Date().toString()); } }); timer.start(); setPreferredSize(new Dimension(320, 240)); }
@Override public void setLocked(boolean isLocked) { super.setLocked(isLocked); if (isLocked) { timer.start(); } else { timer.stop(); } }
@Override @SuppressWarnings("deprecation") public void hide() { if (isExperimentalSheet()) { OSXSheetSupport.hideSheet(this); hide0(); uninstallSheet(); } else if (isAnimated() && isShowAsSheet() && !isNativeSheetSupported()) { getContentPane().setVisible(false); final Rectangle startBounds = getBounds(); int parentWidth = getParent().getWidth(); final Rectangle endBounds = new Rectangle( (parentWidth < startBounds.width) ? startBounds.x + (startBounds.width - parentWidth) / 2 : startBounds.x, startBounds.y, Math.min(startBounds.width, parentWidth), 0); final Timer timer = new Timer(20, null); timer.addActionListener( new ActionListener() { long startTime; long endTime; public void actionPerformed(ActionEvent evt) { long now = System.currentTimeMillis(); if (startTime == 0) { startTime = now; endTime = startTime + 200; } if (now > endTime) { timer.stop(); hide0(); setBounds(startBounds); getContentPane().setVisible(true); uninstallSheet(); } else { float ratio = (now - startTime) / (float) (endTime - startTime); setBounds( (int) (startBounds.x * (1f - ratio) + endBounds.x * ratio), (int) (startBounds.y * (1f - ratio) + endBounds.y * ratio), (int) (startBounds.width * (1f - ratio) + endBounds.width * ratio), (int) (startBounds.height * (1f - ratio) + endBounds.height * ratio)); } } }); timer.setRepeats(true); timer.setInitialDelay(5); timer.start(); } else { hide0(); uninstallSheet(); } }
/* * executado ao clicar no botao excluir */ private void jBExcluirLoteActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBExcluirLoteActionPerformed timerTelaExclusao.stop(); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); excluir(); this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); timerTelaExclusao.start(); jBAtualizar.doClick(); } // GEN-LAST:event_jBExcluirLoteActionPerformed
private void jBFecharKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jBFecharKeyTyped if (evt.getKeyChar() == KeyEvent.VK_ENTER) { if (evt.getSource() == jBFechar) { this.setVisible(false); timerPCP.start(); timer.stop(); } } } // GEN-LAST:event_jBFecharKeyTyped
public void initializeGameObjects() { // instantiate ball, paddle, and brick configuration ball = new Ball(); paddle = new Paddle(); bconfig = new BrickConfiguration(); // set up timer to run GameMotion() every 10ms timer = new Timer(10, new GameMotion()); timer.start(); }
public GameCanvas() { super(true); Timer runLoopTimer = new Timer( 1000 / 60, (action) -> { if (this .shouldPlayMoveSequence()) { // Update only if we're animating the player's // movement. this.update(1000 / 60); this.repaint(); } }); runLoopTimer.setRepeats(true); runLoopTimer.start(); this.addMouseListener( new MouseListener() { @Override public void mouseClicked(MouseEvent e) { double width = GameCanvas.this.getWidth(); double height = GameCanvas.this.getHeight(); Board board = _gameState.board; double ratio = (double) board.width / board.height; width = Math.min(width, (height * ratio)); height = Math.min(height, (width / ratio)); double startX = GameCanvas.this.getWidth() / 2 - width / 2; double startY = GameCanvas.this.getHeight() / 2 - height / 2; double step = width / board.width; int tileX = (int) ((e.getX() - startX) / step); int tileY = (int) ((e.getY() - startY) / step); if (_tileSelectionDelegate.isPresent() && tileX >= 0 && tileX < board.width && tileY >= 0 && tileY < board.height) { _tileSelectionDelegate.get().didSelectTileAtLocation(new Location<>(tileX, tileY)); } } @Override public void mousePressed(MouseEvent e) {} @Override public void mouseReleased(MouseEvent e) {} @Override public void mouseEntered(MouseEvent e) {} @Override public void mouseExited(MouseEvent e) {} }); }
private void jBFecharKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jBFecharKeyTyped if (evt.getKeyChar() == KeyEvent.VK_ENTER) { if (evt.getSource() == jBFechar) { timerTelaExclusao.stop(); timer.start(); this.setVisible(false); atualizar.doClick(); } } } // GEN-LAST:event_jBFecharKeyTyped
public Stars() { setPreferredSize(new Dimension(150, 150)); setBackground(new Color(0, 86, 141)); appDisplay = new JFrame("Stars"); appDisplay.getContentPane().add(this); appDisplay.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); appDisplay.pack(); appDisplay.setVisible(true); timer = new Timer(DELAY, null); timer.addActionListener(new StarListener()); timer.start(); }
private void createRepaintTimer() { if (myRepaintTimer != null) { myRepaintTimer.stop(); } myRepaintTimer = new Timer(1000 / myMaxFPS, new WeakRedrawTimer(this)); myRepaintTimer.start(); }