Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make full screen java applets?

I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this.

Since I haven't been using java applets for 3 years(The last time I've used it was for a course homework :) ) I have forgotten most of the concepts. I googled and found that link: Dani web

But in the method described in above link you have to put a JFrame inside the applet which I have no idea how to do it.

Whatever I need a quick and dirty method b'cause I don't have much time and this is the reason why I asked it here.

Thanx in advance

like image 977
systemsfault Avatar asked Jan 10 '09 14:01

systemsfault


People also ask

How do I fix an applet window in Java?

Re-launch the web browser. Go to the Java applet. When the "Security Warning" window asking "Do you want to run this application?" appears --> Click the "Run" button. The Java applet should load OK now.

How do you clear the screen in Java applet?

Let's combine the above two codes, we get \033[H\033[2J. The combination of code clears the screen or console. In the above example, we have used the same code (\033[H\033[2J) that we have explained above. It clears the console.


2 Answers

The obvious answer is don't use applets. Write an application that uses a JFrame or JWindow as its top-level container. It's not a huge amount of work to convert an applet into an application. Applets are designed to be embedded in something else, usually a web page.

If you already have an applet and want to make it full screen, there's two quick and dirty hacks:

1). If you know the screen resolution, just set the applet parameters to be that size in the HTML and then run the browser in full screen mode.

2). Run the applet in appletviewer, rather than a web page, and maximise the appletviewer window.

like image 196
Dan Dyer Avatar answered Sep 21 '22 11:09

Dan Dyer


Why not just open a new Frame from the applet (either from the "start()" method or, preferably, after the user presses an "open" button) and set it to be maximized?

JFrame frame = new JFrame();
//more initialization code here
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize(dim.width, dim.height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

Don't forget: The JFrame should be created and opened from the EDT. Applet start() is not guaranteed to be called on that thread, so use SwingUtilities.invokeLater(). Of course, if you opt for the button route, button listener is called on the EDT, so you should be safe.

like image 20
Ran Biron Avatar answered Sep 23 '22 11:09

Ran Biron