1

I am working on a game using Java Applets, meant to be played in the JDK AppletViewer, and I have run into an issue. The status bar at the bottom of the applet (the brownish one that says "Applet Started") looks bad with the game playing above. On recommendation from: http://www.coderanch.com/t/256541/Applets/java/JFrame-applet I added the permission "showWindowWithoutWarningBanner". However, upon adding this to my security policy: permission java.awt.AWTPermission "showWindowWithoutWarningBanner";

So I open the applet, but the status bar is still there. I can confirm that the Security Policy file is being used, as I am able to read and write using the same Policy file.

2nd Attempt, tried setting the status to null using setStatus(null); to see if that would finish the job but that only removed the "Applet Started" text, the brownish status bar is still there. Any ideas if I am doing something wrong, or if there are any next steps to take?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Spino Prime
  • 108
  • 1
  • 1
  • 11

2 Answers2

1

Instead of using an Applet (there is absolutely no good reason to in your case), use Swing.

For example, here's a basic skeleton to get you started:

Frame:

public class App extends JFrame {

    public App() {
        super("Title");
        add(new AppPanel());
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationByPlatform(true);
        pack();
    }    

}

Panel:

public class AppPanel extends JPanel {

    @Override
    public void paintComponent(Graphics g) {
        // Perform your painting here
    }    

}

Also, make sure you initialize this on the EDT, like so:

SwingUtilities.invokeLater(new Runnable() {

    public void run() {
        new App().setVisible(true);
    }   

});
LanguagesNamedAfterCofee
  • 5,782
  • 7
  • 45
  • 72
  • Just to clarify your statement, you say there is absolutely no good reason to use an Applet, if I may ask why is that? – Spino Prime Oct 08 '12 at 01:27
  • *"if I may ask why is that?"* Perhaps it is more productive for you to state what you think any good reason for using an applet is. I can think of a couple, but they are unlikely to relate to your app. or situation. – Andrew Thompson Oct 08 '12 at 23:48
1

..a lot of hate for Java Applets, any particular reasons why..?

  • Applets are more difficult to develop and deploy than applications. Every other week there is a new applet bug in some variant of some browser, so it pays to factor the browser out.
  • An applet is a guest in a web page, but realistically, what does the web page wrapper actually contribute to the applet? Better to have the app. free floating on the desktop, at whatever position chosen by the user, and surviving the browser being closed.
  • An applet in a web page is set to a specific size in the HTML, whereas a free floating frame can be whatever size it ideally needs to be. While the applet is only resizable via JS, a frame can be made resizable or not according to need.
  • ...

Really this is a separate question you should ask. Then I'll move this answer to it.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433