當前位置: 首頁>>代碼示例>>Java>>正文


Java Text.setText方法代碼示例

本文整理匯總了Java中javafx.scene.text.Text.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java Text.setText方法的具體用法?Java Text.setText怎麽用?Java Text.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.text.Text的用法示例。


在下文中一共展示了Text.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calculateClipString

import javafx.scene.text.Text; //導入方法依賴的package包/類
/**
 * Truncates text to fit into the EditableLabel
 *
 * @param text The text that needs to be truncated
 * @return The truncated text with an appended "..."
 */
private String calculateClipString(String text) {
    double labelWidth = editableLabel.getWidth();

    Text layoutText = new Text(text);
    layoutText.setFont(editableLabel.getFont());

    if (layoutText.getLayoutBounds().getWidth() < labelWidth) {
        return text;
    } else {
        layoutText.setText(text+"...");
        while ( layoutText.getLayoutBounds().getWidth() > labelWidth ) {
            text = text.substring(0, text.length()-1);
            layoutText.setText(text+"...");
        }
        return text+"...";
    }
}
 
開發者ID:vibridi,項目名稱:fxutils,代碼行數:24,代碼來源:EditableLabelSkin.java

示例2: setupView

import javafx.scene.text.Text; //導入方法依賴的package包/類
private void setupView() {
    ImageView weatherIcon = new ImageView();
    weatherIcon.setImage(weatherEvent.getForecast().getWeather().getIcon());
    weatherIcon.fitWidthProperty().bind(stage.widthProperty().divide(3));
    weatherIcon.fitHeightProperty().bind(stage.heightProperty().multiply(1));
    GridPane.setHgrow(weatherIcon, Priority.ALWAYS);
    GridPane.setVgrow(weatherIcon, Priority.ALWAYS);
    GridPane.setHalignment(weatherIcon, HPos.CENTER);
    GridPane.setValignment(weatherIcon, VPos.CENTER);
    add(weatherIcon, 0, 0);

    Text txt_weather_event = new Text();
    txt_weather_event.setText(controller.getWeatherEventText());
    GridPane.setHgrow(txt_weather_event, Priority.ALWAYS);
    GridPane.setVgrow(txt_weather_event, Priority.ALWAYS);
    GridPane.setValignment(txt_weather_event, VPos.CENTER);
    add(txt_weather_event, 1, 0);
}
 
開發者ID:ykarim,項目名稱:WeatherWatch,代碼行數:19,代碼來源:NotificationPane.java

示例3: createText

import javafx.scene.text.Text; //導入方法依賴的package包/類
/**
 * Ritorna il crea il componente grafico testo utilizzando la stringa passata come parametro
 * @param s testo da visualizzare
 * @return testo creato come componente grafico.
 */
private Text createText(String s) {
	Text t = new Text();
	
	t.setText(s);
	t.setFont(new Font(16));
	t.setBoundsType(TextBoundsType.VISUAL);
	t.setStroke(Color.BLACK);
	this.centerText(t);
	
	return t;
}
 
開發者ID:steppp,項目名稱:Breadth-First-Search,代碼行數:17,代碼來源:GraphDrawer.java

示例4: TimelineEventsSample

import javafx.scene.text.Text; //導入方法依賴的package包/類
public TimelineEventsSample() {
    super(70,70);
    //create a circle with effect
    final Circle circle = new Circle(20,  Color.rgb(156,216,255));
    circle.setEffect(new Lighting());
    //create a text inside a circle
    final Text text = new Text (i.toString());
    text.setStroke(Color.BLACK);
    //create a layout for circle with text inside
    final StackPane stack = new StackPane();
    stack.getChildren().addAll(circle, text);
    stack.setLayoutX(30);
    stack.setLayoutY(30);

    //create a timeline for moving the circle

    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //one can add a specific action when each frame is started. There are one or more frames during
    // executing one KeyFrame depending on set Interpolator.
    timer = new AnimationTimer() {
        @Override
        public void handle(long l) {
            text.setText(i.toString());
            i++;
        }

    };

    //create a keyValue with factory: scaling the circle 2times
    KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2);
    KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2);

    //create a keyFrame, the keyValue is reached at time 2s
    Duration duration = Duration.seconds(2);
    //one can add a specific action when the keyframe is reached
    EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
             stack.setTranslateX(java.lang.Math.random()*200-100);
             //reset counter
             i = 0;
        }
    };

    KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY);

    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);

    getChildren().add(stack);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:54,代碼來源:TimelineEventsSample.java

示例5: createScene

