Skip to content

Instantly share code, notes, and snippets.

@stacktracer
Created February 6, 2015 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stacktracer/28cec8be325a0a3d1f01 to your computer and use it in GitHub Desktop.
Save stacktracer/28cec8be325a0a3d1f01 to your computer and use it in GitHub Desktop.
Popup Test
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.swing.JFrame;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
public class PopupTest
{
public static void main( String[] args )
{
GLProfile glProfile = GLProfile.getMaxFixedFunc( true );
GLCapabilities glCapabilities = new GLCapabilities( glProfile );
GLWindow glWindow = GLWindow.create( glCapabilities );
final NewtCanvasAWT glCanvas = new NewtCanvasAWT( glWindow );
final JFrame frame = new JFrame( "Popup Test" );
frame.getContentPane( ).add( glCanvas );
final JPopupMenu menu = new JPopupMenu( );
menu.setLightWeightPopupEnabled( false );
menu.add( "Menu item 1" );
menu.add( "Menu item 2" );
menu.add( "Menu item 3" );
glWindow.addMouseListener( new MouseAdapter( )
{
public void mousePressed( final MouseEvent ev )
{
SwingUtilities.invokeLater( new Runnable( )
{
public void run( )
{
menu.show( glCanvas, ev.getX( ), ev.getY( ) );
}
} );
}
} );
SwingUtilities.invokeLater( new Runnable( )
{
public void run( )
{
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.setSize( 800, 600 );
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}
} );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment