• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i resize scene in javafx 8?

 
drashti pandya
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I pressed Key Button in NumericKeypad.fxml Key Panel should appear and when i click on it again it should hide and stage should be shrink.
I Have try KeyPane.setPrefSize(0, 0); Keypad get disappear but whole scene is still on same size.

AddItemController.java
@FXML
public void handleAddUPCButtonAction(ActionEvent a){
try {
Stage stg=new Stage();
FXMLLoader fxml=new FXMLLoader(getClass().getResource("NumericKeyPad.fxml"));
Parent root=(Parent)fxml.load();
stg.setScene(new Scene(root));
stg.show();
} catch (IOException ex) {
Logger.getLogger(SelectDeptController.class.getName()).log(Level.SEVERE, null, ex);
}
}

NumericKeypad.fxml

<AnchorPane id="AnchorPane" prefHeight="493.0" prefWidth="521.0" styleClass="mainFxmlClass" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="finaldemo.Controller.NumericKeyPadController" fx:id="mainPane">
<stylesheets>
<URL value="@numerickeypad.css" />
</stylesheets>
<children>
<Pane layoutX="6.0" prefHeight="105.0" prefWidth="428.0">
<children>
<TextField layoutX="89.0" layoutY="13.0" prefHeight="25.0" prefWidth="284.0" />
<Button layoutX="52.0" layoutY="61.0" mnemonicParsing="false" prefHeight="32.0" prefWidth="78.0" text="Key>>" />
<Button layoutX="190.0" layoutY="62.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="78.0" text="OK" />
<Button layoutX="337.0" layoutY="66.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="78.0" text="Cancel" />
</children>
</Pane>
<Pane fx:id="KeyPanel" layoutX="14.0" layoutY="144.0" prefHeight="341.0" prefWidth="418.0">
<children>
<Button layoutX="14.0" layoutY="7.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="1" />
<Button layoutX="153.0" layoutY="7.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="2" />
<Button layoutX="14.0" layoutY="91.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="4" />
<Button layoutX="153.0" layoutY="91.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="5" />
<Button layoutX="300.0" layoutY="7.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="3" />
<Button layoutX="300.0" layoutY="91.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="6" />
<Button layoutX="153.0" layoutY="185.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="8" />
<Button layoutX="14.0" layoutY="185.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="7" />
<Button layoutX="294.0" layoutY="185.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="9" />
<Button layoutX="294.0" layoutY="282.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="Delete" />
<Button layoutX="153.0" layoutY="282.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="00" />
<Button layoutX="14.0" layoutY="282.0" mnemonicParsing="false" prefHeight="50.0" prefWidth="112.0" text="0" />
</children>
</Pane>
</children>
</AnchorPane>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic