本文整理匯總了Java中javafx.scene.layout.Pane類的典型用法代碼示例。如果您正苦於以下問題:Java Pane類的具體用法?Java Pane怎麽用?Java Pane使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Pane類屬於javafx.scene.layout包,在下文中一共展示了Pane類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showQRCode
import javafx.scene.layout.Pane; //導入依賴的package包/類
@FXML
protected void showQRCode(MouseEvent event) {
// Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling
// lazy tonight.
final byte[] imageBytes = QRCode
.from(uri())
.withSize(320, 240)
.to(ImageType.PNG)
.stream()
.toByteArray();
Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
ImageView view = new ImageView(qrImage);
view.setEffect(new DropShadow());
// Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird.
// Then fix the width/height to stop it expanding to fill the parent, which would result in the image being
// non-centered on the screen. Finally fade/blur it in.
Pane pane = new Pane(view);
pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight());
final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this);
view.setOnMouseClicked(event1 -> overlay.done());
}
示例2: loadSellingAuctions
import javafx.scene.layout.Pane; //導入依賴的package包/類
/**
* Load box with artworks profile is selling
* @return bidedPane
*/
private HBox loadSellingAuctions(){
HBox bidedPane = new HBox();
for(Auction auction: dc.getAuctions()){
if(auction
.getSeller()
.getUsername()
.equals(p.getUsername())){
ImageView imgView2 = new ImageView(new Image(auction
.getArtwork()
.getPhoto()
.getPath())
);
imgView2.setFitWidth(200);
imgView2.setFitHeight(200);
bidedPane
.getChildren()
.addAll(new Pane(imgView2)
);
}
}
return bidedPane;
}
示例3: addRow
import javafx.scene.layout.Pane; //導入依賴的package包/類
protected void addRow (Transition transition) {
// load fxml
try {
FXMLLoader loader = new FXMLLoader(new File(ROW_FXML).toURI().toURL());
//set controller
TransitionRowController controller = new TransitionRowController(this, this.entry, this.index, transition);
this.controllerList.add(controller);
loader.setController(controller);
Pane rootPane = loader.load();//FXMLLoader.load(new File(fxmlPath).toURI().toURL());
//initialize tab controller
controller.init(stage, null, rootPane);
this.listView.getItems().add(rootPane);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
}
示例4: load_as_pane_multiple
import javafx.scene.layout.Pane; //導入依賴的package包/類
@Test
public void load_as_pane_multiple() {
final Pane testPane = this.assertSuccessAndGet(
this.easyFxml.loadNode(TEST_NODES.PANE, SELECTOR)
);
this.assertAppliedStyle(testPane, "");
this.assertControllerBoundToTestPane(
testPane,
this.controllerManager.getMultiple(TEST_NODES.PANE, SELECTOR)
);
assertThat(testPane.getChildren()).hasSize(1);
assertThat(testPane.getChildren().get(0).getClass()).isEqualTo(Button.class);
}
示例5: assertControllerBoundToTestPane
import javafx.scene.layout.Pane; //導入依賴的package包/類
/**
* We have to sleep here because the event firing in JavaFX can't be waited on all the way.
* So if we don't wait, as soon as the click is actually sent, but not yet registered,
* we are already asserting.
* The wait is a horrific thing that the whole async life promised to save us from. But it did
* not deliver (yet).
*
* @param testPane The pane to test bounding on
* @param controllerLookup The controller as an {@link Option} so we can know if the test
* actually failed because of some outside reason.
*/
private void assertControllerBoundToTestPane(final Pane testPane, final Option<FxmlController> controllerLookup) {
assertThat(controllerLookup.isDefined()).isTrue();
assertThat(controllerLookup.get().getClass()).isEqualTo(SAMPLE_CONTROL_CLASS.class);
Stages.stageOf("TEST_PANE", testPane)
.whenCompleteAsync((stage, err) -> Stages.scheduleDisplaying(stage))
.whenCompleteAsync((stage, err) -> {
final Button btn = (Button) stage.getScene().getRoot().getChildrenUnmodifiable().get(0);
btn.fire();
Stages.asyncStageOperation(stage, Stage::hide);
})
.whenCompleteAsync((stage, err) -> {
final SAMPLE_CONTROL_CLASS testController = (SAMPLE_CONTROL_CLASS) controllerLookup.get();
assertThat(testController.locatedInstance).isTrue();
})
.toCompletableFuture()
.join();
}
示例6: start
import javafx.scene.layout.Pane; //導入依賴的package包/類
@Override
public void start(final Stage stage) {
Platform.setImplicitExit(false);
STAGE_TITLE = "STAGE_TITLE";
STAGE_TITLE_2 = "STAGE_TITLE_2";
STAGE_PANE = new Pane();
TEST_STAGE = stage;
stage.show();
stage.hide();
}
示例7: ControlsPaneController
import javafx.scene.layout.Pane; //導入依賴的package包/類
public ControlsPaneController(UIToolBox toolBox) {
this.toolBox = toolBox;
toolBox.getEventBus()
.toObserverable()
.ofType(MediaControlsChangedEvent.class)
.subscribe(e -> updateMediaControlPane(e.get()));
emptyControlsPane = new Pane();
emptyControlsPane.setPrefSize(440, 80);
emptyControlsPane.setMaxSize(440, 80);
emptyControlsPane.setMinSize(440, 80);
Runtime.getRuntime()
.addShutdownHook(new Thread(() -> saveDividerPositions(splitPaneKey, getRoot())));
}
示例8: displayText
import javafx.scene.layout.Pane; //導入依賴的package包/類
private void displayText(final String s, final String title) {
final Scene scene = new Scene(new Pane());
String text = s;
if (s == null || s.isEmpty()) { text = "Whoops! Nothing to see here"; }
final Text textItem = new Text(text);
final Button okButton = new Button("OK");
final GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
grid.add(textItem, 0, 0);
grid.add(okButton, 1, 0);
final Pane root = (Pane) scene.getRoot();
root.getChildren().add(grid);
if (rootModel.darkModeProperty().get()) {
scene.getStylesheets().add("root/darkMode.css");
textItem.getStyleClass().add("text");
}
final Stage stage = new Stage();
stage.setScene(scene);
stage.setTitle(title);
stage.show();
okButton.setOnAction(e -> {
stage.close();
});
}
示例9: initGraphics
import javafx.scene.layout.Pane; //導入依賴的package包/類
private void initGraphics() {
if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
Double.compare(getHeight(), 0.0) <= 0) {
if (getPrefWidth() > 0 && getPrefHeight() > 0) {
setPrefSize(getPrefWidth(), getPrefHeight());
} else {
setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
}
}
getStyleClass().setAll("chart", "matrix-chart");
matrix = PixelMatrixBuilder.create()
.prefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT)
.pixelShape(PixelShape.SQUARE)
.useSpacer(true)
.squarePixels(false)
.pixelOnColor(Color.BLACK)
.pixelOffColor(Color.TRANSPARENT)
.build();
pane = new Pane(matrix);
getChildren().setAll(pane);
}
示例10: ConsoleTab
import javafx.scene.layout.Pane; //導入依賴的package包/類
public ConsoleTab(Button button, Pane pane, TextArea mooConsole, TextField commandInput, Button commandSend) {
super(button, pane);
this.mooConsole = mooConsole;
this.commandInput = commandInput;
this.commandSend = commandSend;
// for sending command
commandSend.setOnAction(event -> {
String text = commandInput.getText();
commandInput.clear();
PacketMessenger.message(new PacketConsoleInput(text));
});
// register this as event listener
EventExecutor.getInstance().register(this);
PacketAdapting.getInstance().register(this);
}
示例11: init
import javafx.scene.layout.Pane; //導入依賴的package包/類
@Override
public void init(Stage stage, Scene scene, Pane pane) {
addButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
//add transition
String eventName = eventNameTextField.getText();
if (eventName.isEmpty()) {
return;
}
RaiseEventTransition transition = new RaiseEventTransition(eventName);
entry.getTranstionList(index).add(transition);
//refresh listview
paneController.refreshListView();
stage.close();
}
});
}
示例12: create
import javafx.scene.layout.Pane; //導入依賴的package包/類
private void create(){
mStage = new Stage();
mStage.initModality(Modality.APPLICATION_MODAL);
mStage.initOwner(null);
mStage.initStyle(StageStyle.TRANSPARENT);
mStage.setResizable(false);
viewTuple = createContent();
if(viewTuple.getView() instanceof BaseView){
BaseView view = (BaseView) viewTuple.getView();
view.onDialogSet(this);
root = (Pane) viewTuple.getRoot();
alignCenter(root.getPrefWidth(), root.getPrefHeight());
if(isDragable)
dragDialogAbleNode(root);
}else{
try {
throw new Exception("your view is not a BaseView!");
} catch (Exception e) {
e.printStackTrace();
}
}
mScene = new Scene(viewTuple.getRoot());
// mScene.getStylesheets().setAll(TestinStage.getInstance().getStylesheet());
mStage.setScene(mScene);
}
示例13: initGraphics
import javafx.scene.layout.Pane; //導入依賴的package包/類
private void initGraphics() {
if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
Double.compare(getHeight(), 0.0) <= 0) {
if (getPrefWidth() > 0 && getPrefHeight() > 0) {
setPrefSize(getPrefWidth(), getPrefHeight());
} else {
setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
}
}
segmentPane = new Pane();
chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
chartCanvas.setMouseTransparent(true);
chartCtx = chartCanvas.getGraphicsContext2D();
pane = new Pane(segmentPane, chartCanvas);
pane.setBackground(new Background(new BackgroundFill(backgroundPaint, CornerRadii.EMPTY, Insets.EMPTY)));
pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth))));
getChildren().setAll(pane);
prepareData();
}
示例14: simpleScene
import javafx.scene.layout.Pane; //導入依賴的package包/類
private Scene simpleScene() {
try {
VBox root = new VBox();
Pane pane = new Pane();
Rectangle rectangle = new Rectangle(100, 100, Color.AQUA);
pane.getChildren().addAll(rectangle);
VerticalResizeContainerController controller = new VerticalResizeContainerController(pane);
root.getChildren().addAll(controller.getView());
VBox.setVgrow(controller.getView(), Priority.ALWAYS);
Scene scene = new Scene(root, 800, 600);
return scene;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例15: updateSidebar
import javafx.scene.layout.Pane; //導入依賴的package包/類
private void updateSidebar() {
if (docPage != null) {
ObservableList<SamplePage> relatedSamples = docPage.getRelatedSamples();
if (!(relatedSamples.isEmpty())) {
sidePane.setContent(createSideBar(relatedSamples));
sidePane.setVisible(true);
webView.getStyleClass().remove(WEB_VIEW_WINDOW_CORNER_STYLECLASS);
} else {
sidePane.setContent(new Pane());
sidePane.setVisible(false);
webView.getStyleClass().add(WEB_VIEW_WINDOW_CORNER_STYLECLASS);
}
} else {
sidePane.setContent(new Pane());
sidePane.setVisible(false);
webView.getStyleClass().add(WEB_VIEW_WINDOW_CORNER_STYLECLASS);
}
requestLayout();
}