LWJGL
May 21, 2012, 01:00:03 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: panel problem  (Read 2152 times)
ararie
Newbie
*
Posts: 11


« on: May 21, 2007, 19:26:09 »

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!
Logged
Matzon
Administrator
Demigod
*****
Posts: 2177



« Reply #1 on: May 21, 2007, 22:02:34 »

just put an AWTGLCanvas into you jpanel
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
ararie
Newbie
*
Posts: 11


« Reply #2 on: May 23, 2007, 14:10:33 »

so.. do i extend my room as an awtGLcanvas and not as a jpanel?
Logged
Matzon
Administrator
Demigod
*****
Posts: 2177



« Reply #3 on: May 24, 2007, 01:28:35 »

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

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
ararie
Newbie
*
Posts: 11


« Reply #4 on: May 25, 2007, 14:57:40 »

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?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!