use of com.codename1.ui.util.Resources in project CodenameOne by codenameone.
the class GameCanvasImplementation method installNativeTheme.
/**
* @inheritDoc
*/
public void installNativeTheme() {
InputStream i = getResourceAsStream(getClass(), "/nokia_touch_theme.res");
if (i == null) {
i = getResourceAsStream(getClass(), "/nokia_non_touch.res");
}
if (i == null) {
i = getResourceAsStream(getClass(), "/nokia_asha_theme.res");
}
if (i == null) {
i = getResourceAsStream(getClass(), "/nativeJ2METheme.res");
}
if (i != null) {
try {
Resources r = Resources.open(i);
UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
} catch (Throwable t) {
t.printStackTrace();
}
}
}
use of com.codename1.ui.util.Resources in project CodenameOne by codenameone.
the class ComponentTreeInspector method editStyle.
// GEN-LAST:event_unselectedActionPerformed
private void editStyle() {
File cn1dir = new File(System.getProperty("user.home"), ".codenameone");
if (!cn1dir.exists()) {
JOptionPane.showMessageDialog(this, "Please open the designer once by opening the theme.res file", "Error Opening Designer", JOptionPane.ERROR_MESSAGE);
return;
}
File resourceEditor = new File(cn1dir, "designer_1.jar");
if (!resourceEditor.exists()) {
resourceEditor = new File(cn1dir, "designer.jar");
}
if (!resourceEditor.exists()) {
JOptionPane.showMessageDialog(this, "Please open the designer once by opening the theme.res file", "Error Opening Designer", JOptionPane.ERROR_MESSAGE);
return;
}
File javaBin = new File(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java.exe");
if (!javaBin.exists()) {
javaBin = new File(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");
}
final File javaExe = javaBin;
final File resourceEditorFinal = resourceEditor;
final String themeFile = themePaths.get(themes.getSelectedIndex());
final String themeName = themeNames.get(themes.getSelectedIndex());
final String uiid = componentUIID.getText();
new Thread() {
@Override
public void run() {
try {
ProcessBuilder pb = new ProcessBuilder(javaExe.getAbsolutePath(), "-jar", resourceEditorFinal.getAbsolutePath(), "-style", themeFile, uiid, themeName).inheritIO();
Process proc = pb.start();
proc.waitFor();
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
try {
Resources res = Resources.open(new FileInputStream(themeFile));
UIManager.getInstance().addThemeProps(res.getTheme(themeName));
Display.getInstance().getCurrent().refreshTheme();
Display.getInstance().getCurrent().revalidate();
} catch (Exception err) {
err.printStackTrace();
}
}
});
} catch (Exception err) {
err.printStackTrace();
}
}
}.start();
}
Aggregations