import javafx.scene.text.Text; //導入方法依賴的package包/類
private static Scene createScene() {
  Group root = new Group();
  Scene scene = new Scene(root, javafx.scene.paint.Color.ALICEBLUE);
  Text text = new Text();

  text.setX(40);
  text.setY(100);
  text.setFont(new javafx.scene.text.Font(25));
  text.setText("JavaFX Window!");

  root.getChildren().add(text);

  return (scene);
}
 
開發者ID:mshareghi,項目名稱:arcgis-javafx-sample-addin,代碼行數:15,代碼來源:JavaFXDockableWindow.java

示例6: getCouponResultDialog

import javafx.scene.text.Text; //導入方法依賴的package包/類
private Dialog getCouponResultDialog(Stage owner) {
    Dialog dialog = null;
    try {
        FXMLLoader loader = new FXMLLoader(
                getClass().getResource("/View/CouponResult.fxml")
        );
        dialog = new Dialog();
        dialog.setResizable(false);
        dialog.setDialogPane(loader.load());
        dialog.initOwner(owner);
        dialog.initModality(Modality.WINDOW_MODAL);
        dialog.initStyle(StageStyle.UTILITY);

        // Add button to dialog
        ButtonType buttonTypeOk = new ButtonType("확인", ButtonBar.ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
        GridPane grid = (GridPane) dialog.getDialogPane().getContent();
        Text couponNumberField = new Text();
        couponNumberField.setText(getCouponNumber(selectedCoupon));
        Text couponPriceField = new Text();
        couponPriceField.setText(String.valueOf(selectedCoupon));
        grid.add(couponNumberField, 0, 1);
        grid.add(couponPriceField, 0, 3);

    } catch (IOException e) {
        System.out.println("Unable to load dialog FXML");
        e.printStackTrace();
    }
    return dialog;
}
 
開發者ID:Jinsu-L,項目名稱:CNU_TermProject_SoftwareEngineering,代碼行數:31,代碼來源:CouponController.java

示例7: licencesp

import javafx.scene.text.Text; //導入方法依賴的package包/類
private ScrollPane licencesp(double width, double height) {

        ScrollPane sp = new ScrollPane();

        Text text = new Text();

        text.setX(width * 0.1);
        text.setY(height * 0.1);
        text.setFont(new Font(20));

        text.setFill(new Color(1, 1, 1, 1));

        StringBuilder licence = new StringBuilder(10000);
        String line;

        try {
            BufferedReader br = new BufferedReader(new FileReader("data/common/licence.txt"));

            while ((line = br.readLine()) != null) {
                licence.append('\n');
                licence.append(line);
            }
            br.close();
        } catch (IOException e) {
            log.error("Exception", e);
        }

        text.setText(licence.toString());

        sp.setContent(text);
        sp.setFitToHeight(true);
        sp.setFitToWidth(true);
        sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        sp.setVmax(height);
        // sp.setPrefSize(width*0.8, height*0.8);

        return sp;

    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:40,代碼來源:License.java

示例8: configureBox

import javafx.scene.text.Text; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
	StackPane container = new StackPane();
	//container.setPrefHeight(700);
	container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
	container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");

	table= new TableView<AttClass>();
	Label lview= new Label();
	lview.setText("View Records");
	lview.setId("lview");
	bottomPane= new VBox();

	tclock= new Text(); 
	tclock.setId("lview");
	//tclock.setFont(Font.font("Calibri", 20));
	final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {  
		@Override  
		public void handle(ActionEvent event) {  
			tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
		}  
	}));  
	timeline.setCycleCount(Animation.INDEFINITE);  
	timeline.play();

	bottomPane.getChildren().addAll(tclock,lview);
	bottomPane.setAlignment(Pos.CENTER);

	//table pane
	namecol= new TableColumn<>("First Name");
	namecol.setMinWidth(170);
	namecol.setCellValueFactory(new PropertyValueFactory<>("name"));

	admcol= new TableColumn<>("Identication No.");
	admcol.setMinWidth(180);
	admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));

	typecol= new TableColumn<>("Type");
	typecol.setMinWidth(130);
	typecol.setCellValueFactory(new PropertyValueFactory<>("type"));

	timecol= new TableColumn<>("Signin");
	timecol.setMinWidth(140);
	timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));

	datecol= new TableColumn<>("Date");
	datecol.setMinWidth(180);
	datecol.setCellValueFactory(new PropertyValueFactory<>("date"));

	table.getColumns().addAll(namecol, admcol, typecol, timecol, datecol);
	table.setItems(getAtt());
	att= getAtt();
	table.setItems(FXCollections.observableArrayList(att));
	table.setMinHeight(500);

	btnrefresh = new Button("Refresh");
	btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
		public void handle(ActionEvent t) {
			table.setItems(getAtt());
		}
	});
	laytable= new VBox(10);
	laytable.getChildren().addAll(table, btnrefresh);
	laytable.setAlignment(Pos.TOP_LEFT);

	container.getChildren().addAll(bottomPane,laytable);
	setAnimation();
	sc.setContent(container);
	root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
	root.getChildren().addAll(getActionPane(),sc);

	//service.start();
}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:74,代碼來源:AllAttendance.java

