poo – Timer en java como usar

Tengo un timer en mi Panel, quiero que lo use en otra clase, pero ahora quiero que lo use en mi clase, desconozco como es que funciona quiero saber que me hace falta adjunto mi JPanel donde lo implementé.

public class JPAreaJuego extends JPanel implements KeyListener, MouseListener, ActionListener {
    private Juego juego;
    private javax.swing.Timer timer;
    private int contadorReproduccion;
    private int CDDamage;
    
    public JPAreaJuego() {
        this.contadorReproduccion = 0;
        this.CDDamage = 0;
        this.setPreferredSize(new Dimension(800, 600));
        this.setFocusable(true);
        this.requestFocus();
        this.addKeyListener(this);
        this.addMouseListener(this);
        this.juego = new Juego();
        this.timer = new javax.swing.Timer(1000/60, this);
        this.timer.start();
    } // JPanel del área de juego

    public javax.swing.Timer getTimer() {
        return timer;
    }

    public void setTimer(javax.swing.Timer timer) {
        this.timer = timer;
    }

    protected void paintComponent(Graphics g) {
        this.juego.dibujar(g);
        this.juego.actualizar();
        this.repaint();
    } // paintComponent

    public void keyPressed(KeyEvent e) {
        
        if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            this.juego.getJugador().ponerGranada();
        }
        
        if (e.getKeyCode() == KeyEvent.VK_UP) {
            this.juego.getJugador().movimientoArriba();
        }

        if (e.getKeyCode() == KeyEvent.VK_DOWN) {
            this.juego.getJugador().movimientoAbajo();
        }

        if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
            this.juego.getJugador().movimientoDerecha();
        }

        if (e.getKeyCode() == KeyEvent.VK_LEFT) {
            this.juego.getJugador().movimientoIzquierda();
        }

        if (e.getKeyCode() == KeyEvent.VK_UP) {
            this.juego.getJugador().getBlaster().movimientoArriba();
        }

        if (e.getKeyCode() == KeyEvent.VK_DOWN) {
            this.juego.getJugador().getBlaster().movimientoAbajo();
        }

        if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
            this.juego.getJugador().getBlaster().movimientoDerecha();
        }

        if (e.getKeyCode() == KeyEvent.VK_LEFT) {
            this.juego.getJugador().getBlaster().movimientoIzquierda();
        }

    } // Movimiento

    public void keyReleased(KeyEvent e) {

    }

    public void keyTyped(KeyEvent e) {

    } // Para las teclas

    public void mouseClicked(MouseEvent e) {

    }

    public void mouseEntered(MouseEvent e) {

    }

    public void mouseExited(MouseEvent e) {

    }

    public void mousePressed(MouseEvent e) {
        this.juego.getJugador().getBlaster().disparar();
    }

    public void mouseReleased(MouseEvent e) {
    
    }

    public void actionPerformed(ActionEvent e) {
        contadorReproduccion++;
        if(contadorReproduccion == 600) {
            this.juego.getTablero().reproducirse();
            this.juego.getTablero().crearEnemigos();
        } // Duración para que se reproduzcan
    }

} // Class

Este es mi JPanel donde lo inicializo y uso el actionsperformed y seleccioné el método que quiero que taimee, le puse el tiempo etc, pero no sé como activarlo en mi clase. adjunto el método de la otra clase que quiero que use.

