Java Program to use Soft Bevel Border in Swing

Java 8Object Oriented ProgrammingProgramming

Here, we are creating soft beven border on JComboBox:

JComboBox comboBox = new JComboBox(list);

Now, set bevel border:

comboBox.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));

The following is an example to use soft bevel border in Swing:

Example

import java.awt.Font;
import java.awt.GridBagLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
public class SwingDemo {
   static final String list[] = { "One", "Two", "Three", "Four", "Five", "Six" };
   public static void main(String[] args) {
      JFrame window = new JFrame("ComboBox Example");
      JPanel panel = new JPanel();
      panel.setLayout(new GridBagLayout());
      JComboBox comboBox = new JComboBox(list);
      comboBox.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
      panel.add(comboBox);
      window.add(panel);
      window.setSize(600, 400);
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      window.setVisible(true);
   }
}

Output

raja
Published on 03-May-2019 07:53:14
Advertisements