Skip to content

Fix a few theme-related issues#13877

Merged
Siedlerchr merged 9 commits intoJabRef:mainfrom
HoussemNasri:fix-some-theme-issues
Oct 9, 2025
Merged

Fix a few theme-related issues#13877
Siedlerchr merged 9 commits intoJabRef:mainfrom
HoussemNasri:fix-some-theme-issues

Conversation

@HoussemNasri
Copy link
Copy Markdown
Member

@HoussemNasri HoussemNasri commented Sep 13, 2025

JavaFX default theme brief flash

Screen.Recording.2025-09-13.at.14.53.57.mov

Button-bar button ellipsis truncate issue

Screenshot 2025-09-13 at 17 34 40

Mandatory checks

Houssem Nasri added 3 commits September 13, 2025 17:12
… runtime

- IndexOutOfBoundsException keeps being thrown although the theme is applied correctly.
 By catching the exception, we avoid spamming the exception to user.
@HoussemNasri
Copy link
Copy Markdown
Member Author

Please don't squash before merging, as each commit addresses a separate issue.

@Siedlerchr
Copy link
Copy Markdown
Member

When I go to prefs -> Change from light to dark theme

java.lang.IndexOutOfBoundsException: toIndex = 2
	at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
	at java.base/java.util.AbstractList.subList(AbstractList.java:499)
	at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.subList(ModifiableObservableListBase.java:234)
	at javafx.base@24.0.2/com.sun.javafx.binding.ContentBinding$ListContentBinding.onChanged(ContentBinding.java:123)
	at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:327)
	at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:71)
	at javafx.base@24.0.2/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:246)
	at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.base@24.0.2/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:210)
	at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:102)
	at org.jabref/org.jabref.gui.theme.ThemeManager.installCssImmediately(ThemeManager.java:108)
	at org.jabref/org.jabref.gui.theme.ThemeManager.lambda$installCss$0(ThemeManager.java:117)
	at javafx.graphics@24.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419)
	at javafx.graphics@24.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

@Yubo-Cao
Copy link
Copy Markdown
Collaborator

I also experience the IndexOutOfBoundsException when I switch the theme first from light to dark then dark to light:

java.lang.IndexOutOfBoundsException: toIndex = 3
	at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
	at java.base/java.util.AbstractList.subList(AbstractList.java:499)
	at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.subList(ModifiableObservableListBase.java:234)
	at javafx.base@24.0.2/com.sun.javafx.binding.ContentBinding$ListContentBinding.onChanged(ContentBinding.java:123)
	at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:327)
	at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:71)
	at javafx.base@24.0.2/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:246)
	at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.base@24.0.2/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:210)
	at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:102)
	at org.jabref/org.jabref.gui.theme.ThemeManager.installCssImmediately(ThemeManager.java:108)
	at org.jabref/org.jabref.gui.theme.ThemeManager.lambda$installCss$0(ThemeManager.java:117)
	at javafx.graphics@24.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419)
	at javafx.graphics@24.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at javafx.graphics@24.0.2/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at javafx.graphics@24.0.2/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168)
	at java.base/java.lang.Thread.run(Thread.java:1447)

installCssImmediately(scene);
} catch (IndexOutOfBoundsException e) {
// IndexOutOfBoundsException keeps being thrown although the theme is applied correctly.
// By catching the exception, we avoid spamming the exception to user.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can actually catch the IndexOfOutBoundsException... For some magic that I cannot fully understood, even with that, I can get an error similar to this:

java.lang.IndexOutOfBoundsException: toIndex = 3
	at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
	at java.base/java.util.AbstractList.subList(AbstractList.java:499)
	at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.subList(ModifiableObservableListBase.java:234)
	at javafx.base@24.0.2/com.sun.javafx.binding.ContentBinding$ListContentBinding.onChanged(ContentBinding.java:123)
	at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:327)
	at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:71)
	at javafx.base@24.0.2/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:246)
	at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.base@24.0.2/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:210)
	at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:102)
	at org.jabref/org.jabref.gui.theme.ThemeManager.installCssImmediately(ThemeManager.java:108)
	at org.jabref/org.jabref.gui.theme.ThemeManager.lambda$installCss$0(ThemeManager.java:117)
	at javafx.graphics@24.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419)
	at javafx.graphics@24.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at javafx.graphics@24.0.2/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at javafx.graphics@24.0.2/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168)
	at java.base/java.lang.Thread.run(Thread.java:1447)

I wonder if DelayedExecution utility, or first clear all the theme instead of directly setAll would perform the trick. Alternatively, the other method that I haven't tried before (when I encountered this), is to always keep the base.css and only remove the css not needed (so switch light to dark = add(dark.css); switch dark to light = remove(dark.css), instead of just performing an array of css replacement).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could fix this by calling clear first and then adding the new stylesheets

Copy link
Copy Markdown
Member Author

@HoussemNasri HoussemNasri Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception is less frequent now but still reproducible unfortunately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can actually catch the IndexOfOutBoundsException... For some magic that I cannot fully understood, even with that, I can get an error similar to this:

I'm really confused too :), no idea how the exception is not caught. We have this setUncaughtExceptionHandler method call to catch uncaught exceptions and show them in error dialog but that should be for uncaught 🥲.

I would keep it throwing since this is not a new bug and the theme changes correctly even with the exception, and open an issue to fix it later.

-fx-padding: 0.5em 1em 0.5em 1em;
}

