@@ -564,8 +564,6 @@ public final class Main {
564
564
565
565
private final JMenuItem stopMenuItem ;
566
566
567
- private final JSVGCanvas svgCanvas ;
568
-
569
567
private final JTabbedPane tabbedPane = new JTabbedPane (SwingConstants .TOP );
570
568
571
569
private final SVGDocument templateSvgDocument ;
@@ -638,6 +636,8 @@ public final class Main {
638
636
639
637
private long stopTrayEntry ;
640
638
639
+ private JSVGCanvas svgCanvas ;
640
+
641
641
private volatile Rectangle totalDisplayBounds ;
642
642
643
643
private long tray ;
@@ -863,9 +863,19 @@ public void windowOpened(final WindowEvent e) {
863
863
visualizationPanel = new JPanel (new BorderLayout ());
864
864
tabbedPane .addTab (STRINGS .getString ("VISUALIZATION_TAB" ), visualizationPanel );
865
865
866
- svgCanvas = new JSVGCanvas (null , false , false );
867
- svgCanvas .setBorder (BorderFactory .createEtchedBorder (EtchedBorder .RAISED ));
868
- visualizationPanel .add (svgCanvas , BorderLayout .CENTER );
866
+ tabbedPane .addChangeListener (e -> {
867
+ if (e .getSource () != tabbedPane || tabbedPane .getSelectedComponent () != visualizationPanel ) {
868
+ return ;
869
+ }
870
+
871
+ if (svgCanvas == null ) {
872
+ svgCanvas = new JSVGCanvas (null , false , false );
873
+ svgCanvas .setBorder (BorderFactory .createEtchedBorder (EtchedBorder .RAISED ));
874
+ visualizationPanel .add (svgCanvas , BorderLayout .CENTER );
875
+
876
+ updateVisualizationPanel ();
877
+ }
878
+ });
869
879
870
880
final var exportPanel = new JPanel (LOWER_BUTTONS_FLOW_LAYOUT );
871
881
final var exportButton = new JButton (new ExportAction ());
@@ -3901,7 +3911,7 @@ public void updateTrayIconToolTip(final int batteryPercent) {
3901
3911
}
3902
3912
3903
3913
void updateVisualizationPanel () {
3904
- if (visualizationPanel == null || input == null ) {
3914
+ if (visualizationPanel == null || svgCanvas == null || input == null ) {
3905
3915
return ;
3906
3916
}
3907
3917
@@ -3924,11 +3934,11 @@ public void actionPerformed(final ActionEvent e) {
3924
3934
svgCanvas .setSVGDocument (workingCopySvgDocument );
3925
3935
}
3926
3936
});
3927
- } else {
3928
- modeComboBox .setModel (model );
3929
- modeComboBox .setSelectedIndex (model .getSize () > 0 ? 0 : -1 );
3930
3937
}
3931
3938
3939
+ modeComboBox .setModel (model );
3940
+ modeComboBox .setSelectedIndex (model .getSize () > 0 ? 0 : -1 );
3941
+
3932
3942
svgCanvas .setBackground (UIManager .getColor ("Panel.background" ));
3933
3943
}
3934
3944
0 commit comments