List of usage examples for javafx.scene.layout Background Background
public Background(final @NamedArg("images") BackgroundImage... images)
From source file:jp.co.heppokoact.autocapture.FXMLDocumentController.java
/** * ???????????/* w ww. ja v a 2 s . c om*/ * ???????? * ???ESC???????? * * @return ??????? * @throws IOException ????? */ private Stage createTransparentStage() throws IOException { // ?????????? Stage transparentStage = new Stage(StageStyle.TRANSPARENT); transparentStage.initOwner(anchorPane.getScene().getWindow()); transparentStage.initModality(Modality.APPLICATION_MODAL); transparentStage.setResizable(false); Rectangle2D rect = Screen.getPrimary().getVisualBounds(); transparentStage.setWidth(rect.getWidth()); transparentStage.setHeight(rect.getHeight()); // ??? java.awt.Rectangle awtRect = new java.awt.Rectangle((int) rect.getWidth(), (int) rect.getHeight()); BufferedImage captureImage = robot.createScreenCapture(awtRect); // ?????? ByteArrayInputStream in = ImageUtil.convToInputStream(captureImage); BackgroundImage bgImage = new BackgroundImage(new Image(in), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT); Pane pane = new Pane(); pane.setBackground(new Background(bgImage)); pane.setStyle("-fx-border-color: rgba(255, 255, 0, 0.5); -fx-border-style: solid; -fx-border-width: 15;"); // ???ESC????? Scene scene = new Scene(pane); transparentStage.setScene(scene); scene.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ESCAPE) { transparentStage.close(); } }); return transparentStage; }
From source file:gov.va.isaac.gui.ConceptNode.java
/** * If, for some reason, you want a concept node selection box that is completely disabled - call this method after constructing * the concept node. Though one wonders, why you wouldn't just use a label in this case.... *///from w w w. j a va 2s . c o m public void disableEdit() { AppContext.getService(DragRegistry.class).removeDragCapability(cb_); cb_.setEditable(false); dropDownOptions_.removeListener(listChangeListener_); listChangeListener_ = null; cb_.setItems(FXCollections.observableArrayList()); cb_.setBackground(new Background(new BackgroundFill(Color.LIGHTGRAY, new CornerRadii(0), new Insets(0)))); }
From source file:ui.main.MainViewController.java
private synchronized void paintDate(Chat chat, String day) { //this method draws the recievied text message Task<HBox> recievedMessages = new Task<HBox>() { @Override/*from w w w. j a v a 2 s . co m*/ protected HBox call() throws Exception { VBox vbox = new VBox(); //to add text //chat message Label l = new Label(day); l.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null))); HBox hbox = new HBox(); hbox.setAlignment(Pos.CENTER); hbox.getChildren().addAll(l); return hbox; } }; recievedMessages.setOnSucceeded(event -> { chatList.getChildren().add(recievedMessages.getValue()); }); if (chat.getParticipant().contains(currentChat.getParticipant())) { Thread t = new Thread(recievedMessages); try { t.join(); } catch (InterruptedException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } //t.setDaemon(true); t.start(); scrollPane.setVvalue(scrollPane.getHmax()); } }
From source file:ui.main.MainViewController.java
private synchronized void paintReceivedMessage(Chat chat, String msg, String time) { //this method draws the recievied text message Task<HBox> recievedMessages = new Task<HBox>() { @Override/*from www . j a va 2 s . c om*/ protected HBox call() throws Exception { VBox vbox = new VBox(); //to add text ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image imageRec.setFitHeight(60); imageRec.setFitWidth(50); String strChatterName = chat.getParticipant(); //add name of the chatter with light color strChatterName = Character.toUpperCase(strChatterName.charAt(0)) + strChatterName.substring(1, strChatterName.indexOf("@")); Label chatterName = new Label(strChatterName); chatterName.setDisable(true); Label timeL = new Label(time); timeL.setDisable(true); timeL.setFont(new Font("Arial", 10)); //chat message BubbledLabel bbl = new BubbledLabel(); bbl.setText(msg); bbl.setBackground(new Background(new BackgroundFill(Color.GAINSBORO, null, null))); vbox.getChildren().addAll(chatterName, bbl, timeL); vbox.setAlignment(Pos.CENTER_RIGHT); HBox hbox = new HBox(); bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER); hbox.getChildren().addAll(imageRec, vbox); return hbox; } }; recievedMessages.setOnSucceeded(event -> { chatList.getChildren().add(recievedMessages.getValue()); }); if (chat.getParticipant().contains(currentChat.getParticipant())) { Thread t = new Thread(recievedMessages); //t.setDaemon(true); t.start(); try { t.join(); } catch (InterruptedException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } scrollPane.setVvalue(scrollPane.getHmax()); } }
From source file:ui.main.MainViewController.java
private synchronized void paintWarningInRecieve(Chat chat, String Warning, String time) { //this method draws the recievied text message Task<HBox> recievedMessages = new Task<HBox>() { @Override//from w w w .ja v a2 s . co m protected HBox call() throws Exception { VBox vbox = new VBox(); //to add text ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image imageRec.setFitHeight(60); imageRec.setFitWidth(50); String strChatterName = chat.getParticipant(); //add name of the chatter with light color strChatterName = Character.toUpperCase(strChatterName.charAt(0)) + strChatterName.substring(1, strChatterName.indexOf("@")); Label chatterName = new Label(strChatterName); chatterName.setDisable(true); Label timeL = new Label(time); timeL.setDisable(true); timeL.setFont(new Font("Arial", 10)); //chat message BubbledLabel bbl = new BubbledLabel(); bbl.setText(Warning); bbl.setBackground(new Background(new BackgroundFill(Color.RED, null, null))); vbox.getChildren().addAll(chatterName, bbl, timeL); vbox.setAlignment(Pos.CENTER_RIGHT); HBox hbox = new HBox(); bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER); hbox.getChildren().addAll(imageRec, vbox); return hbox; } }; recievedMessages.setOnSucceeded(event -> { chatList.getChildren().add(recievedMessages.getValue()); scrollPane.setVvalue(scrollPane.getHmax()); scrollPane.setVvalue(scrollPane.getHmax()); }); if (chat.getParticipant().contains(currentChat.getParticipant())) { Thread t = new Thread(recievedMessages); t.start(); try { t.join(); } catch (InterruptedException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } //t.setDaemon(true); } }
From source file:ui.main.MainViewController.java
private synchronized void paintSendMessage(String msg, String time) { Task<HBox> recievedMessages = new Task<HBox>() { @Override//from w w w . j a v a2s . com protected HBox call() throws Exception { VBox vbox = new VBox(); //to add text ImageView imageRec = new ImageView(myAvatar.getImage()); imageRec.setFitHeight(60); imageRec.setFitWidth(50); Label myName = new Label(name.getText()); myName.setDisable(true); Label timeL = new Label(time); timeL.setDisable(true); timeL.setFont(new Font("Arial", 10)); BubbledLabel bbl = new BubbledLabel(); bbl.setText(msg); bbl.setBackground(new Background(new BackgroundFill(Color.LIGHTBLUE, null, null))); HBox hbox = new HBox(); hbox.setAlignment(Pos.TOP_RIGHT); bbl.setBubbleSpec(BubbleSpec.FACE_RIGHT_CENTER); vbox.getChildren().addAll(myName, bbl, timeL); hbox.getChildren().addAll(vbox, imageRec); return hbox; } }; recievedMessages.setOnSucceeded(event -> { chatList.getChildren().add(recievedMessages.getValue()); }); Thread t = new Thread(recievedMessages); t.setDaemon(true); t.start(); try { t.join(); } catch (InterruptedException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ui.main.MainViewController.java
private void paintConversationMessage(Message msg) { //this method draws the recievied text message Task<HBox> recievedMessages = new Task<HBox>() { @Override/* w ww . j a v a2s. com*/ protected HBox call() throws Exception { VBox vbox = new VBox(); //to add text String user = msg.getFrom(); user = user.substring(user.indexOf("/") + 1, user.length()); ImageView imageView = new ImageView(); //image imageView.setFitHeight(60); imageView.setFitWidth(50); VCard vcard = new VCard(); try { vcard.load(ConnectionManager.getConnectionManager().getXMPPConnection(), user.concat(AppData.serviceNameAt)); if (vcard.getAvatar() != null) { BufferedImage img = ImageIO.read(new ByteArrayInputStream(vcard.getAvatar())); Image image = SwingFXUtils.toFXImage(img, null); imageView.setImage(image); } else { Image defaultAvatar = new Image("resources/defaultAvatar.png", 50, 60, true, true); imageView.setImage(defaultAvatar); } } catch (XMPPException e) { Image defaultAvatar = new Image("resources/defaultAvatar.png", 50, 60, true, true); imageView.setImage(defaultAvatar); System.out.println(e); } Label chatterName = new Label(user); chatterName.setDisable(true); //chat message BubbledLabel bbl = new BubbledLabel(); bbl.setText(msg.getBody()); bbl.setBackground(new Background(new BackgroundFill(Color.GAINSBORO, null, null))); vbox.getChildren().addAll(chatterName, bbl); vbox.setAlignment(Pos.CENTER_RIGHT); HBox hbox = new HBox(); bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER); hbox.getChildren().addAll(imageView, vbox); return hbox; } }; recievedMessages.setOnSucceeded(event -> { chatList.getChildren().add(recievedMessages.getValue()); }); Thread t = new Thread(recievedMessages); //t.setDaemon(true); t.start(); try { t.join(); } catch (InterruptedException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } Task t1 = new Task() { @Override protected Object call() throws Exception { Thread.sleep(500); return new Object(); } }; t1.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax())); Thread thread1 = new Thread(t1); thread1.start(); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *//*from w w w . j a v a 2 s .c o m*/ private static void installeEvenements() { /** * */ getScnPrincipale().widthProperty().addListener( (ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) -> { if ((double) newSceneWidth < 1280) { } double largeur = (double) newSceneWidth - largeurOutils - 20; apPanovisu.setLayoutX((double) newSceneWidth - largeurOutils); spVuePanoramique.setPrefWidth(largeur); spVuePanoramique.setBackground( new Background(new BackgroundFill(Color.BLUE, CornerRadii.EMPTY, Insets.EMPTY))); gestionnaireInterface.getApVis().setPrefWidth((double) newSceneWidth - largeurOutils - 20); if ((double) newSceneWidth - largeurOutils - 20 < gestionnaireInterface.getApVis() .getMaxWidth()) { gestionnaireInterface.getApVis().setMinWidth((double) newSceneWidth - largeurOutils - 20); } if ((double) newSceneWidth - largeurOutils - 20 < gestionnairePlan.getApPlan().getMaxWidth()) { gestionnairePlan.getApPlan().setMinWidth((double) newSceneWidth - largeurOutils - 20); } gestionnairePlan.getApPlan().setPrefWidth((double) newSceneWidth - largeurOutils - 20); }); /** * */ getScnPrincipale().heightProperty().addListener((ObservableValue<? extends Number> observableValue, Number oldSceneHeight, Number newSceneHeight) -> { spVuePanoramique.setPrefHeight((double) newSceneHeight - 130.0d - getiDecalageMac()); spPanneauOutils.setPrefHeight((double) newSceneHeight - 130.0d - getiDecalageMac()); spVuePanoramique .setBackground(new Background(new BackgroundFill(Color.BLUE, CornerRadii.EMPTY, Insets.EMPTY))); if ((double) newSceneHeight - 130.0d - getiDecalageMac() < gestionnaireInterface.getSpOutils() .getMaxHeight()) { gestionnaireInterface.getSpOutils() .setMinHeight((double) newSceneHeight - 130.0d - getiDecalageMac()); } gestionnaireInterface.getSpOutils().setPrefHeight((double) newSceneHeight - 130.0d - getiDecalageMac()); gestionnairePlan.getSpOutils().setPrefHeight((double) newSceneHeight - 130 - getiDecalageMac()); if ((double) newSceneHeight - 130 - getiDecalageMac() < gestionnairePlan.getSpOutils().getMaxHeight()) { gestionnairePlan.getSpOutils().setMinHeight((double) newSceneHeight - 130 - getiDecalageMac()); } }); getScnPrincipale().setOnKeyPressed((clavierEvt) -> { //System.out.println("Code clavier : " + clavierEvt.getCode()); if (clavierEvt.isControlDown()) { if (clavierEvt.getText().toLowerCase().equals("l")) { clavierEvt.consume(); setAfficheLoupe(!isAfficheLoupe()); apLoupe.setVisible(isAfficheLoupe()); Point p = MouseInfo.getPointerInfo().getLocation(); if (p.x < getiTailleLoupe() + 80 && p.y < getiTailleLoupe() + 160) { apLoupe.setLayoutX(ivImagePanoramique.getFitWidth() - getiTailleLoupe() + 5); apLoupe.setLayoutY(35); strPositLoupe = "droite"; } else { apLoupe.setLayoutX(35); apLoupe.setLayoutY(35); strPositLoupe = "gauche"; } } } if (clavierEvt.getText().equals("+")) { setiTailleLoupe(getiTailleLoupe() + 10); creeLoupe(); afficheLoupe(positLoupeX, positLoupeY); } if (clavierEvt.getText().equals("-")) { setiTailleLoupe(getiTailleLoupe() - 10); creeLoupe(); afficheLoupe(positLoupeX, positLoupeY); } }); /** * */ panePanoramique.setOnMouseClicked((mouseEvent) -> { gereSourisPanoramique(mouseEvent); }); /** * */ panePanoramique.setOnMouseMoved((mouseEvent) -> { if (bEstCharge) { double mouseX = mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > ivImagePanoramique.getFitWidth()) { mouseX = ivImagePanoramique.getFitWidth(); } double mouseY = mouseEvent.getSceneY() - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY < 0) { mouseY = 0; } if (mouseY > ivImagePanoramique.getFitHeight()) { mouseY = ivImagePanoramique.getFitHeight(); } double longitude, latitude; double largeur = ivImagePanoramique.getFitWidth() * panePanoramique.getScaleX(); longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; String strLong = "Long : " + String.format("%.1f", longitude); String strLat = "Lat : " + String.format("%.1f", latitude); lblLong.setText(strLong); lblLat.setText(strLat); afficheLoupe(mouseX, mouseY); } }); cbListeChoixPanoramique.valueProperty().addListener((ov, ancienneValeur, nouvelleValeur) -> { if (nouvelleValeur != null) { if (!(nouvelleValeur.equals(strPanoAffiche))) { valideHS(); strPanoAffiche = nouvelleValeur.toString(); } } }); }