Results 1 to 4 of 4
  1. #1
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default Embedding Applet into the center of fullscreen API

    Java Code:
    public String a;
        public Applet applet;
        Crawler crawler = new Crawler();
    	HashMap parameters = crawler.getParameters();
    	URLClassLoader classLoader;
    	RGBFinder bot = new RGBFinder();
    	int world = Methods.random(1, 50);
    	String base = "http://world" + world + ".runescape.com";
    
        public EnhancedUI(){
    
            try {
                for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (Exception e) {
              
            }
                  
                       initApplet();
             final JFrame frame = new JFrame();
             frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
             frame.setUndecorated(true);
             frame.setResizable(false);
             frame.setLayout(null);
             frame.validate();
    
    
             getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
            appletResize(500,400);
            applet.setLocation(200,200);
            frame.add(applet);
        }
    
          private void initApplet() {
    
    		try {
    
    
    			String jarName = "loader.jar";
    			String className = "loader";
    			URL[] appletURL = { new URL(base + "/" + jarName) };
    
    			classLoader = new URLClassLoader(appletURL);
    			Class loader = classLoader.loadClass(className);
    			applet = (Applet) loader.newInstance();
    			applet.setStub(this);
    			applet.init();
    			applet.start();
    		} catch (InstantiationException ex) {
    			Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
    		} catch (IllegalAccessException ex) {
    			Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
    		} catch (ClassNotFoundException ex) {
    			Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
    		} catch (MalformedURLException ex) {
    			Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
    		}
    	}
    
    
        public boolean isActive() {
            return false;  //To change body of implemented methods use File | Settings | File Templates.
        }
    
        public URL getDocumentBase() {
              try {
                  return new URL(base);
              } catch (MalformedURLException ex) {
                  Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
                  return null;
              }
          }
    
    
          public URL getCodeBase() {
              try {
                  return new URL(base);
              } catch (MalformedURLException ex) {
                  Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
                  return null;
              }
          }
    
    
          public String getParameter(String name) {
              return (String) parameters.get(name);
          }
    
    
          public AppletContext getAppletContext() {
              return null;
          }
    
         
          public void appletResize(int width, int height) {
              applet.setSize(width, height);
          }
    For some reason, when I run this program, I see the fullscreen, and the can hear the Applet's sound, but not the visual counterpart of the Applet. What is wrong? Thanks!

  2. #2
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    Show us the whole class code that would be more clear to find I guess

  3. #3
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default

    I know for a fact it can't be the applet's fault, because it works when not applied to a full screen window. And that is all the class' code

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Can you make a small executable program to demo the problem.
    Hard to test bits and pieces of code.

Similar Threads

  1. fullscreen
    By ashish9590 in forum AWT / Swing
    Replies: 0
    Last Post: 02-23-2010, 01:58 PM
  2. [SOLVED] Applet Center
    By AndrewM16921 in forum New To Java
    Replies: 1
    Last Post: 03-26-2009, 12:38 AM
  3. Embedding Applet into HTML?
    By Unome in forum Java Applets
    Replies: 1
    Last Post: 02-21-2009, 03:40 AM
  4. Embedding Word in an applet
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 02:34 PM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •