Can someone tell me how I can use swing in fullscreen mode. To show Dialogs .
Thanks
Can someone tell me how I can use swing in fullscreen mode. To show Dialogs .
Thanks
yeah i’m looking for this information too!
[quote]To show Dialogs .
[/quote]
Not gonna happen. Dialog is a top-level window, and there could be only one toplevel window in fullscreen window.
You may try to use JInternalFrame as a lightweight substitude…
Hello,
I have been messing around with the following code and a dialog is getting shown in fullscreen mode over a jogl glcanvas. It seems to work but I haven’t really done much with it yet. Hopefully this helps. When running the program just press any key and a dialog box should pop up with a button on it that will close the application.
/*
* Created on Dec 21, 2003
*
*/
import net.java.games.jogl.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
/**
* @author Stephen Johnson
*
*
*/
public class CsSwingRenderingTesting extends JFrame
{
private GLCanvas _canvas;
private JDialog _dialog;
public CsSwingRenderingTesting()
{
super("Swing Rendering Testing");
_dialog = new JDialog(this);
_dialog.getContentPane().add(new CsPanel());
_dialog.setSize(200,200);
getContentPane().setLayout(new GridLayout(1,1));
setIgnoreRepaint(true);
setUndecorated(true);
addKeyListener(new KeyAdapter(){public void keyPressed(KeyEvent arg0)
{
_dialog.show();
_canvas.display();
}});
setResizable(false);
createGLCanvas();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsDevice gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
System.out.println("Full Screen Supported --> " + gc.isFullScreenSupported());
if(gc.isFullScreenSupported())
{
try
{
gc.setFullScreenWindow(this);
}
catch(Exception ex)
{
System.out.println("Error setting full screen --> " + ex);
gc.setFullScreenWindow(null);
}
}
else
{
this.setSize(500,500);
this.setVisible(true);
}
}
private void createGLCanvas()
{
GLCapabilities c = new GLCapabilities();
_canvas = GLDrawableFactory.getFactory().createGLCanvas(c);
_canvas.addGLEventListener(new CsGLEventListener());
_canvas.addKeyListener(new KeyAdapter(){public void keyPressed(KeyEvent arg0)
{
_dialog.show();
_canvas.display();
}});
this.getContentPane().add(_canvas);
}
public static void main(String args[])
{
CsSwingRenderingTesting t = new CsSwingRenderingTesting();
}
}
class CsGLEventListener implements GLEventListener
{
/* (non-Javadoc)
* @see net.java.games.jogl.GLEventListener#init(net.java.games.jogl.GLDrawable)
*/
public void init(GLDrawable glDrawable)
{
GL gl = glDrawable.getGL();
gl.glClearColor(0.0f,0.0f,0.0f,0.0f);
gl.glColor3d(1.0,1.0,1.0);
}
/* (non-Javadoc)
* @see net.java.games.jogl.GLEventListener#display(net.java.games.jogl.GLDrawable)
*/
public void display(GLDrawable glDrawable)
{
GL gl = glDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslated(0.0,0.0,-2.0);
gl.glBegin(GL.GL_TRIANGLES);
gl.glVertex3d(0.0,0.0,0.0);
gl.glVertex3d(0.0,0.5,0.0);
gl.glVertex3d(0.5,0.0,0.0);
gl.glEnd();
}
public void reshape(GLDrawable glDrawable, int x, int y, int width, int height)
{
GL gl = glDrawable.getGL();
GLU glu = glDrawable.getGLU();
gl.glViewport(x,y,width,height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(65.0,width/height,1.0,20.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
}
/* (non-Javadoc)
* @see net.java.games.jogl.GLEventListener#displayChanged(net.java.games.jogl.GLDrawable, boolean, boolean)
*/
public void displayChanged(GLDrawable glDrawable, boolean arg1, boolean arg2) {
// TODO Auto-generated method stub
}
}
class CsPanel extends JPanel
{
public CsPanel()
{
JButton button = new JButton();
button.setAction(new CsExitAction());
add(button);
}
class CsExitAction extends AbstractAction
{
public CsExitAction()
{
putValue(AbstractAction.NAME,"Exit Application");
}
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
}