这是我的切换菜单 enter image description here
它正常工作,但是打开时无需我单击汉堡包 我想把它摘下来 有可能吗?
我的fxml:
<AnchorPane id="AnchorPane" fx:id="rootHome" prefHeight="600.0" prefWidth="1000.0" style="-fx-background-color: #eee;" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.semeq.controllers.home.HomeController">
<children>
<HBox prefHeight="50.0" style="-fx-background-color: #e546;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<JFXHamburger fx:id="hamburgerMain" />
</children>
<padding>
<Insets left="10.0" />
</padding>
</HBox>
<JFXDrawer fx:id="mainDrawer" defaultDrawerSize="150.0" overLayVisible="false" prefHeight="0.0" prefWidth="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="50.0" />
</children>
</AnchorPane>
控制器
@Controller
public class HomeController {
public void initialize() {
mainDrawer.setOnDrawerOpening(event ->
{
AnchorPane.setRightAnchor(mainDrawer, 0.0);
AnchorPane.setLeftAnchor(mainDrawer, 0.0);
AnchorPane.setTopAnchor(mainDrawer, 50.0);
AnchorPane.setBottomAnchor(mainDrawer, 0.0);
});
mainDrawer.setOnDrawerClosed(event ->
{
AnchorPane.clearConstraints(mainDrawer);
AnchorPane.setLeftAnchor(mainDrawer, -150.00);
AnchorPane.setTopAnchor(mainDrawer, 0.0);
AnchorPane.setBottomAnchor(mainDrawer, 0.0);
});
show();
}
private void show() {
HamburgerSlideCloseTransition transition = new HamburgerSlideCloseTransition(hamburgerMain);
transition.setRate(-1);
hamburgerMain.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
try {
box = FXMLLoader.load(getClass().getResource("/Home.fxml"));
mainDrawer.setSidePane(box);
mainDrawer.toggle();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
}
我搜索了很多东西,却一无所获