java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?

Started by MichaelJPCT, December 28, 2015, 09:17:03 AM

Previous topic - Next topic

MichaelJPCT

i like to write something like:

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?

javamak


EgonOlsen

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;

MichaelJPCT

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!

EgonOlsen

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.