Skip to main content


Showing posts from January, 2009

Swing: Borders

Swing provides various borders those have different look and size. You can add the border using setBorder() method for any component. JComponent provides this method for all available components. javax.swing.border package has various deferent types of borders. You can create border through two ways: The BorderFactory class creates any kind of border for you using static "factory" methods. Creating and setting a component's border, then, is simple:     JLabel labelTwo = new JLabel("etched border.");     labelTwo.setBorder(BorderFactory.createEtchedBorder(  ));   You can create the instance of border class directly.   JLabel labelTwo = new JLabel("raised etched border."); labelTwo.setBorder( new EtchedBorder(EtchedBorder.RAISED) ); There are following border classes BevelBorder SoftBevelBorder EmptyBorder EtchedBorder LineBorder MatteBorder TitledBorder CompoundBorder import  java.awt. * ; import  java.awt.event. * ; import  javax.swing. * ; imp