Some visual issues with a test application
Ty Young
youngty1997 at gmail.com
Mon Oct 15 04:36:37 UTC 2018
On 10/14/18 3:22 PM, Mark Raynsford wrote:
> Hello!
>
> I've been developing with Swing for many years, and I'm just now giving
> JavaFX a serious look now that the distribution issues are fixed
> (packages on Maven Central and the like).
>
> I've run into a couple of odd issues and I'm not sure that either of
> them are my fault.
>
> I've been putting together a little API and GUI application for
> browsing OSGi repositories:
>
> https://github.com/io7m/osgibrowse
>
> I've recorded the issues here:
>
> http://ataxia.io7m.com/2018/10/14/javafx.mp4
>
> You may notice that things look a little odd in that all windows appear
> to be fullscreen. This is because I'm using a tiling window manager
> (i3). Historically, Swing had a bit of trouble with this sort of window
> manager. I'm not sure if JavaFX also does.
>
> The first issue: The menu bar I created seems to behave erratically.
> Sometimes I can click on the menu to open it, other times it flashes
> open and then immediately closes. In both cases, the menu seems to be
> detached from the menu bar (there's a gap between the menu and the bar).
>
> The menu is created here and added to a BorderPane:
>
> https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBBrowserWindow.java#L30
>
> The second issue: Icons set on TreeItem values seem to be corrupted
> when the TreeTableView containing them is scrolled. You can see this
> happen in the video. The table in question is populated from an
> immutable snapshot of data returned by the underlying repository API.
> Once a repository is added, the table is populated once and then does
> not change until the user adds another repository.
>
> Double clicking on a row "selects" a bundle from the repository
> and this triggers a refresh of the table view. When I scroll up and
> down, it seems like icon views are incorrectly reused from other rows.
>
> The entirety of the table configuration happens here:
>
> https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBTableView.java#L188
>
> Icons are set on the tree table nodes here:
>
> https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBTableView.java#L92
>
> Any advice would be appreciated.
The code ultimately does everything correctly. Some JavaFX components
expose a getChildren() method which doesn't actually do anything because
your supposed to use getItems() or something like that and it causes odd
behavior but you're using the right methods...
but I digress, JDK 11 switched to GTK3 by default which has caused some
bugs. Try setting:
-Djdk.gtk.version=2
wherever you add run args in your Maven project(I use Ant and have no
experience with Maven). It will force GTK2. I tried to run your program
myself but there doesn't seem to be a way to add local dependencies like
you can with Ant in Netbeans 9, causing a build fail and Netbeans 9
can't find a main class.
> "YOU ARE NOT USING THE API CORRECTLY"
> criticism is also welcome.
>
If I may ask, why are you sidestepping constructors and using static
everywhere? It works all the same, just never seen anyone write code the
way you did.
More information about the openjfx-dev
mailing list