Blurry render of SwingNode

Kevin Rushforth kevin.rushforth at oracle.com
Mon Aug 24 18:34:54 UTC 2020


It's now in the JDK project in JBS:

https://bugs.openjdk.java.net/browse/JDK-8252255

I was able to reproduce it with the test program you sent.

-- Kevin


On 8/22/2020 12:28 PM, Kevin Rushforth wrote:
> Actually, someone already did file a bug report a couple days ago (I 
> see it in our internal incident tracker). Once it is transferred to 
> the JDK project, I'll add the standalone test program from this email 
> thread to the bug report, which should help in narrowing it down.
>
> Thanks.
>
> -- Kevin
>
>
> On 8/22/2020 11:40 AM, Michael Paus wrote:
>> Hi,
>> this is not a bug reporting list. Please file your bug report here
>> https://bugs.java.com/bugdatabase/ instead.
>> Best regards
>> Michael
>>
>> Am 22.08.20 um 19:57 schrieb Thangalin:
>>> Ahoy list,
>>>
>>> Running OpenJDK 14.0.1 on Windows 7, adding a SwingNode to a SplitPane
>>> causes the contents of the SwingNode to appear blurry. There's a full
>>> write-up with screen-shots at:
>>> https://stackoverflow.com/q/63444771/59087
>>>
>>> Here's an SSCCE that demonstrates the problem:
>>>
>>> import javafx.application.Application;
>>> import javafx.embed.swing.SwingNode;
>>> import javafx.scene.Scene;
>>> import javafx.scene.control.SplitPane;
>>> import javafx.scene.layout.StackPane;
>>> import javafx.scene.layout.VBox;
>>> import javafx.stage.Stage;
>>>
>>> import javax.swing.*;
>>> import java.awt.*;
>>>
>>> import static javafx.application.Platform.runLater;
>>> import static javax.swing.SwingUtilities.invokeLater;
>>>
>>> public class FlyingSourceTest extends Application {
>>>    public static void main( String[] args ) {
>>>      Application.launch( args );
>>>    }
>>>
>>>    @Override
>>>    public void start( Stage stage ) {
>>>      invokeLater( () -> {
>>>        stage.setTitle( "SSCCE" );
>>>
>>>        final var size = 120f;
>>>        final var font = new javafx.scene.text.Font( "Arial", size );
>>>        final var bgStyle = "-fx-background-color: white";
>>>
>>>        // FX label, StackPane
>>>        final var fxLabelTop = new javafx.scene.text.Text( "FX/FX" );
>>>        fxLabelTop.setFont( font );
>>>        final var fxStackPaneTop = new StackPane( fxLabelTop );
>>>
>>>        // FX label, StackPane
>>>        final var fxLabelSplit = new javafx.scene.text.Text( "FX 
>>> LABEL" );
>>>        fxLabelSplit.setFont( font );
>>>        final var fxLabelPane = new StackPane();
>>>        fxLabelPane.getChildren().addAll( fxLabelSplit );
>>>        fxLabelPane.setStyle( bgStyle );
>>>
>>>        // Swing label, StackPane
>>>        final var swingLabel = new JLabel( "SW LABEL" );
>>>        swingLabel.setBackground( Color.WHITE );
>>>        swingLabel.setOpaque( true );
>>>        swingLabel.setFont( swingLabel.getFont().deriveFont( 
>>> Font.PLAIN, size ) );
>>>        final var swingLabelNode = new SwingNode();
>>>        swingLabelNode.setContent( swingLabel );
>>>        final var swingLabelPane = new StackPane( swingLabelNode );
>>>        swingLabelPane.setStyle( bgStyle );
>>>
>>>        final var fxSplitPane = new SplitPane(
>>>            fxLabelPane, swingLabelPane );
>>>        fxSplitPane.setPrefSize( 1280, 300 );
>>>
>>>        final var root = new VBox();
>>>        root.getChildren().addAll( fxStackPaneTop, fxSplitPane );
>>>        root.setStyle( bgStyle );
>>>
>>>        runLater( () -> {
>>>          final var scene = new Scene( root );
>>>          stage.setScene( scene );
>>>          stage.show();
>>>        } );
>>>      } );
>>>    }
>>> }
>>>
>>> Closely compare the "L" from "SW LABEL" to the "L" from "FX LABEL".
>>> You'll see that the "SW LABEL" ell has what looks like stronger
>>> antialiasing applied.
>>>
>>> Changing the Graphics2D rendering hints on the JLabel has no effect.
>>> Changing the JLabel's AffineTransform to shift by 0.5px worsens the
>>> blurriness. Moving the SwingNode out of the SplitPane renders crisply,
>>> as expected. The font colours and background do not affect the
>>> outcome, but are there to make consistent output, which makes
>>> comparing easier.
>>>
>>> This problem affects neither X11 (Linux) nor OSX, only Windows.
>>>
>>> Been trying to fix this for several days without success.
>>>
>>> Any ideas why embedding a SwingNode within a SplitPane causes a blurry
>>> effect? And how can the problem be resolved?
>>>
>>> Thank you!
>>
>>
>



More information about the openjfx-dev mailing list