www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: MichaelJPCT on December 28, 2015, 09:17:03 am

Title: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
Post by: MichaelJPCT on December 28, 2015, 09:17:03 am
i like to write something like:
Code: [Select]
import org.lwjgl.opengl;
class { method() { opengl.Display.setTitle("abc"); } }
but no matter what i tried:
import org.lwjgl;
import org.lwjgl.opengl.*
...
jave doens't compile.
do i have to write { org.lwjgl.opengl.Display.method(); } every time?
Title: Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
Post by: javamak on December 28, 2015, 09:42:38 am
import org.lwjgl.opengl.*
Display.setTitle("abc");

Try this.
Title: Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
Post by: EgonOlsen on December 28, 2015, 09:50:42 am
That should work as long as there is no other Display class in the Imports. In that case, add an import to Display directly: import org.lwjgl.opengl.Display;
Title: Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
Post by: MichaelJPCT on December 28, 2015, 12:26:02 pm
thanks.
import org.lwjgl.opengl.Display works.
but import org.lwjgl.opengl.* has conflict with another "DisplayMode".
import org.lwjgl.opengl should be ideal but it doesn't work. i miss Python, i can write ogl=org.lwjgl.opengl; disp=ogl.Display in it!
Title: Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
Post by: EgonOlsen on December 28, 2015, 03:21:31 pm
It's actually not hard. If there's a naming conflict, either specify the complete path in your code or import the needed classes by name... Just like you did with Display. Any modern IDE can handle these imports more or less automatically for you.