import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
class Mypanel extends JPanel
{
Mypanel()
{
this.setBackground(Color.pink);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.black);
g.setFont(new Font("Arial",Font.BOLD,10));
g.drawString("click the buttons and get your favourite border ",100,20);
}
}
class JBut extends JFrame
{
JButton b1,b2,b3,b4,b5,b6;
JBut()
{
Container c=getContentPane();
Mypanel p=new Mypanel();
c.add(p);
c.setLayout(new GridLayout());
b1=new JButton("Raised Bevel Border");
b1=new JButton("Lowered Bevel Border");
b1=new JButton("Raised Etch Border");
b1=new JButton("Raised Etch Border");
b1=new JButton("Line Border");
b1=new JButton("Empty Border");
Border bd=BorderFactory.createBevelBorder(BevelBorder.RAI SED,Color.red,Color.green);
b1.setBorder(bd);
bd=BorderFactory.createBevelBorder(BevelBorder.LOW ERED,Color.red,Color.green);
b2.setBorder(bd);
bd=BorderFactory.createBevelBorder(EtchedBorder.RA ISED,Color.red,Color.green);
b3.setBorder(bd);
bd=BorderFactory.createBevelBorder(EtchedBorder.RA ISED,Color.red,Color.green);
b4.setBorder(bd);
bd=BorderFactory.createLineBorder(Color.red,5);
b5.setBorder(bd);
bd=BorderFactory.createEmptyBorder(10,10,10,10);
b6.setBorder(bd);
c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);
c.add(b5);
c.add(b6);
}
public static void main(String[] args)throws NullPointerException
{
JBut j=new JBut();
j.setSize(600,600);
j.setTitle("border choosing frame");
j.setVisible(true);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
################################################## #########################################
this is the run time error i am getting during running....... please help me out guyss!!!!!!
Exception in thread "main" java.lang.NullPointerException
at JBut.<init>(JBut.java:36)
at JBut.main(JBut.java:54)