Results 1 to 6 of 6
  1. #1
    JL4
    JL4 is offline Member
    Join Date
    Nov 2008
    Posts
    10
    Rep Power
    0

    Unhappy Java App to Applet

    Hi

    I was wondering if anyone knows how to convert a Java application to an Applet?

    My GUI consists of just Swing components.

    I changed the main() to void init() method and got it running-ish, the GUI items doesn't appear apart from the buttons when the mouse is over them.

    Any ideas whats wrong?

    Thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Better post what you have now then.

  3. #3
    JL4
    JL4 is offline Member
    Join Date
    Nov 2008
    Posts
    10
    Rep Power
    0

    Default

    Java Code:
     public void init() {
        
    
            try {
                java.awt.EventQueue.invokeAndWait(new Runnable() {
    
                    public void run() {
                    
                      initGui(); //Creates and initialises swing components for the GUI.
                 initPanel(); //Adds objects to panels.                     
                    }
                });
            } catch (Exception ex) {
                ex.printStackTrace();
            }
    
    
    public void start() {
        }
    
        public void stop() {
        }
    
        public void paint(Graphics g) {
        }
    Thanks

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    You are going to have to post the whole class.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Your program is tough to decipher since we have no idea what happens in your initGui and initPanel methods.

    I also am quite concerned with that empty paint method sitting near the bottom. This method will override the applet's native paint method and can make sure that nothing shows up.

    My tips for you include:

    1) Write your GUIs so that they are geared to produce a JPanel or other JComponent.
    2) If you want to create a JApplet then create the JPanel above and place it into a JApplet's contentPane.
    3) If you want to create a JFrame then create the JPanel above and place it into a JFrame's contentPane.
    4) If you want to create a JDialog then create the JPanel above ...

    well you get the picture

  6. #6
    devunion is offline Member
    Join Date
    Jun 2008
    Posts
    56
    Rep Power
    0

    Default

    Main window of your app sould extens JApplet instead of JFrame or JWindow. Then you need to movi initialization code in appropriate places. See start() and init() methods.
    Try Controls4J - Advanced Swing Components.

Similar Threads

  1. Replies: 3
    Last Post: 07-23-2008, 08:07 AM
  2. Please check my java applet
    By mark.7100 in forum Java Applets
    Replies: 3
    Last Post: 07-22-2008, 04:33 PM
  3. Java Applet Help
    By Nuluvius in forum New To Java
    Replies: 0
    Last Post: 03-01-2008, 03:04 PM
  4. New to JAVA Applet
    By kazitula in forum Java Applets
    Replies: 2
    Last Post: 10-31-2007, 08:11 PM
  5. Java 3d in applet
    By carl in forum Java Applets
    Replies: 1
    Last Post: 08-06-2007, 05:55 PM

Posting Permissions

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