import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.TitledBorder;
public class MainClass {
public static void main(final String args[]) {
JFrame frame = new JFrame("Positioned Titled Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop");
aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP);
JButton aboveTopButton = new JButton();
aboveTopButton.setBorder(aboveTopBorder);
Container contentPane = frame.getContentPane();
contentPane.add(aboveTopButton);
frame.setSize(300, 200);
frame.setVisible(true);
}
}
|