-1

I've got a question today and would like to know which would be better to use in Java development. Which would be better to use: Java Swing OR Java Applet. I am new to Java development and have been confused between the two.

  • If you were creating a game which would be better to use.
  • Which is better to understand and uses less lines ect.
  • Which is light weight?

Any questions would be awesome!

Shaun
  • 388
  • 3
  • 13

3 Answers3

2

Java Swing OR Java Applet

There is some confusion here.

AWT has Frame for desktop applications/Applet for applets. Swing has JFrame for desktop applications/JApplet for applets.

Other matters:

  1. AWT/Swing. Why AWT rather than Swing? See this answer on Swing extras over AWT for many good reasons to abandon using AWT components. If you need to support older AWT based APIs, see Mixing Heavyweight and Lightweight Components.

  2. Applet vs. application. Why code an applet? If it is due to spec. by teacher, please refer them to Why CS teachers should stop teaching Java applets.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
2

Many of the components in javax.swing.* have made other still accessible JDK components obsolete, such as AWT. Swing is actually built on top of AWT, and is a large improvement in performance, features, and usage over AWT.

This tutorial on custom graphics with Swing may help: http://www.ntu.edu.sg/home/ehchua/programming/java/J4b_CustomGraphics.html

As for Java Applets, these are unrelated to Swing in terms of normal application development. Java Applets are small applications that can run in a web browser.

AMDG
  • 1,118
  • 1
  • 13
  • 29
1

Swing is a set of platform independent UI tools (JButton, JScrollBar, etc.). It guarantees that your user interface design will look the same on different platforms. An applet is an app that runs inside a browser or other hosted environment. An applet can use Swing UI, but doesn't need to.

Personally, I wouldn't develop a game in either if it's graphics intensive. If you want lightweight, I would suggest using JavaScript in Chrome's V8. Check out Chrome's developer showcase. They're doing amazing things with Javascript these days.

mttdbrd
  • 1,791
  • 12
  • 17
  • See, I get confused between the client side. I see many games using Flash player for the client but when I search on google not many make tutorials on connect Java to Actionscript ect. – Shaun Nov 24 '13 at 02:38
  • Flash is going the way of the Dodo. HTML5 and JavaScript is the way forward in the browser. Android is Java and I would develop games on that, but not standalone Java games. I don't think there's anyone developing games in Java to run on PCs/Macs etc. – mttdbrd Nov 24 '13 at 02:39
  • Right! But Java is the way to go for a Server side game correct? – Shaun Nov 24 '13 at 02:40
  • Not necessarily. Chrome's V8 engine has been turned into quite an amazing little web server (NodeJS). I would say don't let the technology guide your game design; pick a game design and let it dictate the choice of software. – mttdbrd Nov 24 '13 at 02:41
  • Okay, I get your point. But I wan't to create a Java Server side based game and from the re-search I've got that applet's and Swing isn't the best choice for making a game client side. – Shaun Nov 24 '13 at 02:43
  • No applets. Applets are dead technology. You can code your server in one language/platform and your clients in another. – mttdbrd Nov 24 '13 at 02:44
  • Okay! But where should I go for the client side of game? Like is there tutorials out there that show you how to connect Java Server to client side? If you could give me any information regarding this would be awesome. – Shaun Nov 24 '13 at 02:46
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/41782/discussion-between-mttdbrd-and-shaun) – mttdbrd Nov 24 '13 at 02:46