8375567: Remove AppContext usage from Swing Motif L&F classes

Reviewed-by: serb, psadhukhan
This commit is contained in:
Phil Race 2026-01-30 19:07:59 +00:00
parent 3a4277db74
commit 32e00ff337
4 changed files with 8 additions and 44 deletions

View File

@ -42,8 +42,6 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonListener;
import javax.swing.plaf.basic.BasicButtonUI;
import sun.awt.AppContext;
/**
* MotifButton implementation
*
@ -55,20 +53,13 @@ public class MotifButtonUI extends BasicButtonUI {
private boolean defaults_initialized = false;
private static final Object MOTIF_BUTTON_UI_KEY = new Object();
private static final ComponentUI UI = new MotifButtonUI();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifButtonUI motifButtonUI =
(MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY);
if (motifButtonUI == null) {
motifButtonUI = new MotifButtonUI();
appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI);
}
return motifButtonUI;
return UI;
}
// ********************************

View File

@ -30,8 +30,6 @@ import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import sun.awt.AppContext;
/**
* MotifCheckBox implementation
*
@ -39,7 +37,7 @@ import sun.awt.AppContext;
*/
public class MotifCheckBoxUI extends MotifRadioButtonUI {
private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object();
private static final ComponentUI UI = new MotifCheckBoxUI();
private static final String propertyPrefix = "CheckBox" + ".";
@ -50,14 +48,7 @@ public class MotifCheckBoxUI extends MotifRadioButtonUI {
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifCheckBoxUI motifCheckBoxUI =
(MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY);
if (motifCheckBoxUI == null) {
motifCheckBoxUI = new MotifCheckBoxUI();
appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI);
}
return motifCheckBoxUI;
return UI;
}
@Override

View File

@ -29,8 +29,6 @@ import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicLabelUI;
import sun.awt.AppContext;
/**
* A Motif {@literal L&F} implementation of LabelUI.
* This merely sets up new default values in MotifLookAndFeel.
@ -39,16 +37,9 @@ import sun.awt.AppContext;
*/
public class MotifLabelUI extends BasicLabelUI
{
private static final Object MOTIF_LABEL_UI_KEY = new Object();
private static final ComponentUI UI = new MotifLabelUI();
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifLabelUI motifLabelUI =
(MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY);
if (motifLabelUI == null) {
motifLabelUI = new MotifLabelUI();
appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI);
}
return motifLabelUI;
return UI;
}
}

View File

@ -39,8 +39,6 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicToggleButtonUI;
import sun.awt.AppContext;
/**
* BasicToggleButton implementation.
*
@ -48,7 +46,7 @@ import sun.awt.AppContext;
*/
public class MotifToggleButtonUI extends BasicToggleButtonUI
{
private static final Object MOTIF_TOGGLE_BUTTON_UI_KEY = new Object();
private static final ComponentUI UI = new MotifToggleButtonUI();
protected Color selectColor;
@ -58,14 +56,7 @@ public class MotifToggleButtonUI extends BasicToggleButtonUI
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MotifToggleButtonUI motifToggleButtonUI =
(MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY);
if (motifToggleButtonUI == null) {
motifToggleButtonUI = new MotifToggleButtonUI();
appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI);
}
return motifToggleButtonUI;
return UI;
}
// ********************************