What is the difference between swing and awt in java




















Button click, closing the window, typing something in the textbox are some examples of events that can occur in a Graphical User Interface based application.

Today many applications contain GUIs. Mobile applications, Air ticket reservation systems, Automated Teller Machines have rich graphical interfaces for customers to use the application easily. AWT requires a native OS object to implement the functionalities. Therefore, AWT components are heavyweight and require more memory space. AWT components also take time to execute.

The number of components available in AWT is minimum. It is necessary to import javax. Some AWT components are button, text fields, drop down boxes, scroll bars, window, frame, panel, labels. After creating the objects, they can be placed into a container. A container provides space for components to load. AWT does not support pluggable look and feel. Therefore, an AWT application developed in one operating system might not look the same in another operating system.

Swing is a GUI widget toolkit for Java. Swing was developed to provide more flexible and sophisticated components than AWT. Swing contains basic components such as labels, text boxes, buttons. It also contains more advanced components. Some of them are trees, tables, lists, scroll panes and tabbed panes.

If the programmer needs to implement a Swing application, it is necessary to import javax. Swing components do not have a platform-specific code. Therefore, Swing is platform independent. JVM is responsible for invoking the native methods. Swing component is platform independent 3. Swing requires javax. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. What is the difference between Swing and AWT? Ask Question. Asked 12 years, 10 months ago. Active 11 months ago. Viewed k times. Can someone please explain me what's the difference between Swing and AWT?

Improve this question. Yves M. Samiksha Samiksha 5, 6 6 gold badges 27 27 silver badges 28 28 bronze badges. Related: stackoverflow. Add a comment. Active Oldest Votes. Improve this answer. Nondeterministic narwhal 5 5 silver badges 17 17 bronze badges. No way. I can't believe they can fix it, and I still can't believe mixing lightweight and heavyweight components would ever be desirable.

But it's incredible that they can fix it. Just forget about both. Have a look at WPF. Here's an official Java article confirming that mixing is fixed: oracle. Access Denied Access Denied 1 1 gold badge 13 13 silver badges 23 23 bronze badges. It used to be relevant Unbroken article link edn.

This used to really come into play if you were building Applets - you wanted to target the lowest common denominator so people wouldn't have to install a newer Java plugin. I'm not sure what the current most widely installed version of the Java plugin is - this may be different today. There are better 3rd party native looking skins than Swing's implementations BTW Lots of people preferred using AWT's FileDialog over Swing's FileChooser because it gave the platform file dialog most people were used to rather than the 'weird' custom Swing one.

To understand the differences between Awt and Swing, we have created the same example in awt as well. Consider the following example. JavaTpoint offers too many high quality services. Mail us on [email protected] , to get more information about given services.

Please mail your requirement at [email protected] Duration: 1 week to 2 week. Java Training Java Tutorial. Abstract class Interface Abstract vs Interface. Package Access Modifiers Encapsulation. Reinforcement Learning. R Programming.

React Native. Python Design Patterns. Python Pillow. Python Turtle. Verbal Ability. Interview Questions. Company Questions. Artificial Intelligence. Cloud Computing. Data Science.



0コメント

  • 1000 / 1000