/* Program : 4 Program to demonstrate different types of borders to use on different components Development Status : Completed and Tested Developed by : Malhar Vora Developed on : 20-11-2010 Email : vbmade2000@gmail.com WebSite : www.malhar2010.blogspot.com *********************************************************************************/ import javax.swing.*; import java.awt.*; import javax.swing.border.*; public class P4 extends JFrame { //LineBorder JPanel paneLine = null; JLabel lblLine = null; JTextField txtLine = null; JButton btnLine = null; //BevelBorder JPanel paneBevel = null; JLabel lblBevel = null; JTextField txtBevel = null; JButton btnBevel = null; //EtchedBorder JPanel paneEtched = null; JLabel lblEtched = null; JTextField txtEtched = null; JButton btnEtched = null; //MatteBorder JPanel paneMatte = null; JLabel lblMatte = null; JTextField txtMatte = null; JButton btnMatte = null; //SoftBevelBorder JPanel paneSoftBevel = null; JLabel lblSoftBevel = null; JTextField txtSoftBevel = null; JButton btnSoftBevel = null; //TitledBorder JPanel paneTitled = null; JLabel lblTitled = null; JTextField txtTitled = null; JButton btnTitled = null; JTabbedPane tabMain = null; P4() { tabMain = new JTabbedPane(); //LineBorder paneLine = new JPanel(); lblLine = new JLabel("Line Border"); txtLine = new JTextField("Line Border"); btnLine = new JButton("Line Border"); //BevelBorder paneBevel = new JPanel(); lblBevel = new JLabel("Bevel Border"); txtBevel = new JTextField("Bevel Border"); btnBevel = new JButton("Bevel Border"); //EtchedBorder paneEtched = new JPanel(); lblEtched = new JLabel("Etched Border"); txtEtched = new JTextField("Etched Border"); btnEtched = new JButton("Etched Border"); //MatteBorder paneMatte = new JPanel(); lblMatte = new JLabel("Matte Border"); txtMatte = new JTextField("Matte Border"); btnMatte = new JButton("Matte Border"); //SoftBevelBorder paneSoftBevel = new JPanel(); lblSoftBevel = new JLabel("SoftBevel Border"); txtSoftBevel = new JTextField("SoftBevel Border"); btnSoftBevel = new JButton("SoftBevel Border"); //TitledBorder paneTitled = new JPanel(); lblTitled = new JLabel("Titled Border"); txtTitled = new JTextField("Titled Border"); btnTitled = new JButton("Titled Border"); //=============================================================== //LineBorder paneLine.setLayout(null); lblLine.setBorder(new LineBorder(Color.RED,3)); txtLine.setBorder(new LineBorder(Color.RED,3)); btnLine.setBorder(new LineBorder(Color.RED,3)); lblLine.setBounds(10,10,100,30); txtLine.setBounds(10,50,100,30); btnLine.setBounds(10,90,100,30); paneLine.add(lblLine); paneLine.add(txtLine); paneLine.add(btnLine); //BevelBorder paneBevel.setLayout(null); lblBevel.setBorder(new BevelBorder(BevelBorder.RAISED)); txtBevel.setBorder(new BevelBorder(BevelBorder.RAISED)); btnBevel.setBorder(new BevelBorder(BevelBorder.RAISED)); lblBevel.setBounds(10,10,100,30); txtBevel.setBounds(10,50,100,30); btnBevel.setBounds(10,90,100,30); paneBevel.add(lblBevel); paneBevel.add(txtBevel); paneBevel.add(btnBevel); //EtchedBorder paneEtched.setLayout(null); lblEtched.setBorder(new EtchedBorder(EtchedBorder.RAISED)); txtEtched.setBorder(new EtchedBorder(EtchedBorder.RAISED)); btnEtched.setBorder(new EtchedBorder(EtchedBorder.RAISED)); lblEtched.setBounds(10,10,100,30); txtEtched.setBounds(10,50,100,30); btnEtched.setBounds(10,90,100,30); paneEtched.add(lblEtched); paneEtched.add(txtEtched); paneEtched.add(btnEtched); //MatteBorder paneMatte.setLayout(null); lblMatte.setBorder(new MatteBorder(5, 10, 5, 10, Color.GREEN)); txtMatte.setBorder(new MatteBorder(5, 10, 5, 10, Color.GREEN)); btnMatte.setBorder(new MatteBorder(5, 10, 5, 10, Color.GREEN)); lblMatte.setBounds(10,10,100,30); txtMatte.setBounds(10,50,100,30); btnMatte.setBounds(10,90,100,30); paneMatte.add(lblMatte); paneMatte.add(txtMatte); paneMatte.add(btnMatte); //SoftBevelBorder paneSoftBevel.setLayout(null); lblSoftBevel.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED)); txtSoftBevel.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED)); btnSoftBevel.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED)); lblSoftBevel.setBounds(10,10,100,30); txtSoftBevel.setBounds(10,50,100,30); btnSoftBevel.setBounds(10,90,100,30); paneSoftBevel.add(lblSoftBevel); paneSoftBevel.add(txtSoftBevel); paneSoftBevel.add(btnSoftBevel); //TitledBorder paneTitled.setLayout(null); lblTitled.setBorder(new TitledBorder("Label with Titled Border")); txtTitled.setBorder(new TitledBorder("TextField with Border")); btnTitled.setBorder(new TitledBorder("Button with Titled Border")); lblTitled.setBounds(10,10,150,60); txtTitled.setBounds(10,80,150,60); btnTitled.setBounds(10,160,150,60); paneTitled.add(lblTitled); paneTitled.add(txtTitled); paneTitled.add(btnTitled); //=============================================================================== tabMain.addTab("Line Border",paneLine); tabMain.addTab("Bevel Border",paneBevel); tabMain.addTab("Etched Border",paneEtched); tabMain.addTab("Matte Border",paneMatte); tabMain.addTab("SoftBevel Border",paneSoftBevel); tabMain.addTab("Titled Border",paneTitled); //=============================================================================== getContentPane().add(tabMain); setTitle("Program 4 - Developed by Malhar Vora"); setSize(400,500); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String []str) { P4 p = new P4(); } }
Wednesday, November 24, 2010
Program to demonstrate different types of borders to use on different components
Labels:
Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.