From 9b44ea39bf07b1d76e5bf9ebddbcae6bfc93e357 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 19 Feb 2026 17:58:36 +0000 Subject: [PATCH] 8378204: Remove AppContext from two Swing UI classes Reviewed-by: serb, kizune --- .../java/swing/plaf/motif/MotifRadioButtonUI.java | 13 ++----------- .../javax/swing/plaf/metal/MetalLabelUI.java | 3 +-- .../classes/sun/awt/im/InputMethodManager.java | 1 - 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java index f9a1dd7bb50..d78bcb13577 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java @@ -36,8 +36,6 @@ import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRadioButtonUI; -import sun.awt.AppContext; - /** * RadioButtonUI implementation for MotifRadioButtonUI * @@ -45,7 +43,7 @@ import sun.awt.AppContext; */ public class MotifRadioButtonUI extends BasicRadioButtonUI { - private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object(); + private static final ComponentUI UI = new MotifRadioButtonUI(); protected Color focusColor; @@ -55,14 +53,7 @@ public class MotifRadioButtonUI extends BasicRadioButtonUI { // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { - AppContext appContext = AppContext.getAppContext(); - MotifRadioButtonUI motifRadioButtonUI = - (MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY); - if (motifRadioButtonUI == null) { - motifRadioButtonUI = new MotifRadioButtonUI(); - appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI); - } - return motifRadioButtonUI; + return UI; } // ******************************** diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java index 35fc07de056..1d131c9d294 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -26,7 +26,6 @@ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; -import sun.awt.AppContext; import javax.swing.*; import javax.swing.plaf.*; diff --git a/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java b/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java index 0da7dbed6ea..c3968f19b60 100644 --- a/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java +++ b/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java @@ -35,7 +35,6 @@ import java.awt.PopupMenu; import java.awt.Menu; import java.awt.MenuItem; import java.awt.Toolkit; -import sun.awt.AppContext; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InvocationEvent;