swing components and containers in hindi

Swing components and containers in hindi:-

जावा में, swing components जो है वह बेसिक यूजर इंटरफ़ेस ऑब्जेक्ट होता है तथा यह सभी जावा एप्लीकेशनों में पाया जाता है.

swing फ्रेमवर्क में बहुत सारें components है जो कि बहुत ही अच्छे functions तथा उच्च स्तर के customization उपलब्ध कराते है.

swing components का प्रयोग करने के लिए हमें container की आवश्यकता होती है. container जो है वह components को रखने के लिए जगह देता है तथा उनको मैनेज करता है.

इसमें दो प्रकार के containers होते है:-

1:- top level containers

2:- light weight containers

1:- top level container:- इसमें JFrame, JApplet तथा JDialog आदि components आते है. ये AWT के components तथा container को inherit करते है तथा ये components बहुत heavyweight होते है.

2:- light weight containers:- light weight container का उदाहरण है:- JPanel.
यह JComponent क्लास को inherit करता है.

कुछ महत्वपूर्ण swing components classes:-

Java swing components

यहाँ पर हम कुछ महत्वपूर्ण swing components है जो कि ज्यादातर प्रयोग किये जाते है हम उनके बारें में पढेंगे.

JButton:-

JButton class का प्रयोग labelled button को create करने के लिए किया जाता है.

JButton class declaration:- नीचे javax.swing.JButton class का declaration दिया गया है:-

public class JButton
   extends AbstractButton
      implements Accessible

JButton class constructor:- इसके मुख्य constructor निम्नलिखित है.

  • JButton() – इसके द्वारा button बनाया जाता है जिसमें ना तो text होता है ना ही icon.
  • JButton(string text)- इसके द्वारा button बनाया जाता हैं जिसमें text होता है.
  • JButton(Icon icon)- icon के साथ button बनाया जाता है.
  • JButton(string text, Icon icon)- icon के साथ button बनाया जाता है.

JTextField-

JTextField का प्रयोग एक single line text को edit करने के लिए किया जाता है.

JTextField class declaration:- नीचे javax.swing.JTextField class का declaration दिया गया है:-

public class JTextField
   extends JTextComponent
      implements SwingConstants

JTextField class constructor:- इसमें मुख्य रूप से प्रयोग होने वाले constructors निम्नलिखित है:-

  • JTextField()- यह नए textfield को create करता है.
  • JTextField(string text)- यह नए TextField को create करता है जो कि एक विशिष्ट text से initialize होता है.

JCheckBox:-

इसका प्रयोग checkbox को बनाने के लिए किया जाता है.

JCheckBox class declaration:– नीचे javax.swing.JCheckBox class का declaration दिया गया है.

public class JCheckBox
   extends JToggleButton
      implements Accessible

JCheckBox class constructors:-

इसमें मुख्य रूप से प्रयोग होने वाले constructors निम्नलिखित है:-

  • JCheckBox():- इसके द्वारा unselected checkbox बनाया जाता है जिसमें ना तो text होता है ना ही icon.
  • JCheckBox(String text):- इसके द्वारा unselected checkbox बनाया जाता है जिसमें text होता है.
  • JCheckBox(Icon icon):- इसके द्वारा unselected checkbox बनाया जाता है जिसमें icon होता है.
  • JCheckBox(String text, Icon icon):- इसके द्वारा unselected checkbox बनाया जाता है जिसमें icon तथा text दोनों होते हैं.

Leave a Comment