public NetworkSyncPane() { networkSyncInfoLabel = new Label(); networkSyncInfoLabel.setText("Synchronize with network..."); networkSyncProgressBar = new ProgressBar(); networkSyncProgressBar.setPrefWidth(200); networkSyncProgressBar.setProgress(-1); getChildren().addAll(new HSpacer(5), networkSyncProgressBar, networkSyncInfoLabel); }
private void onSendMessage(String inputText, Dispute dispute) { DisputeDirectMessage disputeDirectMessage = disputeManager.sendDisputeDirectMessage( dispute, inputText, new ArrayList<>(tempAttachments)); tempAttachments.clear(); scrollToBottom(); inputTextArea.setDisable(true); inputTextArea.clear(); final Timer timer = FxTimer.runLater( Duration.ofMillis(500), () -> { sendMsgInfoLabel.setVisible(true); sendMsgInfoLabel.setManaged(true); sendMsgInfoLabel.setText("Sending Message..."); sendMsgProgressIndicator.setProgress(-1); sendMsgProgressIndicator.setVisible(true); sendMsgProgressIndicator.setManaged(true); }); disputeDirectMessage .arrivedProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue) { hideSendMsgInfo(timer); } }); disputeDirectMessage .storedInMailboxProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue) { sendMsgInfoLabel.setVisible(true); sendMsgInfoLabel.setManaged(true); sendMsgInfoLabel.setText( "Receiver is not online. Message is saved to his mailbox."); hideSendMsgInfo(timer); } }); }
public void downloadComplete() { networkSyncInfoLabel.setText("Sync with network: Done"); networkSyncProgressBar.setProgress(1); FadeTransition fade = new FadeTransition(Duration.millis(700), this); fade.setToValue(0.0); fade.setCycleCount(1); fade.setInterpolator(Interpolator.EASE_BOTH); fade.play(); fade.setOnFinished(e -> getChildren().clear()); }
@Override public void start(Stage stage) throws Exception { // ----------MENU---------- MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem menuItemPurchase = new MenuItem("New Purchase"); MenuItem menuItemStore = new MenuItem("New Store"); MenuItem menuItemCategory = new MenuItem("New Category"); MenuItem menuItemExit = new MenuItem("Exit"); menuFile.getItems().addAll(menuItemPurchase, menuItemStore, menuItemCategory, menuItemExit); Menu menuHelp = new Menu("Help"); menuBar.getMenus().addAll(menuFile, menuHelp); // ----------TOOLBAR---------- ToolBar toolBar = new ToolBar(); Button buttonPurchase = new Button(); Button buttonStore = new Button(); Button buttonCategory = new Button(); buttonPurchase.setGraphic(new ImageView("/pictures/purchase.png")); buttonStore.setGraphic(new ImageView("/pictures/store.png")); buttonCategory.setGraphic(new ImageView("/pictures/category.png")); toolBar.getItems().addAll(buttonPurchase, buttonStore, buttonCategory); buttonStore.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { Stage stage = new Stage(); try { new StoreWindows().start(stage); } catch (Exception e) { e.printStackTrace(); } } }); // ----------WORKSPACE---------- GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setVgap(10); gridPane.setHgap(10); gridPane.setPadding(new Insets(0, 25, 25, 0)); Label storeLabel = new Label("Store: "); storeLabel.setId("simpleLabel"); gridPane.add(storeLabel, 0, 1); final ComboBox<String> stores = new ComboBox<String>(); gridPane.add(stores, 1, 1); Label categoryLabel = new Label("Category: "); categoryLabel.setId("simpleLabel"); gridPane.add(categoryLabel, 2, 1); final ComboBox<String> categories = new ComboBox<String>(); gridPane.add(categories, 3, 1); Button bCount = new Button("Count"); HBox hBox = new HBox(10); hBox.setAlignment(Pos.BOTTOM_RIGHT); hBox.getChildren().add(bCount); gridPane.add(hBox, 4, 1); FlowPane flowPane1 = new FlowPane(); flowPane1.setAlignment(Pos.CENTER); flowPane1.setPadding(new Insets(10, 25, 25, 10)); final Text spentTitle = new Text("SPENT: "); spentTitle.setId("headline"); flowPane1.getChildren().add(spentTitle); // ----------DATABASE---------- Label statusLabel = new Label(); DaoFactory daoFactory = new MySQLDaoFactory(); try { Connection connection = daoFactory.getConnection(); statusLabel.setText("Database connection: success"); StoreDao storeDao = new MySQLStoreDao(connection); ArrayList<Store> storeList = (ArrayList) storeDao.getStores(); for (Store store : storeList) { stores.getItems().add(store.getName()); } CategoryDao categoryDao = new MySQLCategoryDao(connection); ArrayList<Category> categoryList = (ArrayList) categoryDao.getCategories(); for (Category category : categoryList) { categories.getItems().add(category.getTitle()); } } catch (SQLException e) { statusLabel.setText("Database connection: failed"); } FlowPane footer = new FlowPane(); footer.setPadding(new Insets(10, 10, 10, 10)); footer.getChildren().add(statusLabel); bCount.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { try { PurchaseDao purchaseDao = new MySQLPurchaseDao(new MySQLDaoFactory().getConnection()); spentTitle.setText( "SPENT: " + purchaseDao.showSpent(stores.getValue(), categories.getValue())); } catch (SQLException e) { e.printStackTrace(); } } }); // ----------VIEW---------- Scene scene = new Scene(new VBox(), 800, 600); scene.getStylesheets().add("css/style.css"); ((VBox) scene.getRoot()).getChildren().addAll(menuBar, toolBar, gridPane, flowPane1, footer); stage.setScene(scene); stage.setTitle("Cash Organizer"); stage.getIcons().add(new Image("pictures/icon.png")); stage.show(); }
public void setProgress(double percent) { networkSyncProgressBar.setProgress(percent / 100.0); networkSyncInfoLabel.setText("Synchronize with network: " + (int) percent + "%"); }
private void render() { ArrayList<NetworkMessage> messages = networkController.getMessages(); for (NetworkMessage message : messages) { String messageType = message.getClass().getName().replace("NetworkMessages.", "").replace("Messages.", ""); switch (messageType) { case "PelletPositionMessage": { PelletPositionMessage m = (PelletPositionMessage) message; Drawable drawable = getCachedDrawable(m.id); if (drawable != null) { drawable.node.relocate(m.x, m.y); drawable.cacheMisses = 0; } else { Random r = new Random(); Node node = drawCircle( m.x, m.y, 5, new Color(r.nextFloat(), r.nextFloat(), r.nextFloat(), 1)); drawableCache.add(new Drawable(m.id, node)); } } break; case "BlobStateMessage": { BlobStateMessage m = (BlobStateMessage) message; Color color = Color.web(m.color); Node node; if (color.getBrightness() != 0) { node = drawCircle(m.x, m.y, m.size / 2, color); } else { node = drawCircle(m.x, m.y, m.size / 2, color.brighter().brighter()); } Node nameText = drawText((m.x - m.username.length() * 5), (m.y - m.size / 2), m.username, color); Drawable drawable = getCachedDrawable(m.id); if (drawable != null) { node.setLayoutX((drawable.node.getTranslateX() - m.x) / 10000); node.setLayoutY((drawable.node.getTranslateY() - m.y) / 10000); drawable.node = node; drawable.cacheMisses = 0; Drawable nameTag = getCachedDrawable(m.id + 9000); nameTag.node = nameText; nameTag.cacheMisses = 0; } else { drawableCache.add(new Drawable(m.id, node)); drawableCache.add(new Drawable(m.id + 9000, nameText)); } } break; case "PingMessage": { renderPane.getChildren().clear(); ArrayList<Drawable> drawables = new ArrayList<>(drawableCache); for (Drawable drawable : drawables) { if (drawable.cacheMisses > 1) { drawableCache.remove(drawable); } drawable.cacheMisses++; renderPane.getChildren().add(drawable.node); } renderPane.getChildren().addAll(chatBox, chatInput, lagLabel, scores); lag = System.currentTimeMillis() - lastReceivedTime; lastReceivedTime = System.currentTimeMillis(); lagLabel.setText("Net Lag: " + Long.toString(lag)); } break; case "HighScoreMessage": { HighScoreMessage m = (HighScoreMessage) message; highScores.setText("HIGH SCORES:" + m.text); } break; case "CurrentScoreMessage": { CurrentScoreMessage m = (CurrentScoreMessage) message; currentScores.setText("Current Scores:" + m.text); } break; case "ChatMessage": { ChatMessage m = (ChatMessage) message; chatBox.appendText(m.username + "> " + m.text + "\n"); } break; } } }
protected void update() { mPrice.update(); mLobby.update(); mOil.update(); mActionValue.setText("" + mModel.getResourceManager().getActionPoints()); }
public void titoloConEsitoOk(String txt) { // (2) labelTitolo.getStyleClass().add("messaggioOk"); labelTitolo.getStyleClass().remove("errore"); labelTitolo.setText(txt); }
public void setTitoloTxt(String t) { labelTitolo.getStyleClass().remove("errore"); labelTitolo.getStyleClass().remove("messaggioOk"); labelTitolo.setText(t); }
public entryView(Object object) { getChildren().clear(); getStylesheets().add("css/entryView.css"); giveNode(object); BorderPane mainpane = new BorderPane(); BorderPane centerpane = new BorderPane(); BorderPane bottompane = new BorderPane(); GridPane divgrid = new GridPane(); GridPane maingrid = new GridPane(); Label emptylab = new Label(); Label divlab = new Label(); VBox options = new VBox(); VBox tlist = new VBox(); Button ok = new Button("ok"); Periods periods = new Periods(); TList loadteacher = new TList(); DatePicker date = new DatePicker(); BorderPane datepane = new BorderPane(); BorderPane nextpane = new BorderPane(); Button next = new Button("next"); options.setId("options"); tlist.setId("tlist"); divgrid.setId("divgrid"); bottompane.setId("bottompane"); periods.setId("period"); divlab.setId("divlabel"); datepane.setId("datepane"); nextpane.setId("nextpane"); emptylab.setPrefHeight(100); bottompane.setStyle("-fx-background-color:#ecf0f1;"); StringConverter converter = new StringConverter<LocalDate>() { DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); @Override public String toString(LocalDate date) { if (date != null) { return dateFormatter.format(date); } else { return ""; } } @Override public LocalDate fromString(String string) { if (string != null && !string.isEmpty()) { return LocalDate.parse(string, dateFormatter); } else { return null; } } }; date.setConverter(converter); date.setPromptText("dd-MM-yyyy".toLowerCase()); date.setValue(LocalDate.now()); maingrid = div.loadDiv(); list = (ListView) div.takelist(); periods.period(); list.getSelectionModel().select(0); divlab.setText((String) list.getItems().get(0)); list.setOnMouseClicked( e -> { divlab.setText((String) list.getSelectionModel().getSelectedItem()); periods.getChildren().clear(); periods.period(); }); final Node node = maingrid.getChildren().get(0); Platform.runLater( new Runnable() { @Override public void run() { node.requestFocus(); } }); next.setOnAction( e -> { // list.getSelectionModel().getSelectedIndex()+1 list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1); divlab.setText((String) list.getSelectionModel().getSelectedItem()); }); nextpane.setRight(next); datepane.setRight(date); options.getChildren().clear(); options.getChildren().add(maingrid); divgrid.setHgap(5); // divgrid.add(emptylab, 0, 1); divgrid.add(datepane, 1, 0); divgrid.add(divlab, 0, 2); divgrid.add(periods, 1, 2); divgrid.add(nextpane, 1, 3); divgrid.setAlignment(Pos.TOP_CENTER); mainpane.setCenter(centerpane); mainpane.setLeft(options); mainpane.setRight(loadteacher); centerpane.setCenter(divgrid); centerpane.setBottom(bottompane); bottompane.setRight(ok); addCloseButton cb = new addCloseButton(); cb.addxb(1); setTop(cb); setCenter(mainpane); }