System File Chooser: on Linux when JavaFX is used in application, then always use Swing file chooser because system file dialog does work (PR #988)

with Java 8, some GLib related messages are logged to console and system file dialog is not shown
e.g.: `GLib-GObject-WARNING **: cannot register existing type 'GdkDisplayManager'`

with Java 17, the system file dialog is shown, but then JavaFX no longer works
with Java 21, the application quits/crashes immediately when trying to show system file dialog

also fixed Error Prone warning in `getFiltersForDialog()`
This commit is contained in:
Karl Tauber
2025-12-01 13:41:54 +01:00
parent 1c6e8774cf
commit 58e073a05b
2 changed files with 50 additions and 5 deletions

View File

@@ -77,7 +77,7 @@ public class FlatSystemFileChooserTest
FlatSystemFileChooserTest() {
initComponents();
if( !NativeJFileChooser.FX_AVAILABLE ) {
if( SystemInfo.isLinux || !NativeJFileChooser.FX_AVAILABLE ) {
javafxOpenButton.setEnabled( false );
javafxSaveButton.setEnabled( false );
}
@@ -231,7 +231,7 @@ public class FlatSystemFileChooserTest
int fileTypeIndex = fileTypeIndexSlider.getValue();
if( !useAcceptAllFileFilterCheckBox.isSelected() )
fc.setAcceptAllFileFilterUsed( false );
for( int i = 0; i < fileTypes.length; i += 2 ) {
for( int i = 0; i < fileTypes.length; i += 2 ) {
fc.addChoosableFileFilter( "*".equals( fileTypes[i+1] )
? fc.getAcceptAllFileFilter()
: new SystemFileChooser.FileNameExtensionFilter( fileTypes[i], fileTypes[i+1].split( ";" ) ) );
@@ -282,7 +282,7 @@ public class FlatSystemFileChooserTest
int fileTypeIndex = fileTypeIndexSlider.getValue();
if( !useAcceptAllFileFilterCheckBox.isSelected() )
fc.setAcceptAllFileFilterUsed( false );
for( int i = 0; i < fileTypes.length; i += 2 ) {
for( int i = 0; i < fileTypes.length; i += 2 ) {
fc.addChoosableFileFilter( "*".equals( fileTypes[i+1] )
? fc.getAcceptAllFileFilter()
: new FileNameExtensionFilter( fileTypes[i], fileTypes[i+1].split( ";" ) ) );