mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-16 05:15:22 +00:00
7025987: Nimbus L&F increases insets unexpectedly
Reviewed-by: alexp
This commit is contained in:
parent
b85845f9da
commit
650afe234d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2011, 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,13 +26,11 @@ package javax.swing.plaf.nimbus;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Color;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -58,7 +56,9 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
|
||||
@Override
|
||||
protected Object[] getExtendedCacheKeys(JComponent c) {
|
||||
return new Object[] {c.getBackground()};
|
||||
return (c != null)
|
||||
? new Object[] { c.getBackground() }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,6 +85,7 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
*/
|
||||
protected void doPaint(Graphics2D g, JComponent c, int width, int height,
|
||||
Object[] extendedCacheKeys) {
|
||||
Color color = (c == null) ? Color.BLACK : c.getBackground();
|
||||
BufferedImage img1 = new BufferedImage(IMG_SIZE,IMG_SIZE,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
BufferedImage img2 = new BufferedImage(IMG_SIZE,IMG_SIZE,
|
||||
@ -93,14 +94,14 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
Graphics2D g2 = (Graphics2D)img1.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setColor(c.getBackground());
|
||||
g2.setColor(color);
|
||||
g2.fillRoundRect(2,0,26,26,RADIUS,RADIUS);
|
||||
g2.dispose();
|
||||
// draw shadow
|
||||
InnerShadowEffect effect = new InnerShadowEffect();
|
||||
effect.setDistance(1);
|
||||
effect.setSize(3);
|
||||
effect.setColor(getLighter(c.getBackground(),2.1f));
|
||||
effect.setColor(getLighter(color, 2.1f));
|
||||
effect.setAngle(90);
|
||||
effect.applyEffect(img1,img2,IMG_SIZE,IMG_SIZE);
|
||||
// draw outline to img2
|
||||
@ -108,7 +109,7 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setClip(0,28,IMG_SIZE,1);
|
||||
g2.setColor(getLighter(c.getBackground(),0.90f));
|
||||
g2.setColor(getLighter(color, 0.90f));
|
||||
g2.drawRoundRect(2,1,25,25,RADIUS,RADIUS);
|
||||
g2.dispose();
|
||||
// draw final image
|
||||
@ -150,7 +151,7 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
* @param c the component for which this border insets value applies
|
||||
*/
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return INSETS;
|
||||
return (Insets) INSETS.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2011, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4856008
|
||||
* @bug 4856008 7025987
|
||||
* @summary Tests border insets
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
@ -59,6 +59,7 @@ import javax.swing.plaf.basic.BasicBorders;
|
||||
import javax.swing.plaf.basic.BasicToolBarUI;
|
||||
import javax.swing.plaf.metal.MetalBorders;
|
||||
import javax.swing.plaf.metal.MetalComboBoxEditor;
|
||||
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||
|
||||
import sun.swing.plaf.synth.SynthFileChooserUI;
|
||||
|
||||
@ -134,6 +135,9 @@ public class Test4856008 {
|
||||
|
||||
//+ SynthFileChooserUI.UIBorder:
|
||||
new SynthFileChooser().getUIBorder(),
|
||||
|
||||
//+ LoweredBorder:
|
||||
new NimbusLookAndFeel().getDefaults().getBorder("TitledBorder.border"),
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2011, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6978482
|
||||
* @bug 6978482 7025987
|
||||
* @summary Tests unchecked casts
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
@ -58,6 +58,7 @@ import javax.swing.plaf.basic.BasicBorders;
|
||||
import javax.swing.plaf.basic.BasicToolBarUI;
|
||||
import javax.swing.plaf.metal.MetalBorders;
|
||||
import javax.swing.plaf.metal.MetalComboBoxEditor;
|
||||
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||
|
||||
import sun.swing.plaf.synth.SynthFileChooserUI;
|
||||
|
||||
@ -132,6 +133,9 @@ public class Test6978482 {
|
||||
|
||||
//+ SynthFileChooserUI.UIBorder:
|
||||
new SynthFileChooser().getUIBorder(),
|
||||
|
||||
//+ LoweredBorder:
|
||||
new NimbusLookAndFeel().getDefaults().getBorder("TitledBorder.border"),
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user