Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Java setFullScreenWindow and Browser woes
Java setFullScreenWindow and Browser woes [message #668507] Thu, 05 May 2011 22:07 Go to next message
Chris A is currently offline Chris AFriend
Messages: 2
Registered: May 2011
Junior Member
Hey all,

I have been running into an issue with a SWT Browser and running it in fullscreenmode with java. When I run it with a 16 bit depth, it works fine, but when I switch it over to 32, it renders a black screen. Currently the application we are developing needs to be run in fullscreenmode with 32 bit depth, and cannot switch back and forth between the different bit depth due to the screen flickering between changes.

The reason why I am using a SWT Browser is so I can run the flash plugin inside of java. It's not ideal, but it's what my boss wants.

Any help would be appreciated. Prototype code to follow.

Thanks,

Chris A

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class FullScreenSwtBrowser {

	private JFrame bFrame;
	private JPanel embedPanel;

	private GraphicsEnvironment ge =
        GraphicsEnvironment.getLocalGraphicsEnvironment();
	private DisplayMode newDisplay = null;
	private GraphicsDevice defaultGD = ge.getDefaultScreenDevice();


	// SWT Components

	private Display display = new Display();
	private Shell shell;
	private Canvas embedCanvas;
	private Browser swtBrowser;

	public void init(){
		bFrame = new JFrame();
		bFrame.setSize(800, 600);
		bFrame.setUndecorated(true);
		newDisplay = new DisplayMode(800, 600, 32, 60);
//		newDisplay = new DisplayMode(800, 600, 16, 60);


		embedCanvas = new Canvas();
		embedCanvas.setPreferredSize(new Dimension(800, 600));

		embedPanel = new JPanel();
		embedPanel.add(embedCanvas);


		JPanel activityPanel = new JPanel();
		activityPanel.setBackground(Color.GREEN);
		bFrame.pack();

	}

	public void initBrowser(final String url) {

		display.syncExec(new Runnable() {

			@Override
			public void run() {

				shell = SWT_AWT.new_Shell(display, embedCanvas);
				shell.setLayout(new GridLayout());

				swtBrowser = new Browser(shell, SWT.NONE);
				swtBrowser.setLayoutData(new GridData(GridData.FILL_BOTH));
				shell.setSize(embedCanvas.getWidth(), embedCanvas.getHeight());
				shell.setLayoutData(new GridData(GridData.FILL_BOTH));
				swtBrowser.setUrl(url);
				shell.open();
				shell.forceFocus();
			}
		});
	}

	public void start(){
		bFrame.add(embedPanel);
		defaultGD.setFullScreenWindow(bFrame);
		defaultGD.setDisplayMode(newDisplay);

		embedPanel.setVisible(true);

		String url = "http://www.adobe.com/software/flash/about/";

		initBrowser(url);

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}



	/**
	 * @param args
	 */
	public static void main(String[] args) {
		FullScreenSwtBrowser  fssb = new FullScreenSwtBrowser();
		fssb.init();
		fssb.start();
	}

}

Re: Java setFullScreenWindow and Browser woes [message #669866 is a reply to message #668507] Wed, 11 May 2011 21:19 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Chris,

The behavior I see is a bit different from what you describe but still
similar. I assume there's a reason you're using SWT_AWT here (?). It works
fine if straight swt is used, snippet is below.

If using only swt is not possible for you then I suggest logging a report
with SWT at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT
and provide your snippet. I'm not sure if there's a problem in how you're
mixing swt and awt or not, it could just be a bug.

public void start() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.NONE);
String url = "http://www.adobe.com/software/flash/about/";
browser.setUrl(url);
shell.open();
shell.setFullScreen(true);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
display.dispose();
}

Grant


"Chris A" <chrisarnold@waterford.org> wrote in message
news:ipv6js$m0g$1@news.eclipse.org...
> Hey all,
>
> I have been running into an issue with a SWT Browser and running it in
> fullscreenmode with java. When I run it with a 16 bit depth, it works
> fine, but when I switch it over to 32, it renders a black screen.
> Currently the application we are developing needs to be run in
> fullscreenmode with 32 bit depth, and cannot switch back and forth between
> the different bit depth due to the screen flickering between changes.
> The reason why I am using a SWT Browser is so I can run the flash plugin
> inside of java. It's not ideal, but it's what my boss wants.
>
> Any help would be appreciated. Prototype code to follow.
>
> Thanks,
>
> Chris A
>
>
> import java.awt.Canvas;
> import java.awt.Color;
> import java.awt.Dimension;
> import java.awt.DisplayMode;
> import java.awt.GraphicsDevice;
> import java.awt.GraphicsEnvironment;
>
> import javax.swing.JFrame;
> import javax.swing.JPanel;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.awt.SWT_AWT;
> import org.eclipse.swt.browser.Browser;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class FullScreenSwtBrowser {
>
> private JFrame bFrame;
> private JPanel embedPanel;
>
> private GraphicsEnvironment ge =
> GraphicsEnvironment.getLocalGraphicsEnvironment();
> private DisplayMode newDisplay = null;
> private GraphicsDevice defaultGD = ge.getDefaultScreenDevice();
>
>
> // SWT Components
>
> private Display display = new Display();
> private Shell shell;
> private Canvas embedCanvas;
> private Browser swtBrowser;
>
> public void init(){
> bFrame = new JFrame();
> bFrame.setSize(800, 600);
> bFrame.setUndecorated(true);
> newDisplay = new DisplayMode(800, 600, 32, 60);
> // newDisplay = new DisplayMode(800, 600, 16, 60);
>
>
> embedCanvas = new Canvas();
> embedCanvas.setPreferredSize(new Dimension(800, 600));
>
> embedPanel = new JPanel();
> embedPanel.add(embedCanvas);
>
>
> JPanel activityPanel = new JPanel();
> activityPanel.setBackground(Color.GREEN);
> bFrame.pack();
>
> }
>
> public void initBrowser(final String url) {
>
> display.syncExec(new Runnable() {
>
> @Override
> public void run() {
>
> shell = SWT_AWT.new_Shell(display, embedCanvas);
> shell.setLayout(new GridLayout());
>
> swtBrowser = new Browser(shell, SWT.NONE);
> swtBrowser.setLayoutData(new GridData(GridData.FILL_BOTH));
> shell.setSize(embedCanvas.getWidth(), embedCanvas.getHeight());
> shell.setLayoutData(new GridData(GridData.FILL_BOTH));
> swtBrowser.setUrl(url);
> shell.open();
> shell.forceFocus();
> }
> });
> }
>
> public void start(){
> bFrame.add(embedPanel);
> defaultGD.setFullScreenWindow(bFrame);
> defaultGD.setDisplayMode(newDisplay);
>
> embedPanel.setVisible(true);
>
> String url = "http://www.adobe.com/software/flash/about/";
>
> initBrowser(url);
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> }
>
>
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> FullScreenSwtBrowser fssb = new FullScreenSwtBrowser();
> fssb.init();
> fssb.start();
> }
>
> }
>
>
Previous Topic:swt awt browser
Next Topic:adding component to a tableviewer
Goto Forum:
  


Current Time: Mon Feb 24 12:53:13 GMT 2020

Powered by FUDForum. Page generated in 0.02115 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top