Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

missing radio buttons

  Asked By: Erica    Date: Oct 09    Category: Java    Views: 617
  

I am trying to put a group of radio buttons on my applet. The code section
below compiles fine but none of the radio buttons appear when run. This
section is followed by another JPanel for the middle row which has its own
flow manager and works fine. I've also mucked about with the Applet size to
ensure that the radio buttons really aren't there.
Can anyone please tell me what is wrong?

public void init()
{

mainLayout = new GridLayout ( 3, 1 );
Container mainContainer = getContentPane();
mainContainer.setLayout ( mainLayout );

// deal with radio buttons
difficultyPanel = new JPanel();
mainContainer.add(difficultyPanel);

difficultyPanel.setLayout ( new FlowLayout() );

// add radiobuttons
easy = new JRadioButton ( " Easy ", true );
difficultyPanel.add (easy);

medium = new JRadioButton ( " Medium ", false );
difficultyPanel.add (medium);

hard = new JRadioButton ( " Hard ", false );
difficultyPanel.add (hard);

// register events
RadioButtonHandler handler = new RadioButtonHandler();
easy.addItemListener( handler );
medium.addItemListener( handler );
hard.addItemListener( handler );

// associate radio buttons in group
difficultyGroup = new ButtonGroup();
difficultyGroup.add ( easy );
difficultyGroup.add ( medium );
difficultyGroup.add ( hard );

this is followed by another panel, new flow layout more buttons - all of
which appear on screen as required.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on missing radio buttons Or get search suggestion and latest updates.




Tagged: