import java.awt.Color;
import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
public class MainClass {
public static void main(final String args[]) {
JFrame frame = new JFrame("Justified Titled Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border greenBorder = BorderFactory.createLineBorder(Color.GREEN, 2);
Border blueBorder = BorderFactory.createLineBorder(Color.BLUE, 2);
Border magentaBorder = BorderFactory.createLineBorder(Color.MAGENTA, 2);
Border twoColorBorder = new CompoundBorder(magentaBorder, blueBorder);
Border threeColorBorder = new CompoundBorder(twoColorBorder, greenBorder);
JButton rainbowButton = new JButton("Rainbow");
rainbowButton.setBorder(threeColorBorder);
Container contentPane = frame.getContentPane();
contentPane.add(rainbowButton);
frame.setSize(300, 200);
frame.setVisible(true);
}
}
|