I have aproblem in my code

this is aprogram to paint different shape by using only the drawline method its composed of two classes one contain the frame and buttons and the other contain the panel for drawing I dont know why when I run the programe I get this erorr messags and wats this error message mean ?
Exception in thread "main" java.lang.NullPointerException
     at paint.Paint.<init>(Paint.java:56)
     at paint.Paint.main(Paint.java:37
package paint;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class Paint {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    JButton line = new JButton("Line");
    JButton triangle = new JButton("Triangle");
    JButton rectangle = new JButton("Rectangle");
    JButton regularpolygon = new JButton("Regular Polygon");
    JTextArea regularpolygonno = new JTextArea(2,4);
    JButton circle = new JButton("Circle");
    JButton ellipse = new JButton("Ellipse");
    JButton polyline = new JButton("Polyline");
    JButton polygon = new JButton("Polygon");
    JMenuBar mbar = new JMenuBar();
    JMenu file = new JMenu("File");
    JMenuItem save = new JMenuItem("Save");
    JMenuItem load = new JMenuItem("Load");
    ppanel PaintPanel;
    int result;
    public static void main(String[] args) {
            Paint p = new Paint();
    public Paint (){
        mbar.add(file);
        file.add(load);
        file.add(save);
        panel.setPreferredSize(new Dimension(50, 100));
        panel.setBackground(Color.YELLOW);
        panel.add(line);
        panel.add(triangle);
        panel.add(rectangle);
        panel.add(regularpolygon);
        panel.add(regularpolygonno);
        panel.add(polyline);
        panel.add(polygon);
        panel.add(circle);
        panel.add(ellipse);
        PaintPanel.setPreferredSize(new Dimension(600, 600));
        frame.setTitle("Paint");
        frame.setSize(1200,1200);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setJMenuBar(mbar);
        frame.add(panel, BorderLayout.WEST);
        frame.add(PaintPanel, BorderLayout.EAST);
        frame.pack();
        frame.setVisible(true);
        line.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            line_actionPerformed(e);
        triangle.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            triangle_actionPerformed(e);
        rectangle.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            rectangle_actionPerformed(e);
        regularpolygon.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            regularpolygon_actionPerformed(e);
        circle.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            circle_actionPerformed(e);
        ellipse.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            ellipse_actionPerformed(e);
        polyline.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            polyline_actionPerformed(e);
        polygon.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {
            polygon_actionPerformed(e);
    public void actionPerformed(ActionEvent e) {
            if(e.getActionCommand()=="Load"){
            System.out.println("A Seat Reserved");            
    private void line_actionPerformed(ActionEvent e) {
    result=1;
    System.out.println(result);
    private void triangle_actionPerformed(ActionEvent e) {
    result=2;
    System.out.println(result);
    private void regularpolygon_actionPerformed(ActionEvent e) {
    result=3;
    System.out.println(result);
    private void circle_actionPerformed(ActionEvent e) {
    result=4;
    System.out.println(result);
    private void ellipse_actionPerformed(ActionEvent e) {
    result=5;
    System.out.println(result);
    private void rectangle_actionPerformed(ActionEvent e) {
    result=6;
    System.out.println(result);
    private void polyline_actionPerformed(ActionEvent e) {
    result=7;
    System.out.println(result);
    private void polygon_actionPerformed(ActionEvent e) {
    result=8;
    System.out.println(result);
    public int callresult(){
            return result;
}

this code is just acompelete for the second class in 2nd replay
    @Override public void paintComponent(Graphics g ){
    super.paintComponents(g);
    for(i=0 ; i< al.size(); i++){
            if (drawLines[4] == 1){
pressed = false;
if(pressed1 == 1 && drawLines[i][4] != 1){
pressed1 = 0;
g.drawLine(drawLines[i][0],drawLines[i][1],xplgn,yplgn);
System.out.println("problem here1");
}else
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][3]);
}else if (drawLines[i][4] == 2 ){
pressed = false;
pressed1 = 0;
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][1]);
g.drawLine(drawLines[i][2],drawLines[i][1],drawLines[i][2],drawLines[i][3]);
g.drawLine(drawLines[i][2],drawLines[i][3],drawLines[i][0],drawLines[i][3]);
g.drawLine(drawLines[i][0],drawLines[i][3],drawLines[i][0],drawLines[i][1]);
}else if(drawLines[i][4] == 3){
pressed = false;
pressed1 = 0;
for(int l=0;l<drawLines[i][5]; l++){
double r =Math.sqrt(Math.pow(drawLines[i][0]-drawLines[i][2],2)+Math.pow(drawLines[i][1]-drawLines[i][3],2)) ;
double x11 = r*Math.cos((2*pi/drawLines[i][5])*(l));
double y11 = r*Math.sin((2*pi/drawLines[i][5])*(l));
double x22 = r*Math.cos((2*pi/drawLines[i][5])*(l+1));
double y22 = r*Math.sin((2*pi/drawLines[i][5])*(l+1));
int sumx1 = drawLines[i][0]+(int)x11;
int sumy1 = drawLines[i][1]+(int)y11;
int sumx2 = drawLines[i][0]+(int)x22;
int sumy2 = drawLines[i][1]+(int)y22;
g.drawLine(sumx1,sumy1,sumx2,sumy2);
}else if(drawLines[i][4] == 4) {
pressed = false;
pressed1 = 0;
int n =360;
for(int l=0;l<n; l++){
double r =Math.sqrt(Math.pow(drawLines[i][0]-drawLines[i][2],2)+Math.pow(drawLines[i][1]-drawLines[i][3],2)) ;
double x11 = r*Math.cos((2*pi/n)*(l));
double y11 = r*Math.sin((2*pi/n)*(l));
double x22 = r*Math.cos((2*pi/n)*(l+1));
double y22 = r*Math.sin((2*pi/n)*(l+1));
int sumx1 = drawLines[i][0]+(int)x11;
int sumy1 = drawLines[i][1]+(int)y11;
int sumx2 = drawLines[i][0]+(int)x22;
int sumy2 = drawLines[i][1]+(int)y22;
g.drawLine(sumx1,sumy1,sumx2,sumy2);
}else if(drawLines[i][4] == 5) {
pressed = false;
pressed1 = 0;
int n =360;
for(int l=0;l<n; l++){
double a = Math.abs(drawLines[i][0] - drawLines[i][2]);
double b = Math.abs(drawLines[i][1] - drawLines[i][3]);
double x11 = a*Math.cos((2*pi/n)*(l));
double y11 = b*Math.sin((2*pi/n)*(l));
double x22 = a*Math.cos((2*pi/n)*(l+1));
double y22 = b*Math.sin((2*pi/n)*(l+1));
int sumx1 = drawLines[i][0]+(int)x11;
int sumy1 = drawLines[i][1]+(int)y11;
int sumx2 = drawLines[i][0]+(int)x22;
int sumy2 = drawLines[i][1]+(int)y22;
g.drawLine(sumx1,sumy1,sumx2,sumy2);
}else if(drawLines[i][4] == 6){
pressed = false;
pressed1 = 0;
int n =4;
for(int l=0;l<n; l++){
double r =Math.sqrt(Math.pow(drawLines[i][0]-drawLines[i][2],2)+Math.pow(drawLines[i][1]-drawLines[i][3],2)) ;
double x11 = r*Math.cos((pi/n)-(2*pi/n)*(l));
double y11 = r*Math.sin((pi/n)-(2*pi/n)*(l));
double x22 = r*Math.cos((pi/n)-(2*pi/n)*(l+1));
double y22 = r*Math.sin((pi/n)-(2*pi/n)*(l+1));
int sumx1 = drawLines[i][0]+(int)x11;
int sumy1 = drawLines[i][1]+(int)y11;
int sumx2 = drawLines[i][0]+(int)x22;
int sumy2 = drawLines[i][1]+(int)y22;
g.drawLine(sumx1,sumy1,sumx2,sumy2);
}else if(drawLines[i][4] == 7){
pressed1 = 0;
if(pressed == false){
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][3]);
pressed = true;
}else {
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][3]);
} else if (drawLines[i][4] == 8) {
pressed = false;
if(pressed1 == 0){
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][3]);
xplgn = drawLines[i][0];
yplgn = drawLines[i][1];
pressed1 = 1;
}else {
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][3]);

Similar Messages

Maybe you are looking for

  • Time Machine deleted my old backups and crapped out midstream

    I had just gotten my failing hard drive replaced, and restored from Time Machine backup. So far so good. So a week later, I wanted to upgrade to Mountain Lion, but figured I should be responsible and run Time Machine backup again before doing the upg

  • Displaying a group of  data in different colums

    I have a problem with displaying a group of data in different colums. I want to display a group of data like this: Column 1 --- Column2 ----- Column3 data1 data6 data11 data2 data7 data12 data3 data8 data13 data4 data9 data14 data5 data10 data15 That

  • Using external HD as media disc?

    Hello everybody. Just upgraded to Leopard and also got an external HD. I am wondering if there is some way to use it as a media disc? In other words, I want all my folders such as Music, Pictures, Movies etc to be located on my external so that I can

  • External Authentication in 9.0.2

    I have an external authentication module with Login Server 3.0.9 and I'm migrating my applications to the new release. I checked for the ssoauthx.pks package specification and it says that external authentication module is no longer supported with th

  • Laserjet 3100 driver for Vista OS

    Need help finding a driver for my Laserjet 3100 on Vista OS Thanks