Invisible Radiobutton

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jinnejeevansai
    New Member
    • Nov 2014
    • 48

    Invisible Radiobutton

    Hii,i was writing a code for making radiobutton but the yes button is invisible and becomes visible if i move cursor on it,Can someone explain mistake in my code.


    Code:
    import javax.swing.*;
    class r{
            public static void main(String args[])
            {
                    JFrame f = new JFrame();
                    f.setSize(200,200);
                    JRadioButton b1 = new JRadioButton("Yes");
                    JRadioButton b2 = new JRadioButton("No");
                    b1.setBounds(30,50,50,20);
                    b2.setBounds(30,80,50,20);
                    f.add(b1);
                    f.add(b2);
                    ButtonGroup bg = new ButtonGroup();
                    bg.add(b1);
                    bg.add(b2);
                    f.setVisible(true);
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
    }
    Last edited by Rabbit; Aug 30 '15, 08:09 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • jinnejeevansai
    New Member
    • Nov 2014
    • 48

    #2
    I got the correct output by writing f.setLayout(NUL L); before the line f.setVisible(tr ue); but i was not getting correct output if i wrote below setVisible line.Can someone tell why

    Comment

    Working...