Java fullscreen help

Hello longtime reader, first time poster,

I am trying to make a really simple java app that goes to fullscreen and puts a text message on the screen. I am not sure what exactly I am doing wrong with my code but if someone could explain it to me I would appreciate it greately.


import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import javax.swing.JFrame;


public class ScreenManager {
	GraphicsEnvironment environment;
	GraphicsDevice device;
	DisplayMode displayMode;
	
	public ScreenManager(int x,int y,int d,int r){
		environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		device = environment.getDefaultScreenDevice();
		displayMode = new DisplayMode(x,y,d,r);
	}
	
	public void setFullScreen(JFrame w){
		device.setFullScreenWindow(w);
		try {
			device.setDisplayMode(displayMode);
		}
		catch(IllegalArgumentException ex){
			System.out.println("unsupported display Mode");
		}
	}
	
	public void supported(){
		if (device.isFullScreenSupported()) {
			System.out.println("Fullscreen supported");
	    } else {
	    	System.out.println("Fullscreen not supported");
	    }

	}
}


import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JFrame;


public class FullScreenTester extends JFrame{
	
	public void fullscreen(JFrame j){
		j.setBackground(Color.blue);
		j.setForeground(Color.white);
		j.setFont(new Font("Dialog", Font.PLAIN,24));
		j.setVisible(true);
		ScreenManager sm = new ScreenManager(640,480,16,70);
		sm.setFullScreen(j);
	}
	
	public void paint(Graphics g){
		g.drawString("Hello Fullscreen!",20,50);
	}
	public static void main(String[] args){
		JFrame jframe = new JFrame("fullscreen");
		
		FullScreenTester fs = new FullScreenTester();
		fs.fullscreen(jframe);
	}
}

The frame you are passing into your ScreenManager is not the frame that is printing hello.

For some reason you have create 2 JFrame classes. You only need one.