Skip to main content

Unable to refresh fonts (when switching to another res file)

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
gavdian
Offline
Joined: 2010-07-13

Hi everyone,
I have 2 res files in my project (1.res & 2.res).
In a "fontSelection" form I have 2 radiobuttons "Big fonts" and "Small fonts". The 1.res and 2.res files have exactly the same names for all the themes, components and fonts they contain. The only thing that 1.res and 2.res differ is the font size.
The code I'm using for the radioButtons:

public void actionPerformed(ActionEvent arg0)
{
int index = group1.getSelectedIndex();
radioText = group1.getRadioButton(index).getText();

if (radioText.equals("Big fonts"))
{
try
{
res = Resources.open("/1.res");
UIManager.getInstance().setThemeProps(res.getTheme(themeName));
Display.getInstance().getCurrent().refreshTheme();
} catch (IOException e)
{
e.printStackTrace();
}
} else if (radioText.equals("Small fonts"))
{
try
{
res = Resources.open("/2.res");
UIManager.getInstance().setThemeProps(res.getTheme(themeName));
Display.getInstance().getCurrent().refreshTheme();
} catch (IOException e)
{
e.printStackTrace();
}
}
}

Unfortunately the font size does not refresh.
I changed the fgColor of the Label in 1.res file just to be sure that the resource files properly switch between them and the refresh takes place as expected.
Why is the font size not affected? Am I doing something wrong? How is it possible to solve this?
Thanks in advance :)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

The difference between system font types might not be obious on all devices/simulators.