.dialog-pane .button-bar .button {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching the merge dialog issue. I initially created this catch all for other dialogs when font size is large. For example, if we turn font size of 14 and open preferences dialog or the new entry dialog, their sizes are not properly working out anymore...

image image

Copy link
Copy Markdown
Member Author

@HoussemNasri HoussemNasri Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JabRef should be able to resize buttons to show full texts when font size changes but it is more important to have it work using the default font size, we can think of a better solution for that case in parallel.

The issue doesn't happen with the merge dialog only but with any dialog that has long text (more than two words) in button bar .i.e About dialog.

@koppor koppor added the status: changes-required Pull requests that are not yet complete label Sep 13, 2025
Copy link
Copy Markdown
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried - worked on Gnome.

@Siedlerchr
Copy link
Copy Markdown
Member

Exception no longer occurs after the latest changes. I think the only issue left was that with the icon size updating on font size change not always beeng correct

@HoussemNasri
Copy link
Copy Markdown
Member Author

Exception no longer occurs after the latest changes. I think the only issue left was that with the icon size updating on font size change not always beeng correct

Actually it still does for me. I didn't push any attempts to fix the exception, it is more involved. I reverted the commit that said it fixed this problem. I think we can merge as is, good enough for alpha release.

@Siedlerchr Siedlerchr mentioned this pull request Sep 20, 2025
1 task
Siedlerchr
Siedlerchr previously approved these changes Sep 20, 2025
@Siedlerchr
Copy link
Copy Markdown
Member

@HoussemNasri @Yubo-Cao I merged the javafx25 now in, would be nice if could play around wtih this as well

* upstream/main: (85 commits)
  Fix typo in PR template (add missing 'to') (JabRef#14050)
  New Crowdin updates (JabRef#14049)
  Switch to new macos intel runner and update arm runner as well (JabRef#14048)
  Automatic field editor: Add Clear content tab + viewmodel (JabRef#13824)
  Update dependency org.eclipse.jgit:org.eclipse.jgit.pgm to v7.4.0.202509020913-r (JabRef#14046)
  Rephrase JabRef-Machine's "Determine issue number" (JabRef#14044)
  Chore(deps): Bump com.vanniktech.maven.publish from 0.32.0 to 0.34.0 in /jablib (JabRef#14039)
  Chore(deps): Bump org.mockito:mockito-core in /jablib (JabRef#14038)
  Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#14037)
  Chore(deps): Bump com.dlsc.pdfviewfx:pdfviewfx in /versions (JabRef#14040)
  Chore(deps): Bump lucene from 10.3.0 to 10.3.1 in /versions (JabRef#14042)
  Fix eadr missing (JabRef#14043)
  Enable update in versions of jablib (JabRef#14036)
  Update Gradle Wrapper from 9.3.0-jabref-1 to 9.1.0 (JabRef#14033)
  Implemented OpenAlex  (JabRef#14020)
  Chore(deps): Bump peter-evans/create-or-update-comment from 4 to 5 (JabRef#14023)
  Chore(deps): Bump org.cyclonedx.bom from 3.0.0-alpha-1 to 3.0.0 (JabRef#14026)
  Chore(deps): Bump org.junit.jupiter:junit-jupiter in /versions (JabRef#14030)
  Chore(deps): Bump com.github.andygoossens:gradle-modernizer-plugin (JabRef#14027)
  Chore(deps): Bump org.mockito:mockito-core in /versions (JabRef#14028)
  ...
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Oct 9, 2025
@jabref-machine
Copy link
Copy Markdown
Collaborator

Your pull request needs to link an issue correctly.

To ease organizational workflows, please link this pull request to the issue by including a supported keyword in the pull request's description as per syntax described in GitHub's documentation.

Examples

  • Fixes #xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes https://github.com/JabRef/jabref/issues/xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes https://github.com/Koppor/jabref/issues/xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes [#xyz](https://github.com/JabRef/jabref/issues/xyz) links pull-request to issue. Merging the PR will NOT close the issue.

Copy link
Copy Markdown
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no errors so far, should be fine

@Siedlerchr Siedlerchr dismissed Yubo-Cao’s stale review October 9, 2025 18:37

still better to have the proper text on the buttons

@Siedlerchr Siedlerchr added this pull request to the merge queue Oct 9, 2025
Merged via the queue into JabRef:main with commit 263eae1 Oct 9, 2025
47 of 49 checks passed
Shanaya-1981 pushed a commit to Shanaya-1981/jabref that referenced this pull request Oct 13, 2025
* Prevent brief flash of the default JavaFX (Modena) theme on startup

* Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime

- IndexOutOfBoundsException keeps being thrown although the theme is applied correctly.
 By catching the exception, we avoid spamming the exception to user.

* Fix button-bar buttons truncating long text with ellipsis

* Update Changelog

* use clear

* Revert "Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime"

This reverts commit 7361b5a.

* Update CHANGELOG.md

---------

Co-authored-by: Houssem Nasri <houssem.nasri@360t.com>
Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
merlinymy pushed a commit to merlinymy/jabref that referenced this pull request Nov 19, 2025
* Prevent brief flash of the default JavaFX (Modena) theme on startup

* Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime

- IndexOutOfBoundsException keeps being thrown although the theme is applied correctly.
 By catching the exception, we avoid spamming the exception to user.

* Fix button-bar buttons truncating long text with ellipsis

* Update Changelog

* use clear

* Revert "Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime"

This reverts commit 7361b5a.

* Update CHANGELOG.md

---------

Co-authored-by: Houssem Nasri <houssem.nasri@360t.com>
Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants