javafx-8

JavaFX Change label text from another class with controller

醉酒当歌 提交于 2019-11-29 16:20:19
I want to change the text of a Label with the controller from another class. I have made a method in the FXMLDocumentController, which sets the text to the label: public void setLabelText(String text) { lbZeit.setText(text); } Now I want to change this text from another class like my SerialHandlerClass. First, I need the controller, am I right? So I did this: FXMLLoader loader = new FXMLLoader(FXMLDocumentController.class.getResource("FXMLDocument.fxml")); loader.load(); controller = (FXMLDocumentController) loader.getController(); Now I run the "setLabelText" method.... controller

Text color on JavaFX ComboBox items change only after first selection

我与影子孤独终老i 提交于 2019-11-29 16:18:57
I am building an input form in JavaFx from Java 8.0 using SceneBuilder 2.0 on Windows 7 in e(fx)clipse. I have a simple String ComboBox, and want to change the color and size of the fonts in both the list and the selected String. The css code I use changes the text on the selected item. However, the first time one drops the list, it is in black default font. The second time, the font color and size on all items have changed to the correct values. How do I make the font list start up in the right color and size? Here is simplified code from the initialize method in my Controller class:

How to resolve nested column in tableview after update version of java-124 in javaFx?

喜你入骨 提交于 2019-11-29 16:02:43
问题 Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.dispose(NestedTableColumnHeader.java:323) at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.updateTableColumnHeaders(NestedTableColumn Header.java:265) at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.checkState(NestedTableColumnHeader.java:51 9) at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.computePrefHeight

MenuButton doesn't display items in Javafx

我与影子孤独终老i 提交于 2019-11-29 15:57:25
I have a class Foo which just load the FXML and create the scene. In the FXML, I set the controller to be FooController ( fx:controller="FooController" ) And I add a MenuButton: <MenuButton fx:id="menuButton" layoutX="264.1875" layoutY="146.5" mnemonicParsing="false" text="MenuButton" /> And I try to set the menuButton in the FooController: public class FooController implements Initializable{ @FXML final MenuButton menuButton = new MenuButton("Modalities"); @Override public void initialize(URL arg0, ResourceBundle arg1) { final ObservableList<CheckMenuItem> listFilter = FXCollections

JavaFX getScene() returns null in initialize method of the controller

亡梦爱人 提交于 2019-11-29 15:33:09
I built a small application in JavaFX yesterday. I wanted to get the Scene of the application in the Controller class. I got an error every time I tried to get the scene in the controller class. I could set the OnKeyPressed-method on a Button in the Controller class, works fine. But it works only fine if the Button is selected.. I can get the scene in the Main-class method replaceSceneContent only. I have read this question already , but I call the getScene()-method in the initialize-method?? Thanks for any ideas! Main class: public class Main extends Application { private Stage stage; public

How to update textarea(console)in realtime in JavaFX without loosing flow or freezing the application

蹲街弑〆低调 提交于 2019-11-29 15:31:09
I am new JFX and I am struggling with this. I am trying to run a simple simulation that has to print output (system.out and system.err) to textarea. public class ConsoleController { @FXML public TextArea consoleLogscreen; private class Console extends OutputStream { @Override public void write(int b) throws IOException { consoleLogscreen.appendText(String.valueOf((char) b)); } } @FXML public void initialize() throws IOException { Console console = new Console(); PrintStream ps = new PrintStream(console, true); System.setOut(ps); System.setErr(ps); System.err.flush(); System.out.flush(); } }

Resize JavaFX tab when double click

江枫思渺然 提交于 2019-11-29 15:28:02
I have this simple example with JavaFX tabs: public class test extends Application { private BorderPane root; // Navigation Utilization private ActionTabs actiontabs; @Override public void start(Stage primaryStage) { // Set Main Window Label primaryStage.setTitle("Desktop Client"); Image iv = new Image(getClass().getResource("/images/internet-icon.png").toExternalForm()); primaryStage.getIcons().add(iv); root = new BorderPane(); root.setLeft(getLeftHBox(primaryStage, root)); Scene scene = new Scene(root, 1000, 1000, Color.WHITESMOKE); // Set main Stage color primaryStage.setScene(scene);

Programmatically edit TreeView/TreeItem

为君一笑 提交于 2019-11-29 15:24:05
Edit #2 : Since it looks like a bug i already posted a bug report in the javaFx-jira . You have to have an account to have access to the issue. I will keep this post up-to-date, if there is new information. Original post: I have a simple UI with a button and a TreeView. If the button gets pressed there should be a new item added to the TreeView. This item should be editable as soon as it appears in the tree. import javafx.fxml.FXML; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.control.cell.TextFieldTreeCell; import javafx.util.converter

Prevent JavaFX thread from dying with JFXPanel Swing interop?

无人久伴 提交于 2019-11-29 14:24:45
问题 I'm embedding several JFXPanels into a Swing app and the JavaFX thread dies when the JFXPanels are no longer visible. This is problematic because creating another JFXPanel after the JavaFX thread dies will not start another JavaFX thread and thus the JFXPanel will be blank. From what I can tell the JFXPanel ctor starts the JavaFX thread by calling: PlatformImpl.startup(new Runnable() { @Override public void run() { // No need to do anything here } }); Later on once the JFXPanel has a parent

How to resize Swing control which is inside SwingNode in JavaFX8?

爱⌒轻易说出口 提交于 2019-11-29 14:10:50
How to resize Swing control which is inside SwingNode in JavaFX8? Sometimes, I has controls resized inside SwingNode . But SwingNode seems to resist this. It is said in resize() apidoc, that Applications should not invoke this method directly. If an application needs to directly set the size of the SwingNode, it should set the Swing component's minimum/preferred/maximum size constraints which will be propagated correspondingly to the SwingNode and it's parent will honor those settings during layout. But apparently it does not work. Example code is below. The question is: how to allow control