JavaFX2:展开和折叠时树视图中的奇怪行为(JavaFX2.2中可能存在错误)
我在TreeView上工作,但我看到了一个奇怪的行为。首先看看这里的代码 FXML FXML控制器 解释 使用JDK1.7.067和JavaFXV2.2 请看附件中的图片,我执行了5个步骤,给出了奇怪的行为。图中有解释。如果这不是bug,那么我如何修复它。 我也在JDK 8上检查了这一点,但它在JDK 8中不存在。但是我们不能将我们的项目从JDK7转移到JDK8JavaFX2:展开和折叠时树视图中的奇怪行为(JavaFX2.2中可能存在错误),java,javafx-2,Java,Javafx 2,我在TreeView上工作,但我看到了一个奇怪的行为。首先看看这里的代码 FXML FXML控制器 解释 使用JDK1.7.067和JavaFXV2.2 请看附件中的图片,我执行了5个步骤,给出了奇怪的行为。图中有解释。如果这不是bug,那么我如何修复它。 我也在JDK 8上检查了这一点,但它在JDK 8中不存在。但是我们不能将我们的项目从JDK7转移到JDK8 我认为这是一个错误。。在javaFX问题跟踪器中搜索这个问题,也许你可以找到一个解决方法vafxhttps://javafx-jira
我认为这是一个错误。。在javaFX问题跟踪器中搜索这个问题,也许你可以找到一个解决方法vafxhttps://javafx-jira.kenai.com/browse/RT-38885 一个人回复说我们没有计划在jdk 7u67中解决这个问题:-
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import com.nuaxis.rpas.client.contol.*?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.main.FXMLController">
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<bottom>
<AnchorPane prefHeight="15.0" prefWidth="600.0" BorderPane.alignment="CENTER" />
</bottom>
<center>
<SplitPane fx:id="mSplitPane" prefHeight="160.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<Button layoutX="167.0" layoutY="76.0" mnemonicParsing="false" onAction="#onBAction" text="Button" />
</children>
</AnchorPane>
</items>
</SplitPane>
</center>
</BorderPane>
public class MainApp extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));
Scene scene = new Scene(root);
scene.setFill(Color.LIGHTGRAY);
stage.setTitle("Tree View");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
public class FXMLController {
@FXML private SplitPane mSplitPane;
TreeItem<String> rootNode;
@FXML
public void initialize() {
rootNode = new TreeItem<>("asdf");
rootNode.setExpanded(true);
TreeItem<String> groupNode = new TreeItem<>("645654");
groupNode.getChildren().addAll(new TreeItem<>("adsad"),
new TreeItem<>("dfsf"),
new TreeItem<>("sdfdsf"));
rootNode.getChildren().addAll(new TreeItem<>("565y"),
groupNode,
new TreeItem<>("fdgfdhtry"),
new TreeItem<>("dgfdgdftg"));
TreeView<String> list = new TreeView<String>(rootNode);
list.setShowRoot(false);
mSplitPane.getItems().add(0, list);
}
@FXML
void onBAction(ActionEvent event) {
rootNode.getChildren().add(new TreenItem<>("new"));
}
}