Results 1 to 6 of 6
  1. #1
    StaticRich is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default Converting my app from Swing to AWT

    So, I started writing a game in Java. Unfortunately I started out with Swing and later realized it would be better in AWT. For example Google Chrome (at least my copy) can't run a JApplet, but can instead run Applet. So I started to convert my code from Swing to AWT. Good news is after switching JApplet, JFrame, and JLabel with Applet, Frame, and Label, there aren't many errors left. The errors I'm getting now pertain to the methods JLabel.setIcon(ImageIcon), JApplet.setContentPane(JLayeredPane), and JFrame.setDefaultCloseOperation(int). I need to know what the AWT equivalent is of these methods, and also if there is an AWT version of JLayeredPane. I'm not sure but I might be able to get away with using a regular Panel. Thing is the JLayeredPane is the map screen so there's the map, player, NPCs, objects etc all drawn on the same panel and they need to be drawn on the right layer to display properly. For example the map image must be below everything else and the player must be above it. I don't know if I can just add them to a Panel, if the order in which I add them will determine on which layer they're drawn, or if I really will need an AWT equivalent.

    And, like I said, I need to know how to accomplish the following in AWT:
    JLabel.setIcon(ImageIcon) [with a Label]
    JApplet.setContentPane(JLayeredPane) [with an Applet]
    JFrame.setDefaultCloseOperation(int) [with a Frame]

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

    Default Re: Converting my app from Swing to AWT

    Quote Originally Posted by StaticRich View Post
    ...Unfortunately I started out with Swing and later realized it would be better in AWT...
    Why do you think this? Can you give an argument for using a weaker less robust gui library?

    For example Google Chrome (at least my copy) can't run a JApplet, but can instead run Applet.
    No, that makes no sense. Google Chrome will treat both the same. Something else is wrong.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Converting my app from Swing to AWT

    Yep, it's nothing to do with Google Chrome, which simply uses your Java plugin, and it's unlikely in the extreme that a browser like Chrome would be using a version of Java that expired a decade before the browser was written.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Converting my app from Swing to AWT

    Just roll with IE and life will be good ;-P


    (let the hate spams begin! lol)

  5. #5
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: Converting my app from Swing to AWT

    My Swing JApplets work in Google Chrome. I usually do not use the system's graphical Components unless I am using C and GTK+. Usually I stick with the JButtons, JLables etc due to their versatility. What version of Google Chrome do you have. What plugin version of Java are you using? are you using the chrome plugin that exists in the JRE or the JDK?

    Aside from that, I think there is something even deeper that is the reason why your program (the one using Swing) is not working. Do you have the plugin window Console window enabled? if you do not know what I am talking about, here is a picture. If you do, consult that for the error that is present in your program.

    Converting my app from Swing to AWT-java_console.png
    My API:
    Java Code:
    cat > a.out || cat > main.class

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

    Default Re: Converting my app from Swing to AWT

    Quote Originally Posted by StaticRich View Post
    For example Google Chrome (at least my copy) can't run a JApplet, but can instead run Applet.
    As already pointed out, that statement is wrong. Not only that, since JApplet extends Applet (i.e. every JApplet is-a Applet), any software that can launch an Applet can and will launch a JApplet.

    Google Chrome has other issues with the Java plugin, like repeatedly asking to be updated and downloading the same update over and over again. Some of those issues (maybe all, but I can't be sure) can be sorted out by upgrading to Java 7.

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

Similar Threads

  1. Converting
    By PhQ in forum New To Java
    Replies: 3
    Last Post: 08-21-2011, 06:28 PM
  2. Help me Converting jar to jpg and jpg to jar
    By nap_patague in forum Advanced Java
    Replies: 0
    Last Post: 03-20-2011, 09:33 AM
  3. converting hex to dec -
    By Symbiot in forum New To Java
    Replies: 3
    Last Post: 05-27-2010, 02:56 PM
  4. need help converting
    By sr20guy in forum New To Java
    Replies: 16
    Last Post: 04-02-2010, 02:07 PM
  5. Converting URL to URI
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11: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
  •