Java Tutorial/Swing/BevelBorder
Содержание
14. A Raised Bevel Border
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
public class ABevelBorder {
public static void main(String args[]) {
JFrame frame = new JFrame("Bevel Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border raisedBorder = BorderFactory.createRaisedBevelBorder();
JButton button = new JButton("Raised");
button.setBorder(raisedBorder);
frame.add(button);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
14. BevelBorder Class
A bevel border draws a border with a three-dimensional appearance: raised or lowered.
public BevelBorder(int bevelType)
Border bevelBorder = new BevelBorder(BevelBorder.RAISED);
public static Border createBevelBorder(int bevelType)
Border bevelBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED);
public static Border createLoweredBevelBorder()
Border bevelBorder = BorderFactory.createLoweredBevelBorder();
public static Border createRaisedBevelBorder()
Border bevelBorder = BorderFactory.createRaisedBevelBorder();
public BevelBorder(int bevelType, Color highlight, Color shadow)
Border bevelBorder = new BevelBorder(BevelBorder.RAISED, Color.PINK, Color.RED);
public static Border createBevelBorder(int bevelType, Color highlight, Color shadow)
Border bevelBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.PINK, Color.RED);
public BevelBorder(int bevelType, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner)
Border bevelBorder = new BevelBorder(BevelBorder.RAISED, Color.PINK, Color.PINK.brighter(), Color.RED, Color.RED.darker());
public static Border createBevelBorder(int bevelType, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner)
Border bevelBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.PINK, Color.PINK.brighter(), Color.RED, Color.RED.darker());
14. Creating BevelBorder with Border color setting
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
public class ABevelBorderLoweredBevelBorderRAISED {
public static void main(String args[]) {
JFrame frame = new JFrame("Bevel Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.PINK,
Color.RED);
// Border myLoweredBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.PINK,
// Color.RED);
JButton button = new JButton("Raised");
button.setBorder(myRaisedBorder);
frame.add(button);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
14. Lowered BevelBorder
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
public class ABevelBorderLoweredBevelBorder {
public static void main(String args[]) {
JFrame frame = new JFrame("Bevel Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border loweredBorder = BorderFactory.createLoweredBevelBorder();
JButton button = new JButton("Raised");
button.setBorder(loweredBorder);
frame.add(button);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
14. Using BevelBorder"s constructor to create BevelBorder
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
public class BevelBorderWithDiffBorderColor {
public static void main(String args[]) {
JFrame frame = new JFrame("Sample Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border bevelBorder = new BevelBorder(BevelBorder.RAISED, Color.RED, Color.RED.darker(),
Color.PINK, Color.PINK.brighter());
JLabel aLabel = new JLabel("Bevel");
aLabel.setBorder(bevelBorder);
aLabel.setHorizontalAlignment(JLabel.CENTER);
frame.add(aLabel);
frame.setSize(400, 200);
frame.setVisible(true);
}
}