----jGRASP exec: java BorderTest
Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1045)
at java.awt.Container.add(Container.java:927)
at BorderTest.<init>(BorderTest.java:120)
at BorderTest.main(BorderTest.java:40)
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Osea si compila pero al correrlo me lanza el error anterior..
MI CODIGO:
Código:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
//--------------
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class BorderTest extends JFrame
{
//-----------------
private static final long serialVersionUID = -5807365968277501395L;
private JPanel pnorte;
private JPanel psur;
private JPanel poeste;
private JPanel peste;
//------------------
public static void main(String[] args)
{
BorderTest prueba=new BorderTest();
//----
JFrame window = new BorderTest();
window.setVisible(true);
}
public void visualizaVentana()
{
JFrame v = new JFrame("Prueba BorderLayout");
construyeTodo(v.getContentPane());
v.pack();
v.setVisible(true);
v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void start()
{
construyeTodo(this);
}
//---------------------------------------
private void construyeTodo(Container contenedor)
{
construyepsur();
// construyepoeste();
construyepeste();
//---------------------------------------------
JScrollPane scroll = new JScrollPane(new JTextArea());
contenedor.setLayout(new BorderLayout());
//----
contenedor.add(scroll, BorderLayout.CENTER);
contenedor.add(pnorte, BorderLayout.NORTH);
contenedor.add(psur, BorderLayout.SOUTH);
contenedor.add(poeste, BorderLayout.WEST);
contenedor.add(peste, BorderLayout.EAST);
}
//-------
private void construyepsur()
{
psur = new JPanel(new FlowLayout(FlowLayout.CENTER));
psur.setBackground(Color.cyan);
psur.add(new JButton("Probar"));
psur.add(new JButton("Insertar Serie"));
psur.add(new JButton("Salir"));
}
//----------------------
private void construyepeste()
{
peste = new JPanel(new FlowLayout());
peste.setBackground(Color.yellow);
peste.add(new JTextField(25));
peste.add(new JTextField(25));
peste.add(new JTextField(25));
}
BorderTest() {
JLabel etiquetaN = new JLabel("Nombre: El Mio");
JButton east = new JButton("Easgggggggggggggggggggggggggggggggggggggggggt");
JButton south = new JButton("West");
JButton west = new JButton("south");
JPanel content = new JPanel();
content.setLayout(new BorderLayout());
content.add(etiquetaN , BorderLayout.NORTH);
content.add(east , BorderLayout.EAST);
content.add(psur , BorderLayout.SOUTH);
content.add(west , BorderLayout.WEST);
setContentPane(content);
setTitle("BorderTest");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
}