JButton button = new JButton("Click me"); Border border = button.getBorder();
JLabel label = new JLabel("Hello World!"); Border border = label.getBorder();In this example, we create a new JLabel object and call the getBorder method to retrieve the current border object. The javax.swing package library provides the JComponent class and the Border interface. However, the actual border objects used by the JComponent class are often implemented by classes in other packages such as javax.swing.border or java.awt.