๐จ 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 เค्เคฒाเคธ เคนाเคฏเคฐाเคฐ्เคी
-
Component (เคॉเคฎ्เคชोเคจेเคจ्เค) –All AWT elements like Button, Label, TextField are Components.เคธเคญी AWT เคเคฒिเคฎेंเค เคैเคธे เคฌเคเคจ, เคฒेเคฌเคฒ, เคेเค्เคธ्เค เคซीเคฒ्เคก เคเคฆि เคॉเคฎ्เคชोเคจेเคจ्เค เคเคนเคฒाเคคे เคนैं।
-
Container (เคंเคेเคจเคฐ) –Holds other components and manages their layout.เคฏเคน เค เคจ्เคฏ เคॉเคฎ्เคชोเคจेเคจ्เค्เคธ เคो เคฐเคเคคा เคนै เคเคฐ เคเคจเคे เคฒेเคเคเค เคो เคฎैเคจेเค เคเคฐเคคा เคนै।
-
Window (เคตिंเคกो) –A container without border or menu bar; created using Frame or Dialog.เคเค เคंเคेเคจเคฐ เคो เคฌॉเคฐ्เคกเคฐ เคเคฐ เคฎेเคจ्เคฏू เคฌाเคฐ เคे เคฌिเคจा เคนोเคคा เคนै; เคเคธे Frame เคฏा Dialog เคธे เคฌเคจाเคฏा เคाเคคा เคนै।
-
Panel (เคชैเคจเคฒ) –A simple container used to group components.เคธाเคงाเคฐเคฃ เคंเคेเคจเคฐ เคो เคॉเคฎ्เคชोเคจेเคจ्เค्เคธ เคो เค्เคฐुเคช เคเคฐเคจे เคे เคฒिเค เคช्เคฐเคฏोเค เคนोเคคा เคนै।
-
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 buttonButton b = new Button("Click Here");b.setBounds(50, 100, 100, 40); // x, y, width, height// Add button to frameadd(b);// Frame settingssetSize(400, 400); // Frame width and heightsetLayout(null); // No layout managersetVisible(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
Post a Comment