• 0

[JAVA] JFrame and Image Slideshow


Question

Hi

Simply put I am try to create a fullscreen image slide show in java. This is the code that is causing the problems:

		panel = new JPanel();
	frame.add(panel);

// This part sets all the neccessary stuff to make the frame full screen
	frame.setUndecorated(true);
	GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
		frame.setVisible(true);

	for (String s : pics) {
		try {
		photo = new JLabel(new ImageIcon(s));
		panel.add(photo);
		Thread.currentThread().sleep(wait*1000);
		panel.remove(photo);
		}
		catch (Exception e){
		e.printStackTrace();
		}
	}

The code won't let me add and remove images when it is full screen. The following code works fine, its full screen and the image is there.

panel = new JPanel();
	frame.add(panel);
	panel.add(new JLabel(new ImageIcon(pics[0])));

	frame.setUndecorated(true);
	GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
		frame.setVisible(true);

The strange thing is that you add the component to the frame before setting it to full screen.

It seems that setting the full screen stuff and then adding the component won't work. Is there any way round this?

Or if anyone knows any better way of doing a slide show please nudge me in the right direction.

Thanks

James

Link to comment
https://www.neowin.net/forum/topic/622761-java-jframe-and-image-slideshow/
Share on other sites

3 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.