Java by API/javax.swing.border/EtchedBorder — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 17:43, 31 мая 2010
Содержание
EtchedBorder.LOWERED
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
public class MainClass {
public static void main(String[] a) {
JFrame frame = new JFrame("Etched Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED);
Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED);
JButton raisedButton = new JButton("Raised");
raisedButton.setBorder(raisedBorder);
JButton loweredButton = new JButton("Lowered");
loweredButton.setBorder(loweredBorder);
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(1, 2, 5, 5));
contentPane.add(raisedButton);
contentPane.add(loweredButton);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
EtchedBorder.RAISED
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
public class MainClass {
public static void main(String[] a) {
JFrame frame = new JFrame("Etched Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED);
Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED);
JButton raisedButton = new JButton("Raised");
raisedButton.setBorder(raisedBorder);
JButton loweredButton = new JButton("Lowered");
loweredButton.setBorder(loweredBorder);
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(1, 2, 5, 5));
contentPane.add(raisedButton);
contentPane.add(loweredButton);
frame.setSize(300, 100);
frame.setVisible(true);
}
}
new EtchedBorder(int etchType, Color highlight, Color shadow)
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Sample Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, Color.RED, Color.PINK);
JLabel aLabel = new JLabel("Bevel");
aLabel.setBorder(etchedBorder);
aLabel.setHorizontalAlignment(JLabel.CENTER);
frame.add(aLabel);
frame.setSize(400, 200);
frame.setVisible(true);
}
}
new EtchedBorder(int style)
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
public class MainClass {
public static void main(String[] a) {
JFrame frame = new JFrame("Etched Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED);
Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED);
JButton raisedButton = new JButton("Raised");
raisedButton.setBorder(raisedBorder);
JButton loweredButton = new JButton("Lowered");
loweredButton.setBorder(loweredBorder);
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(1, 2, 5, 5));
contentPane.add(raisedButton);
contentPane.add(loweredButton);
frame.setSize(300, 100);
frame.setVisible(true);
}
}