Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When you use Frame or JFrame in Java? [duplicate]

Possible Duplicate:
What is the difference between swing and awt?

I often see that JFrame is used a lots. But sometimes, I also see that programmer use Frame in their example. So could you tell me the advantages/disadvantages of them?

like image 995
MasterDark116 Avatar asked Aug 27 '12 15:08

MasterDark116


People also ask

Is frame and JFrame same?

A Frame is an AWT component whereas a JFrame is a Swing component.

Why do you use frames in java?

In Java, a frame is a window that has nice borders, various buttons along the top border, and other features. What you usually call a "window" Java calls a "frame". A frame is a container object, so GUI components can be placed in it.

What is the difference between JFrame and JWindow?

JWindow is a part of Java Swing and it can appear on any part of the users desktop. It is different from JFrame in the respect that JWindow does not have a title bar or window management buttons like minimize, maximize, and close, which JFrame has. JWindow can contain several components such as buttons and labels.

Which JFrame method is used to display the frame?

By default, a JFrame can be displayed at the top-left position of a screen. We can display the center position of JFrame using the setLocationRelativeTo() method of Window class.


2 Answers

Well let me break it up for you.............. Before jumping into Frame Vs JFrame, let me explain you about AWT and Swing.

AWT :

- It has a Platform Dependent Look and Feel.

- So it uses the Native GUI components.

- As AWT uses the peer components, its called as Heavy Weight Component.

Swing :

- It has a Platform Independent Look and Feel.

- And its because it uses the Pure Java Components.

- As Swing uses pure java components, its know as Light Weight Component.

Its was said that AWT is faster than Swing as it uses the Platform component, but due the arrival of faster processor, etc .... Its equivalent now..and you get lots of flexibility.

Here is the GUI Tree :

        Object
           |
        Component
           |
        Container
  ---------|---------

  |                 |
JComponent        Window
  |                 |
JPanel            Frame
                    |
                  JFrame

Now Frame is an AWT component, where as JFrame is a Swing component.

You can also that see JFrame extends Frame.

But JFrame, provides lots of functinality and flexibility as compared to Frame, we can even say this that Swing provides better functionality with ease of implementing them.

like image 190
Kumar Vivek Mitra Avatar answered Oct 10 '22 10:10

Kumar Vivek Mitra


A frame is an AWT component(well this is the older classes for java GUI development) which uses native OS GUI support

A JFrame is a Swing component which is the newer one, well today's java GUI development uses mostly Swing as an advantage you can have a lot of community support on it. as far as I know Swing has LookAndFeel Feature that you can configure to change the look of your GUI with just few line of codes.

http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/

like image 43
Netorica Avatar answered Oct 10 '22 09:10

Netorica