Studyon Minte9.com
Java SE




Border




package testexample; import java.awt.*; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Test extends JFrame { public static void main(String[] args) { JFrame frame = new Test(); frame.setBounds(200, 200, 300, 200); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); } public Test() { JLabel label = new JLabel("my text"); label.setBorder(BorderFactory.createLineBorder(Color.red)); JPanel panel = new JPanel(); panel.add(label); add(panel); // Outputs: a label with red border } }
 


http://docs.oracle.com/javase/tutorial/uiswing/components/border.html