Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions Frogger/src/Cronometro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package frogger;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;

/**
*
* @author Fabio
*/
public class Cronometro {
private JFrame form;
private JLabel label;
private JPanel panelButtons;

private Timer timer;
private long startTime;
public Cronometro() {
form = new JFrame("Time");
form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
form.setSize(220, 140);
form.setResizable(false);

label = new JLabel("0:00:00.0");
label.setFont (new Font("SansSerif", Font.BOLD, 30));
label.setHorizontalAlignment(JLabel.CENTER);
panelButtons = new JPanel(new GridLayout(1, 2));
// panelButtons.add(buttonStart);
// panelButtons.add(buttonStop);
form.add(label, BorderLayout.CENTER);
form.add(panelButtons, BorderLayout.SOUTH);
timer = new Timer(100, new ActionListener() {
public void actionPerformed(ActionEvent e) {
long diffTime = System.currentTimeMillis() - startTime;
int decSeconds = (int)(diffTime % 1000 / 100);
int seconds = (int)(diffTime / 1000 % 60);
int minutes = (int)(diffTime / 60000 % 60);
int hours = (int)(diffTime / 3600000);
String s = String.format("%d:%02d:%02d.%d", hours, minutes, seconds, decSeconds);
label.setText(s);
}
});


form.setVisible (true);
}

public void inizio()

{

startTime = System.currentTimeMillis();
timer.start();

}

public void stop()
{
timer.stop();

}


}
6 changes: 6 additions & 0 deletions Frogger/src/Frog.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ public void draw(Graphics g)
g.setColor(COLOR);
g.fillOval(x-RADIUS, y-RADIUS, RADIUS*2, RADIUS*2);
}
public void drawLevel(Graphics g,int levelNumber)
{
String level="LEVEL "+levelNumber;
g.setColor(COLOR);
g.drawString(level,300,400);
}
}
21 changes: 21 additions & 0 deletions Frogger/src/Frogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package frogger;

/**
*
* @author Fabio
*/
public class Frogger {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}

}
Loading