如何在 Java 中创建一个边框,其带有一个降低的斜角边缘?
使用 createLoweredBevelBorder() 方法创建一个边框,其带有一个降低的斜角边缘。我们将在标签组件上设置它 −
JLabel label; label = new JLabel("This has a border with a lowered bevel edge!"); label.setBorder(BorderFactory.createLoweredBevelBorder());
以下是一个创建边框带有一个降低的斜角边缘的示例 −
示例
package my; import javax.swing.BorderFactory; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("This has a border with a lowered bevel edge!"); label.setFont(new Font("Arial", Font.BOLD, 18)); label.setVerticalAlignment(JLabel.CENTER); label.setBorder(BorderFactory.createLoweredBevelBorder()); frame.add(label); frame.setSize(550,350); frame.setVisible(true); } }
输出
广告