如何在 Java 中设置 SoftBevelBorder 的边框颜色?
若要在 Java 中设置 SoftBevelBorder 的边框颜色,请使用 Color 类并在创建边框时设置颜色 −
SoftBevelBorder border = new SoftBevelBorder( BevelBorder.RAISED, Color.ORANGE, Color.ORANGE.darker(), Color.BLUE, Color.magenta.brighter());
我们已将以下颜色设置为参数 −
highlightOuterColor: color to use for the bevel outer highlight highlightInnerColor : color to use for the bevel inner highlight shadowOuterColor : color to use for the bevel outer shadow shadowInnerColor : color to use for the bevel inner shadow
以下是一个在 Java 中设置 SoftBevelBorder 的边框颜色的示例 −
示例
package my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.BevelBorder; import javax.swing.border.SoftBevelBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SoftBevelBorder border = new SoftBevelBorder( BevelBorder.RAISED, Color.ORANGE, Color.ORANGE.darker(), Color.BLUE, Color.magenta.brighter()); JLabel label = new JLabel("This is a demo label with Soft Bevel Border"); label.setBorder(border); Container contentPane = frame.getContentPane(); contentPane.add(label, BorderLayout.CENTER); frame.setSize(550, 300); frame.setVisible(true); } }
输出
广告