Java border example

-In this article I will guide you to learn how to use the java border, known as contours in Java. We will in turn explore four types of contours as listed.

Use simple java border

-To create borders, you use the following syntax and depend on the type of border you want to create.
Border border = BorderFactory.create ...
-Now we will code to create some simple java border types as shown below.
Java border example

  •  The line border is a java border type with some color.
  •  Empty java border is a blank border, it is often used to create space, use as a padding to set the distance between content and outside.
  • Raised etched java border is a floating border, engraved on top.
  • Lowered etched java border is engraved border but sinks to the bottom.
  • Raised bevel java border is the oblique edge border.
  • Lowered bevel java border is the border of the form of the corner down.

-File name: DemoSimpleBorders.java
Java border example

Use matte java border

-Matte java border is a form that allows us to use colors or images that create borders. It also allows us to set the size of the edges. However, when using images, you should set the size by -1, then the size will remain the same, not lost. Code example.
Java border example
-File name: DemoMatteBorder.java
Java border example

Use title java border

-Title java Border is a border type with headings. You can set the title in the left, right, middle, bottom of the border, etc. You can also set the border to be one of the border types that have been created, otherwise the border will be the default by faint blue.
Java border example
-File name: DemoTitleBorder.java
Java border example

Use the compound java border


-Compound java Border is a combination of borders together. We can use it to create beautiful borders as you like, or you can create padding or margin content with the border by associating empty borders with other borders by the bound boundary.
Java border example
-File name: DemoCompoundBorder.java
Java border example
-Read more about create jmenu java swing example:

Comments