示例9: configureBox

import javafx.scene.text.Text; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
	  StackPane container = new StackPane();
	  //container.setPrefHeight(700);
	  container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
	  container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");

	 table= new TableView<OfficeClass>();
	  Label lview= new Label();
	  lview.setText("View Records");
	  lview.setId("lview");
	  bottomPane= new VBox();
	  
	  tclock= new Text(); 
	  tclock.setId("lview");
		//tclock.setFont(Font.font("Calibri", 20));
		final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {  
		     @Override  
		     public void handle(ActionEvent event) {  
		          tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
		     }  
		}));  
		timeline.setCycleCount(Animation.INDEFINITE);  
		timeline.play();
	  
	  bottomPane.getChildren().addAll(tclock, lview);
	  bottomPane.setAlignment(Pos.CENTER);
	  
	  nocol= new TableColumn<>("no");
	  nocol.setMinWidth(130);
	  nocol.setCellValueFactory(new PropertyValueFactory<>("no"));
		
	  
	  namecol= new TableColumn<>("First Name");
		namecol.setMinWidth(170);
		namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
		
		admcol= new TableColumn<>("Admission Number");
		admcol.setMinWidth(180);
		admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
		
		
		timecol= new TableColumn<>("Signin");
		timecol.setMinWidth(140);
		timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
		
		datecol= new TableColumn<>("Date");
		datecol.setMinWidth(180);
		datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
		
		table.getColumns().addAll(nocol,namecol, admcol, timecol, datecol);
		table.setItems(getAtt());
		att= getAtt();
        table.setItems(FXCollections.observableArrayList(att));
        table.setMinHeight(500);
       
        btnrefresh = new Button("Refresh");
        btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent t) {
            	table.setItems(getAtt());
            }
        });
        laytable= new VBox(10);
        laytable.getChildren().addAll(table, btnrefresh);
        laytable.setAlignment(Pos.TOP_LEFT);
        
        container.getChildren().addAll(bottomPane,laytable);
		setAnimation();
		sc.setContent(container);
		root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
		root.getChildren().addAll(getActionPane(),sc);
		
		//service.start();
	 }
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:75,代碼來源:Office_Entry.java

示例10: updateItem

import javafx.scene.text.Text; //導入方法依賴的package包/類
@Override
protected void updateItem(UserInfo item, boolean empty) {
	// TODO Auto-generated method stub
	super.updateItem(item, empty);
	setGraphic(null);
          setText(null);
          if (item != null) {

              HBox hBox = new HBox();
              hBox.setSpacing(5); //節點之間的間距

           Text name = new Text(item.getUsername());
           name.setFont(new Font("Arial", 20));//字體樣式和大小
           ImageView statusImageView = new ImageView();
           Image statusImage = new Image("images/online.png", 16, 16,true,true);
           statusImageView.setImage(statusImage);

           if(item.getUsername().equals(Utils.ALL)){

           	name.setText("group chat >");
           	statusImageView.setImage(null);
           	//hBox.setStyle("-fx-background-color: #336699;"); //背景色

           }
           ImageView pictureImageView = new ImageView();
           Image image = new Image("images/" + item.getUserpic(),50,50,true,true);
           pictureImageView.setImage(image);

           hBox.getChildren().addAll(statusImageView, pictureImageView, name);
           //hBox.getChildren().addAll(pictureImageView, name);
           hBox.setAlignment(Pos.CENTER_LEFT);
           setGraphic(hBox);
          }
}
 
開發者ID:Laity000,項目名稱:ChatRoom-JavaFX,代碼行數:35,代碼來源:ChatController.java

示例11: initInfoPanel

import javafx.scene.text.Text; //導入方法依賴的package包/類
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:80,代碼來源:Level.java

示例12: showCashPayProgress

import javafx.scene.text.Text; //導入方法依賴的package包/類
private void showCashPayProgress() {
    Dialog payDialog = getPayProgressDialog();
    GridPane grid = (GridPane) dialog.getDialogPane().getContent();

    TextField pay = (TextField) grid.lookup("#payPrice");
    Text remind = (Text) grid.lookup("#remind");
    remind.setText(String.valueOf(totalPrice - paidPrice));

    ButtonType closeButton = new ButtonType("취소", ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType OkButton = new ButtonType("결제", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(closeButton, OkButton);

    // Result converter for dialog
    /* Todo 단순 취소, 결제 성공, 결제 금액 이상 나누어서 처리할 수 있어야함 */
    dialog.setResultConverter(param -> {
        if (param != closeButton) {
            int money = 0;
            try {
                money = Integer.parseInt(pay.getText());
            }catch(NumberFormatException e){
                alert("에러메시지","숫자 외 문자 입력");
                return "결제 금액 이상";
            }
            if(money == 0){
                alert("에러메시지", "숫자 0 입력");
                return "결제 금액 이상";
            }
            if(money > (totalPrice - paidPrice))
                money = totalPrice - paidPrice;

            if (!PaymentMoney(money)) {
                return "결제 금액 이상";
            }
            if (paidPrice == totalPrice)
                paymentStatus = false;
            return "성공";
        }
        return "닫기";
    });

    Optional option = payDialog.showAndWait();
    System.out.println(option.get());

}
 
開發者ID:Jinsu-L,項目名稱:CNU_TermProject_SoftwareEngineering,代碼行數:45,代碼來源:PaymentController.java

示例13: showCardPayProgress

import javafx.scene.text.Text; //導入方法依賴的package包/類
private void showCardPayProgress() {
    Dialog payDialog = getPayProgressDialog();
    GridPane grid = (GridPane) dialog.getDialogPane().getContent();

    TextField pay = (TextField) grid.lookup("#payPrice");
    Text remind = (Text) grid.lookup("#remind");
    remind.setText(String.valueOf(totalPrice - paidPrice));
    Label label = (Label) grid.lookup("#Label");
    label.setText("카드 번호");
    label.setVisible(true);
    TextField input = (TextField) grid.lookup("#input");
    input.setPromptText("카드 번호 입력");
    input.setVisible(true);

    ButtonType closeButton = new ButtonType("CANCEL", ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType OkButton = new ButtonType("결제", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(closeButton, OkButton);

    // Result converter for dialog
    /* Todo 단순 취소, 결제 성공, 결제 금액 이상 나누어서 처리할 수 있어야함 */
    dialog.setResultConverter(param -> {
        if (param != closeButton) {
            int money = 0;
            try {
                money = Integer.parseInt(pay.getText());
            }catch(NumberFormatException e){
                alert("에러메시지","숫자 외 문자 입력");
                return "결제 금액 이상";
            }
            if(money == 0){
                alert("에러메시지", "숫자 0 입력");
                return "결제 금액 이상";
            }
            if(money > (totalPrice - paidPrice))
                money = totalPrice - paidPrice;

            if (!PaymentCard(money, input.getText()))
                return "결제 금액 이상";
            if (paidPrice == totalPrice)
                paymentStatus = false;
            return "성공";
        }
        return "닫기";
    });

    Optional option = payDialog.showAndWait();
    System.out.println(option.get());

}
 
開發者ID:Jinsu-L,項目名稱:CNU_TermProject_SoftwareEngineering,代碼行數:50,代碼來源:PaymentController.java

示例14: showCouponPayProgress

import javafx.scene.text.Text; //導入方法依賴的package包/類
private void showCouponPayProgress() {
    Dialog payDialog = getPayProgressDialog();
    GridPane grid = (GridPane) dialog.getDialogPane().getContent();

    TextField pay = (TextField) grid.lookup("#payPrice");
    Text remind = (Text) grid.lookup("#remind");
    remind.setText(String.valueOf(totalPrice - paidPrice));
    Label label = (Label) grid.lookup("#Label");
    label.setText("쿠폰 번호");
    label.setVisible(true);
    TextField input = (TextField) grid.lookup("#input");
    input.setVisible(true);
    input.setPromptText("쿠폰 번호 입력");

    ButtonType closeButton = new ButtonType("CANCEL", ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType OkButton = new ButtonType("결제", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(closeButton, OkButton);

    // Result converter for dialog
    /* Todo 단순 취소, 결제 성공, 결제 금액 이상 나누어서 처리할 수 있어야함 */
    dialog.setResultConverter(param -> {
        if (param != closeButton) {
            int money = 0;
            try {
                money = Integer.parseInt(pay.getText());
            }catch(NumberFormatException e){
                alert("에러메시지","숫자 외 문자 입력");
                return "결제 금액 이상";
            }
            if(money == 0){
                alert("에러메시지", "숫자 0 입력");
                return "결제 금액 이상";
            }
            if(money > (totalPrice - paidPrice))
                money = totalPrice - paidPrice;
            int result=PaymentCoupon(money, input.getText());
            if (result==1) {
                alert("에러메시지","쿠폰 번호 조회 불가");
                return "결제 금액 이상";
            }else if (result==2) {
                alert("에러메시지","쿠폰 잔액 부족");
                return "결제 금액 이상";
            }
            if (paidPrice == totalPrice)
                paymentStatus = false;
            return "성공";
        }
        return "닫기";
    });

    Optional option = payDialog.showAndWait();
    System.out.println(option.get());

}
 
開發者ID:Jinsu-L,項目名稱:CNU_TermProject_SoftwareEngineering,代碼行數:55,代碼來源:PaymentController.java

示例15: addGuiElements

import javafx.scene.text.Text; //導入方法依賴的package包/類
private void addGuiElements() {
    if (controller.getWeatherBackgroundClass() != null) {
        gridPane.setId(controller.getWeatherBackgroundClass());
    }

    weatherIconView = new ImageView(controller.getWeatherIcon() != null ?
            controller.getWeatherIcon() : fileLoad.loadImageFile(NO_IMAGE_LOCATION));
    weatherIconView.fitWidthProperty().bind(stage.widthProperty().divide(3));
    weatherIconView.fitHeightProperty().bind(stage.heightProperty().divide(2));
    GridPane.setHgrow(weatherIconView, Priority.ALWAYS);
    GridPane.setHalignment(weatherIconView, HPos.CENTER);
    GridPane.setVgrow(weatherIconView, Priority.ALWAYS);
    GridPane.setValignment(weatherIconView, VPos.CENTER);
    gridPane.add(weatherIconView, 0, 0);

    GridPane gridPane_conditions = new GridPane();
    gridPane_conditions.setHgap(10);
    gridPane_conditions.setVgap(10);
    GridPane.setHgrow(gridPane_conditions, Priority.ALWAYS);
    GridPane.setHalignment(gridPane_conditions, HPos.CENTER);
    GridPane.setVgrow(gridPane_conditions, Priority.ALWAYS);
    GridPane.setValignment(gridPane_conditions, VPos.TOP);
    gridPane.add(gridPane_conditions, 1, 0);

    txt_temperature = new Text();
    txt_temperature.setText(controller.getCurrentWeatherTemperatureText());
    txt_temperature.setFont(new Font(48));
    txt_temperature.setStyle("-fx-font-weight: bold");
    GridPane.setHgrow(txt_temperature, Priority.ALWAYS);
    GridPane.setHalignment(txt_temperature, HPos.LEFT);
    GridPane.setVgrow(txt_temperature, Priority.ALWAYS);
    GridPane.setValignment(txt_temperature, VPos.TOP);
    gridPane_conditions.add(txt_temperature, 0, 0);

    txt_condition = new Text();
    txt_condition.setText(controller.getCurrentWeatherConditionText());
    txt_condition.setFont(new Font(24));
    GridPane.setHgrow(txt_condition, Priority.ALWAYS);
    GridPane.setHalignment(txt_condition, HPos.LEFT);
    GridPane.setVgrow(txt_condition, Priority.ALWAYS);
    GridPane.setValignment(txt_condition, VPos.TOP);
    gridPane_conditions.add(txt_condition, 0, 1);

    btn_edit_settings = new Button();
    ImageView imgView = new ImageView(fileLoad.loadImageFile(EDIT_ICON_LOCATION));
    btn_edit_settings.setGraphic(imgView);
    GridPane.setHgrow(btn_edit_settings, Priority.ALWAYS);
    GridPane.setHalignment(btn_edit_settings, HPos.RIGHT);
    GridPane.setVgrow(btn_edit_settings, Priority.ALWAYS);
    GridPane.setValignment(btn_edit_settings, VPos.TOP);
    gridPane.add(btn_edit_settings, 2, 0);

    btn_edit_settings.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            SettingsPage settingsPage = new SettingsPage(gridPane, stage);
            stage.getScene().setRoot(settingsPage.getRootPane());
        }
    });

    ForecastsPane gridPane_forecasts = new ForecastsPane(stage);
    GridPane.setHgrow(gridPane_forecasts, Priority.ALWAYS);
    GridPane.setHalignment(gridPane_forecasts, HPos.CENTER);
    gridPane.add(gridPane_forecasts, 0, 1, 3, 1);
}
 
開發者ID:ykarim,項目名稱:WeatherWatch,代碼行數:66,代碼來源:WeatherPage.java


注:本文中的javafx.scene.text.Text.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。