做一个java时钟】

1.让她sleep一秒

2.抢红包的整个过程

1.红包数量

2。随机金额

3.计算剩余可以抢到的金额

#include<stdio.h>
void f(){
    f(n)=f()+f();
}
int main(){
    
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的JavaFX时钟示例代码: ```java import javafx.animation.Animation; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Line; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.util.Duration; import java.time.LocalTime; public class Clock extends Application { @Override public void start(Stage primaryStage) throws Exception { Group root = new Group(); Scene scene = new Scene(root, 400, 400, Color.WHITE); // 创建时钟圆盘 Circle circle = new Circle(200, 200, 150); circle.setFill(Color.WHITE); circle.setStroke(Color.BLACK); // 创建时钟刻度线 for (int i = 0; i < 12; i++) { Line line = new Line(200, 50, 200, 75); line.setStroke(Color.BLACK); line.setRotate(i * 30); root.getChildren().add(line); } // 创建时钟指针 Line hourHand = new Line(200, 200, 200, 100); hourHand.setStrokeWidth(5); hourHand.setStroke(Color.BLACK); Line minuteHand = new Line(200, 200, 200, 50); minuteHand.setStrokeWidth(3); minuteHand.setStroke(Color.BLACK); Line secondHand = new Line(200, 200, 200, 50); secondHand.setStrokeWidth(1); secondHand.setStroke(Color.RED); // 创建时钟数字 for (int i = 1; i <= 12; i++) { Text text = new Text(String.valueOf(i)); text.setFont(Font.font("Arial", 20)); text.setX(190 + 130 * Math.sin(i * Math.PI / 6)); text.setY(210 - 130 * Math.cos(i * Math.PI / 6)); root.getChildren().add(text); } // 创建时钟数字 Text text = new Text(175, 380, ""); text.setFont(Font.font("Arial", 20)); root.getChildren().add(text); // 创建时间轴 Timeline timeline = new Timeline( new KeyFrame(Duration.seconds(1), event -> { LocalTime now = LocalTime.now(); double hourAngle = (now.getHour() % 12 + now.getMinute() / 60.0) * 30; double minuteAngle = now.getMinute() * 6; double secondAngle = now.getSecond() * 6; hourHand.setRotate(hourAngle); minuteHand.setRotate(minuteAngle); secondHand.setRotate(secondAngle); text.setText(now.toString()); }) ); timeline.setCycleCount(Animation.INDEFINITE); timeline.play(); // 将时钟组件添加到根节点 root.getChildren().addAll(circle, hourHand, minuteHand, secondHand); primaryStage.setTitle("Clock"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } ``` 该程序的界面如下所示: ![时钟界面](https://img-blog.csdnimg.cn/20210308155005474.png) 通过 Timeline 类来更新时钟指针和时间数字,这里我们将时间轴的周期设置为1秒。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值