public void reproducirse() {
    
        for (int i = 0; i < casilla.length; i++) {
            for (int j = 0; j < casilla.length; j++) {
                if (i == 0 && j == 0 && this.casilla(i)(j) == null) {
                    if (this.casilla(i)(j + 1) != null && this.casilla(i + 1)(j + 1) != null
                            && this.casilla(i + 1)(j) != null) {
                        int random = (int) (Math.random() * 10);

                        if (random >= 0 && random <= 5) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaL(i * 40, j * 40));
                        } else if (random <= 8 && random >= 6) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaS(i * 40, j * 40));
                        } else {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaV(i * 40, j * 40));
                        } // Else
                    } // If Interno
                } // If externo

                if (j > 0 && i < 0 && this.casilla(i)(j) != null) {
                    if (this.casilla(i)(j - 1) != null && this.casilla(i + 1)(j - 1) != null
                            && this.casilla(i + 1)(j) != null
                            || this.casilla(i)(j + 1) != null && this.casilla(i + 1)(j + 1) != null
                                    && this.casilla(i + 1)(j) != null) {
                        int random = (int) (Math.random() * 10);

                        if (random >= 0 && random <= 5) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaL(i * 40, j * 40));
                        } else if (random <= 8 && random >= 6) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaS(i * 40, j * 40));
                        } else {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaV(i * 40, j * 40));
                        } // Else
                    } // If Interno
                } // If externo

                if (i > 0 && j < 0 && this.casilla(i)(j) != null) {
                    if (this.casilla(i)(j + 1) != null && this.casilla(i + 1)(j + 1) != null
                            && this.casilla(i + 1)(j) != null) {
                        int random = (int) (Math.random() * 10);

                        if (random >= 0 && random <= 5) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaL(i * 40, j * 40));
                        } else if (random <= 8 && random >= 6) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaS(i * 40, j * 40));
                        } else {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaV(i * 40, j * 40));
                        } // Else
                    } // If Interno
                } // If externo

                if (i == 30 && j > 40) {
                    if (this.casilla(i)(j + 1) != null && this.casilla(i - 1)(j + 1) != null
                            && this.casilla(i - 1)(j) != null) {
                        int random = (int) (Math.random() * 10);

                        if (random >= 0 && random <= 5) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaL(i * 40, j * 40));
                        } else if (random <= 8 && random >= 6) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaS(i * 40, j * 40));
                        } else {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaV(i * 40, j * 40));

                        } // Else
                    } // If Interno
                } // If externo

                if (i == 30 && j == 40) {
                    if (this.casilla(i - 1)(j) != null && this.casilla(i - 1)(j - 1) != null
                            && this.casilla(i)(j - 1) != null) {
                        int random = (int) (Math.random() * 10);

                        if (random >= 0 && random <= 5) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaL(i * 40, j * 40));
                        } else if (random <= 8 && random >= 6) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaS(i * 40, j * 40));
                        } else {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaV(i * 40, j * 40));
                        } // Else
                    } // If interno
                } // If externo

                if (i > 0 && j > 0 && this.casilla(i)(j) == null && i < 29 && j < 39) {
                    if (this.casilla(i - 1)(j) != null && this.casilla(i - 1)(j - 1) != null
                            && this.casilla(i)(j - 1) != null
                            || this.casilla(i - 1)(j + 1) != null && this.casilla(i)(j + 1) != null
                                    && this.casilla(i - 1)(j) != null
                            || this.casilla(i)(j - 1) != null && this.casilla(i + 1)(j - 1) != null
                                    && this.casilla(i + 1)(j) != null
                            || this.casilla(i)(j + 1) != null && this.casilla(i + 1)(j + 1) != null
                                    && this.casilla(i + 1)(j) != null) {
                        int random = (int) (Math.random() * 10);

                        if (random >= 0 && random <= 5) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaL(i * 40, j * 40));
                        } else if (random <= 8 && random >= 6) {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaS(i * 40, j * 40));
                        } else {
                            casilla(i)(j) = new Casilla();
                            this.casilla(i)(j).setEnemigo(new CepaV(i * 40, j * 40));
                        } // Else
                    } // If
                } // If
            } // For j
        } // For i
    } // Método para reproducir virus

Ese método que acabo de adjuntar está en otra clase quiero que la use cada 20 seg pero no sé como en el actionsperfomer ya la puse, pero ahora qué debo hacer?

javascript – contruir um timer para desligar um rele em java script

ola.. estou construindo um projeto iot em java e gostaria de de desligar um rele automaticamente 10 segundos apos ligado..

