Main Menu

panel problem

Started by ararie, May 22, 2007, 02:26:09

Previous topic - Next topic

ararie

Hi!

i'm using the tutorials from nehe and right now i'm currently using Lesson10 with a few changes... however, what i wanted to do was create a window with 2 panels, the first contains lesson 10, the second is another panel....

is that possible? i tried extending lesson10 into a JPanel and on my main method i made a JFrame room, instantiated lesson 10 and made another JPanel itemPanel with a JLabel 'label'.  then i added both into 'room' and it compiled fine.  when i ran it it didn't show itemPanel or the JLabel and i figured it's coz i forgot to take out 'createWindow()' from lesson10.  so i did this but it gave me an error:

java.lang.NullPointerException on this line:
        GL11.glGenTextures(buf); // Create Texture In OpenGL

please help!

Matzon

just put an AWTGLCanvas into you jpanel

ararie

so.. do i extend my room as an awtGLcanvas and not as a jpanel?

Matzon

well that depends on what you want to do ... either solutions will work

ararie

okay so this is what did

public class MetalRoom extends AWTGLCanvas
{ the code here is very similar to Lesson 10 of nehe.gamedev.net
  infact it's the same code, i just added a few more items in the room

//constructor
public MetalRoom() throws LWJGLException
{}

//the main method
public static void main(String args[]) {
        JFrame game = new JFrame("The Metal Room");
        game.setSize(640, 480);
        game.isVisible();

        JPanel room = new JPanel();
        JPanel item = new JPanel();
      try
      {   MetalRoom demo = new MetalRoom();
         room.add(demo);
                            game.setLayout(new BorderLayout());
                  game.add(room, BorderLayout.NORTH);
                  JLabel test = new JLabel("this is a test");
                  item.add(test);
                                    game.add(item, BorderLayout.SOUTH);
                                    demo.run(false); 
      }
      catch(LWJGLException e)
      {   System.out.println(e);
         System.exit(0);
      }
    }

}

makes sense?
it compiled fine.. but it gives me a runtime error
java.lang.NullPointer
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1317)
at MetalRoom.loadTexture(MetalRoom.java:375)
at MetalRoom.setupWorld(MetalRoom.java:1083)
at MetalRoom.init(MetalRoom.java:203)
at MetalRoom.run(MetalRoom.java:127)
at MetalRoom.main(MetalRoom.java:1292)

........ what now?