I have written a code which creates graphical shapes and displays on the screen with the fonts/strings written on it.
To do this I extended the Frame class, and its paint() method was overriden and graphical shapes were created and rendered on the screen.
Now I wanted to display different string when different language option is selected.
I use DOM parser to parse different language texts (xml files that has different language tag-values) and its rendered beautifully on the screen too.
I was manually writing in the code to choose this language file to parse and render it on the screen
I wanted to use radio buttons to choose which language file to parse, but when I try to add these radio buttons to the screen, the buttons are flowing and it jitters, flickers.
Existing Code:
Class Apple extends Frame
{
private Shape A = new RoundRectangle2D.Double(20,30,100,150,10,10);
private Shape B = new RoundRectangle2D.Double(20,200,100,150,10,10);
Apple()
{
setTitle("Fruits");
setBackground(Color.BLACK);
setSize(700,700);
setVisible(true);
}
@Override
public void paint(Graphics graphics)
{
super.paint(graphics);
}
}
This code works perfectly fine,
But I want to insert few radio buttons to this screen for choosing language (for the fonts that are displayed in shapes).
So I did this
Class Apple extends Frame
{
private Shape A = new RoundRectangle2D.Double(20,30,100,150,10,10);
private Shape B = new RoundRectangle2D.Double(20,200,100,150,10,10);
CheckboxGroup languageSelector = new CheckboxGroup();
Checkbox selectEnglish = new Checkbox("English", languageSelector,true);
Checkbox selectHindi = new Checkbox("Hindi", languageSelector, false);
Apple()
{
selectEnglish.setBounds(300,100,70,50);
selectHindi.setBounds(350,100,70,50);
setTitle("Fruits");
setBackground(Color.BLACK);
setSize(700,700);
setVisible(true);
}
@Override
public void paint(Graphics graphics)
{
super.paint(graphics);
add(selectEnglish)
add(selectHindi)
}
}
What I have tried:
If I add radio buttons to the Frame directly in the Constructor it will ignore the overriden paint method and will only render the radio buttons on the screen and not the shapes..
So I thought I could add radio buttons to the frame through the overridden paint method itself, but the buttons are continuously flickering over the screen.