function handleDevice(agent) {
const get = agent.parameters.get;
const device = agent.parameters.device;
const status = agent.parameters.status;
if(device && status){
var newStatus;
if(status == ‘on’)
newStatus=“on”;
else
newStatus=“off”;

nfc – How is the timer implemented in mutual distance-bounding protocols?

I’ve come across several papers introducing the concept of mutual distance-bounding, where basically both sides can verify an upper bound of the distance in between, rather than having this unilateral relationship between a verifier and a prover. Although promising, these papers do not address the fact that in relay attacks the prover is usually an NFC capable card or chip. My question is, how can we implement a timer on this card to actually perform mutual distance-bounding protocols?

For reference, see Mutual Distance Bounding Protocols and SECTOR: Secure Tracking of Node Encounters in Multi-hop Wireless Networks.

This is a follow up question for this but in a broader context.

javascript – {LARAVEL} How to Create a timer for claim reward?

My Name is Adhetya – I’m making a new project related to games in Laravel.
I want to ask if anyone here understands or has ever made a project about a game?
First thing is, I want to make rewards every hour using laravel.

I have implemented a simple countdown with javascript and database queries.

This javascript I use:
var countDownDate = new Date(“{!! $rewards !!}”).getTime();

                           var x = setInterval(function() {
                            var now = new Date().getTime();
                               var distance = countDownDate - now;
                               var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                                var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                                var seconds = Math.floor((distance % (1000 * 60)) / 1000);
                               var confirmButton = document.getElementById("bonus");
                               confirmButton.innerHTML = hours + " Hours " + minutes + " Minutes " + seconds + " Second Later";
                               if (distance < 0) {
                                   clearInterval(x);
                                   confirmButton.className = "btn btn-success btn-raised btn-lg";
                                   confirmButton.innerHTML = "Claim Now! <i class='fad fa-check-double'>";
                                   confirmButton.setAttribute('href','{{route('userDailyBonus')}}');
                               }
                           }, 1000);
                       </script>

Just info, $rewards
is what I took from the query $ user->bonus
$user->bonus
is a query that is intended so that members can only claim at that time.
I’m validated this with ($user->bonus < $now )
Are there other ways to help me and be more effective?

Thank you

memory optimization – How can this VHDL code for a 64-bit timer be improved to use less resources?

I have code for a 64-bit timer register which can take in a 32-bit slice and depending on the inputs, place the slice in the high side or the low side, or increment the counter.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity CSR_TIMER is
    Port ( clk : in STD_LOGIC;
           reset: in STD_LOGIC := '0';
           DATA_IN : in STD_LOGIC_VECTOR (31 downto 0);
           EN_WRITE_LOW : in STD_LOGIC;
           EN_WRITE_HIGH : in STD_LOGIC;
           DATA_LOW_OUT : out STD_LOGIC_VECTOR (31 downto 0);
           DATA_HIGH_OUT : out STD_LOGIC_VECTOR (31 downto 0));
end CSR_TIMER;

architecture Behavioral of CSR_TIMER is
    signal clock,clock_next : unsigned(63 downto 0) := x"0000000000000000";
begin
    clock_next <=
    x"0000000000000000"                     when (reset = '1') else
    clock(63 downto 32) & unsigned(DATA_IN) when (EN_WRITE_LOW = '1') else
    unsigned(DATA_IN) & clock(31 downto 0)  when (EN_WRITE_HIGH = '1') else
    clock+1;
    
    DATA_LOW_OUT <=
    std_logic_vector(clock(31 downto 0));
    
    DATA_HIGH_OUT <=
    std_logic_vector(clock(63 downto 32));

    process(clk)
    begin
        if(rising_edge(clk)) then
            clock<=clock_next;
        end if;
    end process;

end Behavioral;

The trouble that I’m having is that the timer takes up too many physical resources, and I’m looking to shrink it down. This is for a RISC-V Processor where the ISA specifies that a proper processor has 32 of these timers, which is 2kb of on-board memory, and is not friendly to any FPGA. The Data_Low_out and data_high_out are connected to a mux, where they are treated as separate registers at different addresses.

How can I optimize this timer ( or a group of 32 timers ) to reduce the physical resource usage? This is synthesized using Vivado 2020.1.

iphone – Is it possible to see the running timer on the lock screen in iOS 14?

In iOS 13, a running timer was shown on the lock screen, so picking up your iPhone was enough to quickly see the remaining time without needing to unlock it:

enter image description here

In iOS 14.0.1 this feature is gone, so in order to see the remaining time on a timer you need to unlock your iPhone, find the Clock app, and switch to the Timers tab.

Is it possible to see the remaining time on the lock screen in iOS 14?

custom post types – How to create a redirect page with timer and download a file

I’ve been working on this trick that I want to apply and after having a research everywhere I couldn’t find the solution to this. I have even tried using some Download Plugins but I also don’t want to achieve this with any Plugin.

So I have a blog post that contains a Download link to a file. I want to add the Download button into a post and once a user click the button, it should redirect to another page(Custom Download Page with some Ads or Text) and the download should start after 5 or 10 seconds automatically. Now I don’t want the download link to have any Slug or Id in it and it should look like this. test.com/download . I have seen some websites using this. If anyone can help me I will appreciate.
Thanks

Nikon p900 Bracketing and Timer

I have a Nikon p900. I want to use bracketed exposures along with either a timer or remote shutter. Activating anything off the timer menu, either a 2 second timer or selecting the shutter remote turns off bracketing. Is there really no way to use bracketing with a timer or remote? Thanks

UCCW/Tasker: Display system timer – Android Enthusiasts Stack Exchange

I have an Samsung Galaxy S9 plus Default ROM but rooted.

I use my timer a lot with a default of 2.5 hours (medice req).
I have a nice UCCW theme customized to my specs.
I would love to have my timer displayed in there just like the clock. Is this possible in any form of way so I can display this with my UCCW skin ? (rebuilding the skin in KWGT is a option but not preferred.)

excel – Running Macro Using a Negative Timer Value

I have a timer in cell A1 that is populated by external software. Often it will go into negative time values.

I am trying to add a condition to a change event macro so that it runs only when the timer is less than 10:

ThisWorkbook.Worksheets("Timer").Range("A1").Value < TimeValue("00:10:00")

This works ok when the timer is between 00:10:00 and 00:00:00 but when it goes into negative values the macro stops running.

How do I change the condition so that it continues to run when the time goes negative?

Thanks