Author Topic: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?  (Read 599 times)

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
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?

Offline javamak

  • byte
  • *
  • Posts: 13
    • View Profile
Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
« Reply #1 on: December 28, 2015, 09:42:38 am »
import org.lwjgl.opengl.*
Display.setTitle("abc");

Try this.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
« Reply #2 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;

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
« Reply #3 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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: java/lwjgl noob question - shortening namespace org.lwjgl.opengl ?
« Reply #4 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.