MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Java Swing Tutorials

Swing In Java

Swing is also part of Sun Microsystems' Java Foundation Classes (JFC) an Application Programming Interface (API) for providing a graphical user interface (GUI) for Java programs.

Introduce to overcome the limitation of AWT. The Swing classes are built on top of the AWT architecture. The JFC also provide some other important features to a GUI program, like the ability to add rich graphics functionality, ability to create a program that can work in different languages/platform, and by users with different input devices..

Write a program that "display the component in Jframe

import java.awt.Color;
import javax.swing.*;

public class FirstFrame extends java.awt.Frame {

//Define the Component and used it into the program
private JLabel label;
private JButton button;
private JTextField field;
private JTextArea area;

public FirstFrame() {

private void init() {
JFrame frame = new JFrame("Frame in Component of AWT ");
JPanel panel = new JPanel();
frame.setBounds(300, 400, 300, 400);

//Initilizad the Component

label = new JLabel("R4R Tech Soft! Welcome");
field = new JTextField("This is TextField", 20);
button = new JButton("Click Me");
area = new JTextArea(null, "This is TextArea", 4, 5);

//Add the component into panel to display inside the JFrame
label.setBounds(30, 20, 300, 30);

field.setBounds(25, 50, 200, 30);

button.setBounds(30, 100, 150, 50);

area.setBounds(20, 180, 200, 100);

//Add panel to the Frame alongwith its component
//Free all the resource and unload the JFrame

public static void main(String[] args) {
FirstFrame firstFrame = new FirstFrame();



Difference Between Swing And AWT
Swing Abstract Window Toolkit( AWT)
Swing classes define in the javax.swing packageAWT classes define in the java.awt package include subpackage java.awt.event
It is totally platform independent It is not totally platform independent
Written entirely in Java programming languageSome AWT component use native code
Build around the number of API that implement various part of the AWTSwing classes are built on top of the AWT architecture
Swing is Light weight component.AWT are heavy weight components
It is "borrows" the screen resource of an ancestor ( means it has no native resource of its own)It is associated with its own native screen resource (commonly known as a peer).