javajavafx3dfxgl

How to create a box with two different pictures(same size) on the top and bottom of the box?


I just want to create a box in javafx. That box has two different pictures(at same size) on top and bottom (It's no need to be only on top or bottom because the box can rotate, just at two opposite faces). Just like the two covers of a book. I thought there are various methods but I don't know how to write the code and which is best. These methods are on below:

  1. Use two MeshView and two textures.
  2. Combine the two pictures in a new texture and use one MeshView.

I tried to use the phongmeterial in Javafx but it painted the six faces with one picture(six times), that not what I thought. I expect a box with two pictures on top and bottom with other faces in white.


Solution

  • For 3D boxes:

    Please take a look at this thread: Javafx: applying image to meshview not working

    For 2D boxes:

    Use a BorderPane. Put the top Image into the top part and the bottom Image into to bottom part. The center is used for your content (or spacing element).

    You can rotate the complete element. The spacing element could be a simple vbox with a fixed height.