BorderFactory.createTitledBorder(String text)
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.border.Border;
public class MainClass {
public static void main(String args[]) {
JFrame f = new JFrame("JProgressBar Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JProgressBar progressBar = new JProgressBar();
progressBar.setValue(25);
progressBar.setStringPainted(true);
Border border = BorderFactory.createTitledBorder("Reading...");
progressBar.setBorder(border);
f.add(progressBar, BorderLayout.NORTH);
f.setSize(300, 100);
f.setVisible(true);
}
}
Related examples in the same category
1. | BorderFactory: createBevelBorder(int type,Color highlight,Color shadow) | | |
2. | BorderFactory: createCompoundBorder(Border outsideBorder, Border insideBorder) | | |
3. | BorderFactory: createEtchedBorder() | | |
4. | BorderFactory: createEmptyBorder(int top,int left,int bottom,int right) | | |
5. | BorderFactory: createLineBorder(Color color) | | |
6. | BorderFactory: createLineBorder(Color color, int thickness) | | |
7. | BorderFactory: createLoweredBevelBorder() | | |
8. | BorderFactory: createMatteBorder(int top, int left, int bottom, int right, Color color) | | |
9. | BorderFactory: createRaisedBevelBorder() | | |
10. | BorderFactory: createTitledBorder(Border b, String t, int j, int p) | | |