-1

Can someone please explain me what's the difference between Swing and JFrame?

Are there any cases where AWT is more useful/advised to use than jframe or vice-versa?

Iqra
  • 1
  • This might be salvageable as a useful question, if its title and body were changed to “Are there any cases where use of AWT is preferred over use of Swing.” Currently, the title and the first question don’t make sense; you can’t compare an entire framework to one class in a different framework or the same framework. – VGR May 07 '18 at 15:16

2 Answers2

1
  1. I think Swing is just a newer version, so you can use awt classes /interfaces like ActionListener for JButtons etc. I use swing, but for some things you need awt-packages like awt.event or awt.color.

  2. JFrame is a class in swing, which is a package.

I'm not sure, if all I wrote is right, so correct me, if I wrote wrong stuff.

1
  • AWT was the first GUI framework in java, with platform specific implementation. So a button in Windows looked like and was a button on Windows. That took some effort, and in effect had not 100% cross platform functionality with more complex controls.
  • Swing was the successor GUI framework, that emulated every platform specific control. It still uses AWT classes. It is more versatile, has themes (LookAndFeels), is simply more enhanced.
  • JavaFX / OpenFX deserves mention, as it is a standard GUI framework of some beauty, with animation effects, custom styles, and a good data modeling. Many lambdas though, so not that easy. But after some experience, very compact and with maintainable code.

So in general the only choice (with standard GUI frameworks) is between Swing and JavaFX.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138