How to create a border with a lowered beveled edge in Java?

Java 8Object Oriented ProgrammingProgramming

Use the createLoweredBevelBorder() method to create a border with a lowered beveled edge. We will set it on the label component −

JLabel label;
label = new JLabel("This has a border with a lowered bevel edge!");
label.setBorder(BorderFactory.createLoweredBevelBorder());

The following is an example to create a border with a lowered beveled edge −

Example

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);
   }
}

Output

raja
Published on 06-Jun-2019 09:19:25
Advertisements