Results 1 to 6 of 6
- 07-06-2012, 12:02 AM #1
Member
- Join Date
- Jul 2012
- Posts
- 2
- Rep Power
- 0
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]
-
Re: Converting my app from Swing to AWT
Why do you think this? Can you give an argument for using a weaker less robust gui library?
No, that makes no sense. Google Chrome will treat both the same. Something else is wrong.For example Google Chrome (at least my copy) can't run a JApplet, but can instead run Applet.
- 07-06-2012, 09:29 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 07-06-2012, 05:00 PM #4
Senior Member
- Join Date
- Apr 2012
- Posts
- 127
- Rep Power
- 0
Re: Converting my app from Swing to AWT
Just roll with IE and life will be good ;-P
(let the hate spams begin! lol)
- 07-06-2012, 10:32 PM #5
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.
My API:Java Code:cat > a.out || cat > main.class
- 07-07-2012, 09:32 AM #6
Re: Converting my app from Swing to AWT
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Converting
By PhQ in forum New To JavaReplies: 3Last Post: 08-21-2011, 05:28 PM -
Help me Converting jar to jpg and jpg to jar
By nap_patague in forum Advanced JavaReplies: 0Last Post: 03-20-2011, 08:33 AM -
converting hex to dec -
By Symbiot in forum New To JavaReplies: 3Last Post: 05-27-2010, 01:56 PM -
need help converting
By sr20guy in forum New To JavaReplies: 16Last Post: 04-02-2010, 01:07 PM -
Converting URL to URI
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks