๐ŸŽจ Java Graphics Programming with AWT ๐ŸŽจ เคœाเคตा เคฎें เค—्เคฐाเฅžिเค•्เคธ เคช्เคฐोเค—्เคฐाเคฎिंเค— (AWT)

Java allows us to create interactive Graphical User Interfaces (GUIs) using Applets and AWT (Abstract Windowing Toolkit).

เคœाเคตा เคนเคฎें เค—्เคฐाเคซिเค•เคฒ เคฏूเคœเคฐ เค‡ंเคŸเคฐเคซेเคธ (GUI) เคฌเคจाเคจे เค•ी เคธुเคตिเคงा เคฆेเคคा เคนै, เคœो เคเคช्เคฒेเคŸ เค”เคฐ AWT (เคเคฌ्เคธ्เคŸ्เคฐैเค•्เคŸ เคตिंเคกोเค‡ंเค— เคŸूเคฒเค•िเคŸ) เค•ी เคฎเคฆเคฆ เคธे เคคैเคฏाเคฐ เคนोเคคे เคนैं।

AWT contains a collection of classes and components for building platform-independent GUI software.
AWT เคฎें เค•्เคฒाเคธेเคธ เค”เคฐ เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ्เคธ เค•ा เคธเคฎूเคน เคนोเคคा เคนै เคœिเคธเคธे เคช्เคฒेเคŸเคซॉเคฐ्เคฎ-เค‡ंเคกिเคชेंเคกेंเคŸ GUI เคธॉเคซ्เคŸเคตेเคฏเคฐ เคฌเคจाเค เคœा เคธเค•เคคे เคนैं।

These components include buttons, checkboxes, labels, text fields, dialogs, menus, fonts, colors, and also event-handling support.
เค‡เคจ เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ्เคธ เคฎें เคฌเคŸเคจ, เคšेเค•เคฌॉเค•्เคธ, เคฒेเคฌเคฒ, เคŸेเค•्เคธ्เคŸ เคซीเคฒ्เคก, เคกाเคฏเคฒॉเค—, เคฎेเคจ्เคฏू, เคซॉเคจ्เคŸ, เค•เคฒเคฐ เค”เคฐ เค‡เคตेंเคŸ-เคนैंเคกเคฒिंเค— เคธเคชोเคฐ्เคŸ เคถाเคฎिเคฒ เคนै।


๐Ÿ—️ AWT Class Hierarchy AWT เค•्เคฒाเคธ เคนाเคฏเคฐाเคฐ्เค•ी

  1. Component (เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ)
    All AWT elements like Button, Label, TextField are Components.
    เคธเคญी AWT เคเคฒिเคฎेंเคŸ เคœैเคธे เคฌเคŸเคจ, เคฒेเคฌเคฒ, เคŸेเค•्เคธ्เคŸ เคซीเคฒ्เคก เค†เคฆि เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ เค•เคนเคฒाเคคे เคนैं।

  2. Container (เค•ंเคŸेเคจเคฐ)
    Holds other components and manages their layout.
    เคฏเคน เค…เคจ्เคฏ เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ्เคธ เค•ो เคฐเค–เคคा เคนै เค”เคฐ เค‰เคจเค•े เคฒेเค†เค‰เคŸ เค•ो เคฎैเคจेเคœ เค•เคฐเคคा เคนै।

  3. Window (เคตिंเคกो)
    A container without border or menu bar; created using Frame or Dialog.
    เคเค• เค•ंเคŸेเคจเคฐ เคœो เคฌॉเคฐ्เคกเคฐ เค”เคฐ เคฎेเคจ्เคฏू เคฌाเคฐ เค•े เคฌिเคจा เคนोเคคा เคนै; เค‡เคธे Frame เคฏा Dialog เคธे เคฌเคจाเคฏा เคœाเคคा เคนै।

  4. Panel (เคชैเคจเคฒ)
    A simple container used to group components.
    เคธाเคงाเคฐเคฃ เค•ंเคŸेเคจเคฐ เคœो เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ्เคธ เค•ो เค—्เคฐुเคช เค•เคฐเคจे เค•े เคฒिเค เคช्เคฐเคฏोเค— เคนोเคคा เคนै।

  5. Frame (เคซ्เคฐेเคฎ)
    A top-level container with title bar, menu bar, and border, which can hold other AWT elements.
    เคถीเคฐ्เคท เคธ्เคคเคฐ เค•ा เค•ंเคŸेเคจเคฐ เคœिเคธเคฎें เคŸाเค‡เคŸเคฒ เคฌाเคฐ, เคฎेเคจ्เคฏू เคฌाเคฐ เค”เคฐ เคฌॉเคฐ्เคกเคฐ เคนोเคคा เคนै, เค”เคฐ เคฏเคน เค…เคจ्เคฏ AWT เคเคฒिเคฎेंเคŸ्เคธ เค•ो เคฐเค– เคธเค•เคคा เคนै।


