当前位置: 首页 > news >正文

好看的网站 你知道的2021产品营销方案案例范文

好看的网站 你知道的2021,产品营销方案案例范文,做网站的公司主要工作是什么,自己设置网站*16.7 (设置时钟的时间) 编写一个程序,显示一个时钟,并通过在三个文本域中输入小时、分钟和秒 钟来设置时钟的时间,如图16-38b 所示。使用程序清单14-21的ClockPane改变时钟大小使其居于面板中央 习题思路 实例化一个ClockPane(在程序清单1…
*16.7 (设置时钟的时间)

    编写一个程序,显示一个时钟,并通过在三个文本域中输入小时、分钟和秒 钟来设置时钟的时间,如图16-38b 所示。使用程序清单14-21的ClockPane改变时钟大小使其居于面板中央

  • 习题思路
  1. 实例化一个ClockPane(在程序清单14_21),创建一个HBox布局
  2. 新建三个Label和三个TextField,添加到HBox布局中
  3. 为三个TextField分别注册一个键盘事件,当在输入框中按下Enter键且内容不为空时, 调用ClockPane的设置时间的方法(如clockPane.setHour(hour))
  4. 创建一个BorderPane,把ClockPane设置在中心,把HBox设置在底部
  5. 创建Scene并运行代码
  •  代码示例

 编程练习题16_7SetClockTime.java

package chapter_16;import chapter_14.程序清单14_21ClockPane;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;public class 编程练习题16_7SetClockTime extends Application{@Overridepublic void start(Stage primaryStage) throws Exception {程序清单14_21ClockPane clockPane = new 程序清单14_21ClockPane();HBox hBox = new HBox(5);hBox.setPadding(new Insets(5, 5, 5, 5));hBox.setAlignment(Pos.CENTER);Label lbHour = new Label("Hour");TextField tfHour = new TextField();Label lbMinute = new Label("Minute");TextField tfMinute = new TextField();Label lbSecond = new Label("Second");TextField tfSecond = new TextField();tfHour.setPrefWidth(40);tfMinute.setPrefWidth(40);tfSecond.setPrefWidth(40);hBox.getChildren().addAll(lbHour,tfHour, lbMinute,tfMinute, lbSecond,tfSecond);tfHour.setOnKeyPressed(e ->{if(e.getCode() == KeyCode.ENTER&&tfHour.getText()!="") {int hour = Integer.parseInt(tfHour.getText());clockPane.setHour(hour);}});tfMinute.setOnKeyPressed(e ->{if(e.getCode() == KeyCode.ENTER&&tfMinute.getText()!="") {int minute = Integer.parseInt(tfMinute.getText());clockPane.setMinute(minute);}});tfSecond.setOnKeyPressed(e ->{if(e.getCode() == KeyCode.ENTER&&tfSecond.getText()!="") {int second = Integer.parseInt(tfSecond.getText());clockPane.setSecond(second);}});BorderPane borderPane = new BorderPane();borderPane.setCenter(clockPane);borderPane.setBottom(hBox);Scene scene = new Scene(borderPane,268, 300);primaryStage.setTitle("编程练习题16_7SetClockTime");primaryStage.setScene(scene);primaryStage.show();}public static void main(String[] args) {Application.launch(args);}
}

程序清单14_21ClockPane.java 

package chapter_14;import java.util.Calendar;
import java.util.GregorianCalendar;import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.text.Text;public class 程序清单14_21ClockPane extends Pane{private int hour;private int minute;private int second;private boolean hourHandVisible = true;private boolean minuteHandVisible = true;private boolean secondHandVisible = true;private double w = 250,h = 250;public 程序清单14_21ClockPane() {setCurrentTime();}public 程序清单14_21ClockPane(int hour) {this.hour = hour;minute = 0;paintClock();}public 程序清单14_21ClockPane(int hour, int minute) {this.hour = hour;this.minute = minute;second = 0;paintClock();}public 程序清单14_21ClockPane(int hour, int minute, int second) {this.hour = hour;this.minute = minute;this.second = second;paintClock();}public int getHour() {return hour;}public void setHour(int hour) {this.hour = hour;paintClock();}public int getMinute() {return minute;}public void setMinute(int minute) {this.minute = minute;paintClock();}public int getSecond() {return second;}public void setSecond(int second) {this.second = second;paintClock();}public double getW() {return w;}public void setW(double w) {this.w = w;paintClock();}public double getH() {return h;}public void setH(double h) {this.h = h;paintClock();}public boolean getHourHandVisible() {return hourHandVisible;}public boolean getMinuteHandVisible() {return minuteHandVisible;}public boolean getSecondHandVisible() {return secondHandVisible;}public void setHourHandVisible(boolean hourHandVisible) {this.hourHandVisible = hourHandVisible;paintClock();}public void setMinuteHandVisible(boolean minuteHandVisible) {this.minuteHandVisible = minuteHandVisible;paintClock();}public void setSecondHandVisible(boolean secondHandVisible) {this.secondHandVisible = secondHandVisible;paintClock();}public void setCurrentTime() {Calendar calendar = new GregorianCalendar();this.hour = calendar.get(Calendar.HOUR_OF_DAY);this.minute = calendar.get(Calendar.MINUTE);this.second = calendar.get(Calendar.SECOND);paintClock();}protected void paintClock() {double clockRadius = Math.min(w, h) * 0.8 * 0.5;double centerX = w / 2;double centerY = h / 2;Circle circle = new Circle(centerX, centerY, clockRadius);circle.setFill(Color.WHITE);circle.setStroke(Color.BLACK);double sLength = clockRadius * 0.8;double sencondX = centerX + sLength * Math.sin(second * (2*Math.PI/60));double sencondY = centerY - sLength * Math.cos(second * (2*Math.PI/60));Line sLine = new Line(centerX, centerY, sencondX, sencondY);sLine.setStroke(Color.RED);double mLength = clockRadius * 0.65;double xMinute = centerX + mLength * Math.sin(minute * (2 * Math.PI / 60));double minuteY = centerY - mLength * Math.cos(minute * (2 * Math.PI / 60));Line mLine = new Line(centerX, centerY, xMinute, minuteY);mLine.setStroke(Color.BLUE);double hLength = clockRadius * 0.5;double hourX = centerX + hLength *Math.sin((hour % 12+minute/60.0) * (2*Math.PI / 12));double hourY = centerY - hLength * Math.cos((hour % 12 + minute / 60.0) * (2 * Math.PI / 12));Line hLine = new Line(centerX, centerY, hourX, hourY);hLine.setStroke(Color.GREEN);getChildren().clear();getChildren().add(circle);if(getHourHandVisible()==true) {getChildren().add(hLine);}if (getMinuteHandVisible()==true) { getChildren().add(mLine);}if(getSecondHandVisible()==true) {getChildren().add(sLine);}for(int i = -90;i < 270;i+=30) {double angle = Math.toRadians(i);double x = centerX-2 + (clockRadius-20) * Math.cos(angle); double y = centerY+3 + (clockRadius-20) * Math.sin(angle);double LineX = centerX-7 + (clockRadius-7) * Math.cos(angle); double LineY = centerY+4 + (clockRadius-7) * Math.sin(angle);int time = i/30+3;if(time == 0)time = 12;Text t = new Text(x,y,time+"");Text line = new Text(LineX,LineY,"—");line.setRotate(i);getChildren().add(t);getChildren().add(line);}for(int i = -90;i < 270;i+=6) {double angle = Math.toRadians(i);double LineX = centerX-3  + (clockRadius-3) * Math.cos(angle); double LineY = centerY+4.5 + (clockRadius-2.5) * Math.sin(angle);Text line = new Text(LineX,LineY,"-");line.setRotate(i);getChildren().add(line);}}
}
  • 结果展示

http://www.yayakq.cn/news/47064/

相关文章:

  • 做网站得多钱wordpress模版改版
  • 如何制作一个网址深圳关键词优化
  • 视频网站的建设预算班服定制网站
  • wordpress主题使用asp网站做seo
  • 网站开发公司赚钱么爱站长尾词
  • 秦皇岛网站团队wordpress4.1中文版
  • 刷leetcode对网站开发有用吗开淘宝店铺的详细步骤
  • 网站设计目的手机购物网站开发
  • 郑州机械网站建设wordpress文章末尾显示tag标签
  • 福州网站建设外贸网站不备案行吗
  • 网站服务器可以做家用电脑有没有做生物科技相关的网站
  • 专业做图片制作网站有哪些比较出名的游戏外包公司
  • 营销型网站建设的费用报价单发帖那个网站好 做装修的
  • 电子商务网站建设行情前端网站做完 后端用什么做
  • 做网站需要要多少钱科技强国向秦始皇直播四大发明
  • 城乡与建设厅网站办公空间设计说明
  • wordpress做出的网站WordPress黑镜主题下载
  • 阿里巴巴网站中详情页怎么做南宁制作网站企业
  • 移动互联网技术网站系统没有安装wordpress
  • 西安做网站科技有限公司海口有哪几家是做网站的
  • 轻媒做的网站正能量不良网站直接进入
  • 广州学校论坛网站建设app开发需要什么资源和团队
  • 名人网站设计版式佛山招收网站设计
  • 网站 备案 注销怎么制作小视频
  • 建网站需要哪些资质邵阳市建设局网站首页
  • 长春在线制作网站密码行业西部数据
  • golang和php 做网站海淘网站
  • 门户网站个人可以做专业外贸网站制作价格
  • 廊坊企业网站团队昌做网站
  • 无锡网站排名哪里有手机网站建设 技术规范