Results 1 to 3 of 3
  1. #1
    verd is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Gui for applet in another class

    So, I want my code organized and created a Gui class to handle my GUI, here's what i got so far:
    Java Code:
    package core;
    
    import javax.swing.JApplet;
    
    public class Client extends JApplet{
    
    	public void init(){
    		try{
    			javax.swing.SwingUtilities.invokeAndWait(new Runnable(){
    				public void run(){
    	                new Gui();
    	                }});
    			}catch (Exception e){
    	        System.err.println("EE");
    	    }
    	}
    	
    	public void start(){
    		
    	}
    	
    	public void stop(){
    		
    	}
    	
    	public void destroy(){
    		
    	}
    }
    My Gui class:
    Java Code:
    package core;
    
    public class Gui{
    	
    	public Gui(){
    		
    	}
    }
    Ok, so here's my problem the Gui class doesn't extend JApplet so there for, I can't set the size, or add components how would I do this?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,419
    Rep Power
    20

    Default Re: Gui for applet in another class

    1) The size of an Applet is set by the HTML tag that displays it, not by any Java code
    2) Whatever GUI Components your GUI class might instantiate, they won't be shown without being added to a top level window -- in this case, the Applet. The GUI class should either extend a Container subclass or (usually better) have a method that returns a Container populated with the desired Components.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    verd is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

Similar Threads

  1. . class not found when trying to run applet?
    By louiedogg418 in forum New To Java
    Replies: 3
    Last Post: 08-04-2011, 06:43 PM
  2. applet class inside java.applet.* or java.awt.*
    By Manish87 in forum Java Applets
    Replies: 1
    Last Post: 09-27-2010, 02:15 PM
  3. can Applet be an inner class?
    By zweibieren in forum Java Applets
    Replies: 0
    Last Post: 03-26-2010, 06:42 AM
  4. class problen with java Applet
    By Tucan in forum Java Applets
    Replies: 7
    Last Post: 07-07-2009, 05:02 PM
  5. Multiple class applet
    By lordbob75 in forum Java Applets
    Replies: 5
    Last Post: 01-08-2009, 01:22 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
  •