⚡ Commonly Used AWT Methods เคœाเคตा AWT เคฎें เคช्เคฐเคฏुเค•्เคค เคฎेเคฅเคก्เคธ

Method Name Description เคตिเคตเคฐเคฃ
add(Component c) Adds a component to the container. เค•ंเคŸेเคจเคฐ เคฎें เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ เคœोเคก़เคคा เคนै
setSize(int w, int h) Sets width and height of the component. เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ เค•ा เค†เค•ाเคฐ (เคšौเคก़ाเคˆ เค”เคฐ เคŠँเคšाเคˆ) เคธेเคŸ เค•เคฐเคคा เคนै
setLayout(LayoutManager m) Defines layout for the container. เค•ंเคŸेเคจเคฐ เค•े เคฒिเค เคฒेเค†เค‰เคŸ เคชเคฐिเคญाเคทिเคค เค•เคฐเคคा เคนै
setVisible(boolean status) Makes the component visible/invisible. เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ เค•ो เคฆृเคถ्เคฏ/เค…เคฆृเคถ्เคฏ เคฌเคจाเคคा เคนै

๐Ÿงช Example: Creating a Simple AWT Window with Button เคฌเคŸเคจ เค•े เคธाเคฅ เคเค• เคธाเคงाเคฐเคฃ AWT เคตिंเคกो เคฌเคจाเคจा

import java.awt.*;
class AWTExample extends Frame {
AWTExample() {
// Create a button
Button b = new Button("Click Here");
b.setBounds(50, 100, 100, 40); // x, y, width, height
// Add button to frame
add(b);
// Frame settings
setSize(400, 400); // Frame width and height
setLayout(null); // No layout manager
setVisible(true); // Make frame visible
}
public static void main(String args[]) {
new AWTExample();
}
}

Output: A 400x400 window with a Click Here button.
เค†เค‰เคŸเคชुเคŸ: 400x400 เค•ी เคเค• เคตिंเคกो เคœिเคธเคฎें Click Here เคฌเคŸเคจ เคนोเค—ा।


๐ŸŽฏ Notes on AWT Graphics Programming เคœाเคตा AWT เค—्เคฐाเฅžिเค•्เคธ เคช्เคฐोเค—्เคฐाเคฎिंเค— เคชเคฐ เคจोเคŸ्เคธ

  • AWT is platform-independent but heavyweight because it depends on native OS components.
    AWT เคช्เคฒेเคŸเคซॉเคฐ्เคฎ-เค‡ंเคกिเคชेंเคกेंเคŸ เคนै เคฒेเค•िเคจ เคนेเคตीเคตेเคŸ เคนै เค•्เคฏोंเค•ि เคฏเคน เคจेเคŸिเคต OS เค•ॉเคฎ्เคชोเคจेเคจ्เคŸ्เคธ เคชเคฐ เคจिเคฐ्เคญเคฐ เค•เคฐเคคा เคนै।

  • For advanced GUI, Swing is preferred as it is lightweight and fully Java-based.
    เคเคกเคตांเคธ GUI เค•े เคฒिเค Swing เค•ो เคช्เคฐाเคฅเคฎिเค•เคคा เคฆी เคœाเคคी เคนै เค•्เคฏोंเค•ि เคฏเคน เคฒाเค‡เคŸเคตेเคŸ เค”เคฐ เคชूเคฐी เคคเคฐเคน เคœाเคตा-เคฌेเคธ्เคก เคนै।

  • Event Handling is important to make GUI interactive.
    GUI เค•ो เค‡ंเคŸเคฐैเค•्เคŸिเคต เคฌเคจाเคจे เค•े เคฒिเค เค‡เคตेंเคŸ เคนैंเคกเคฒिंเค— เคฎเคนเคค्เคตเคชूเคฐ्เคฃ เคนै।

Comments

Popular posts from this blog

What is a Web Browser? เคตेเคฌ เคฌ्เคฐाเค‰เคœ़เคฐ เค•्เคฏा เคนै?

Java's Support System เคœाเคตा เค•ा เคธเคนเคฏोเค—ी เคคंเคค्เคฐ

The Internet and Java เค‡ंเคŸเคฐเคจेเคŸ เค”เคฐ เคœाเคตा เค•ा เคธเคฎ्เคฌเคจ्เคง