By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 3,090 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

Invisible Radiobutton

P: 48
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.


Expand|Select|Wrap|Line Numbers
  1. import javax.swing.*;
  2. class r{
  3.         public static void main(String args[])
  4.         {
  5.                 JFrame f = new JFrame();
  6.                 f.setSize(200,200);
  7.                 JRadioButton b1 = new JRadioButton("Yes");
  8.                 JRadioButton b2 = new JRadioButton("No");
  9.                 b1.setBounds(30,50,50,20);
  10.                 b2.setBounds(30,80,50,20);
  11.                 f.add(b1);
  12.                 f.add(b2);
  13.                 ButtonGroup bg = new ButtonGroup();
  14.                 bg.add(b1);
  15.                 bg.add(b2);
  16.                 f.setVisible(true);
  17.                 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18.         }
  19. }
Aug 30 '15 #1
Share this Question
Share on Google+
1 Reply


P: 48
I got the correct output by writing f.setLayout(NULL); before the line f.setVisible(true); but i was not getting correct output if i wrote below setVisible line.Can someone tell why
Aug 31 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.