CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > Swing > BevelBorder in Java Swing

Swing Tutorial

  • What Is Java Swing
  • First Program
  • What is AWT
  • Advantages of Swing Over AWT
  • JFrame
  • Swing Components
  • JLabel
  • JTextField
  • JPasswordField
  • JButton
  • Event Handling
  • FlowLayout
  • BorderLayout
  • GridLayout
  • GridBagLayout
  • BoxLayout
  • JPanel
  • JCheckBox
  • JRadioButton
  • Border Component
  • JComboBox
  • JList
  • JList with MVC
  • Mouse Event
  • Key Event
  • JMenuBar
  • JTextArea
  • Using Color
  • Use Font
  • Display Image/Icon
  • Dialog Box
  • JTable
  • JDesktopPane and JInternalFrame
  • JDesktopPane
  • JInternalFrame
  • Adapter Classes
  • Swing Timer
  • JScrollPane
  • JSlider
  • JProgressBar
  • JSeparator
  • JToolBar
  • ActionListener
  • ItemListener
  • Worker Thread
  • Nimbus Look and Feel

BevelBorder in Java Swing

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 2 min read · 0 Comments
Share: in X

BevelBorder is a border style in Java Swing that creates a raised or lowered beveled edge around a component. It is a subclass of the Border class and can be applied to any Swing component that supports borders.

The BevelBorder class has several constructors that allow us to customize the appearance of the border.

Following is an example of creating a BevelBorder with a raised edge:

import java.awt.BorderLayout;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

public class BevelBorderDemo {
	public static void main(String[] args) {
        JFrame frame = new JFrame("BevelBorder Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300, 200);

        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        panel.setLayout(new BorderLayout());
        panel.setSize(200, 100);

        JLabel label = new JLabel("Hello, World!");
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setVerticalAlignment(JLabel.CENTER);
        panel.add(label);

        frame.add(panel, BorderLayout.NORTH);
        frame.setVisible(true);
    }
}

In this example, a JPanel is created and a BevelBorder with a raised edge is applied to it using the createBevelBorder() method of the BorderFactory class. The JLabel “Hello, World!” is then added to the panel and centered within it. The panel is positioned at the top of the frame with the help of BorderLayout.NORTH.

Output:

Bevelborder in Java swing

There are two different styles of BevelBorder that we can choose from:

  • RAISED
  • LOWERED

In addition to the style, we can also specify the colors of the border using the following constructors:

BorderFactory.createBevelBorder(int type, Color highlight, Color shadow)
BorderFactory.createBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner)

The first constructor takes two colors: highlight and shadow, which are used for the raised and lowered edges, respectively. The second constructor takes four colors: highlightOuter, highlightInner, shadowOuter, and shadowInner, which are used for the four edges of the border.

Reference:

  • https://docs.oracle.com/javase/7/docs/api/javax/swing/border/BevelBorder.html

Related Posts:

  • EtchedBorder in Java Swing
  • Constructor in Java
  • CompoundBorder in Java Swing
  • What Is Java Swing? A Complete Guide to Java’s GUI Toolkit
  • JPanel in Java Swing
  • Inheritance in Java: A Developer’s Guide to Code Reusability
Tags:javaswing
Was this article helpful?
← Previous ArticlePseudo Parameters in AWS CloudFormation
Next Article →Math class in Java

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap