8349111: Enhance Swing supports

Co-authored-by: Jan Kratochvil <jkratochvil@openjdk.org>
Reviewed-by: abakhtin, andrew, mbalao
Backport-of: 8a34c18c6593da54b6b8695d645310db95f23509
This commit is contained in:
Alexei Voitylov 2025-06-06 19:34:02 +00:00 committed by Andrew John Hughes
parent 33624e872e
commit f1d976060f
4 changed files with 30 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -404,7 +404,11 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
}
tabPane.addContainerListener(getHandler());
if (tabPane.getTabCount() > 0) {
htmlViews = createHTMLVector();
Boolean htmlDisabled = (Boolean)
tabPane.getClientProperty("html.disable");
if (!(Boolean.TRUE.equals(htmlDisabled))) {
htmlViews = createHTMLVector();
}
}
}
@ -3466,8 +3470,10 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
private void updateHtmlViews(int index) {
final String title = tabPane.getTitleAt(index);
Boolean htmlDisabled = (Boolean)
tabPane.getClientProperty("html.disable");
final boolean isHTML = BasicHTML.isHTMLString(title);
if (isHTML) {
if (isHTML && !(Boolean.TRUE.equals(htmlDisabled))) {
if (htmlViews == null) { // Initialize vector
htmlViews = createHTMLVector();
} else { // Vector already exists

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -701,6 +701,11 @@ public class TitledBorder extends AbstractBorder
}
private JLabel getLabel(Component c) {
if (c instanceof JComponent) {
JComponent comp = (JComponent)c;
this.label.putClientProperty("html.disable",
comp.getClientProperty("html.disable"));
}
this.label.setText(getTitle());
this.label.setFont(getFont(c));
this.label.setForeground(getColor(c));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -423,6 +423,11 @@ public class BasicOptionPaneUI extends OptionPaneUI {
} else {
JLabel label;
label = new JLabel( s, JLabel.LEADING );
if (Boolean.TRUE.equals(
this.optionPane.getClientProperty("html.disable"))) {
label.putClientProperty("html.disable", true);
BasicHTML.updateRenderer(label, label.getText());
}
label.setName("OptionPane.label");
configureMessageLabel(label);
addMessageComponents(container, cons, label, maxll, true);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -417,7 +417,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
}
tabPane.addContainerListener(getHandler());
if (tabPane.getTabCount()>0) {
htmlViews = createHTMLVector();
Boolean htmlDisabled = (Boolean)
tabPane.getClientProperty("html.disable");
if (!(Boolean.TRUE.equals(htmlDisabled))) {
htmlViews = createHTMLVector();
}
}
}
@ -3584,8 +3588,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
private void updateHtmlViews(int index) {
String title = tabPane.getTitleAt(index);
Boolean htmlDisabled = (Boolean)
tabPane.getClientProperty("html.disable");
boolean isHTML = BasicHTML.isHTMLString(title);
if (isHTML) {
if (isHTML && !(Boolean.TRUE.equals(htmlDisabled))) {
if (htmlViews==null) { // Initialize vector
htmlViews = createHTMLVector();
} else { // Vector already exists