com.codename1.ui.util.Resources Java Examples
The following examples show how to use
com.codename1.ui.util.Resources.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketsSample.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void init(Object context) { try { theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch(IOException e){ e.printStackTrace(); } // Pro users - uncomment this code to get crash reports sent to you automatically /*Display.getInstance().addEdtErrorHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); Log.p("OS " + Display.getInstance().getPlatformName()); Log.p("Error " + evt.getSource()); Log.p("Current Form " + Display.getInstance().getCurrent().getName()); Log.e((Throwable)evt.getSource()); Log.sendLog(); } });*/ }
Example #2
Source File: ChartsDemo.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
public void init(Object context) { try { Resources theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch(IOException e){ e.printStackTrace(); } // Pro users - uncomment this code to get crash reports sent to you automatically /*Display.getInstance().addEdtErrorHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); Log.p("OS " + Display.getInstance().getPlatformName()); Log.p("Error " + evt.getSource()); Log.p("Current Form " + Display.getInstance().getCurrent().getName()); Log.e((Throwable)evt.getSource()); Log.sendLog(); } });*/ }
Example #3
Source File: GameCanvasImplementation.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * @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(); } } }
Example #4
Source File: StateMachine.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
private Container createATM(final ATMData d, final boolean forceBack) { Resources res = fetchResourceFile(); Container c = createContainer(res, "Entry"); Button title = findAtmTitle(c); title.setCommand(new Command(d.name) { public void actionPerformed(ActionEvent ev) { current = d; if(forceBack || !Display.getInstance().isTablet()) { back(); } else { Form currentForm = Display.getInstance().getCurrent(); if(Display.getInstance().isPortrait()) { ((Dialog)currentForm).dispose(); updateFormMap(Display.getInstance().getCurrent()); } else { updateFormMap(currentForm); } } } }); findAtmLine2(c).setText(d.location + "\n" + d.zip); findAtmUnit(c).setText(d.metric); findAtmDistance(c).setText(d.distance); findAtmPaidOrFree(c).setText(d.paid); return c; }
Example #5
Source File: ClockDemo.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
public void init(Object context) { try { Resources theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch(IOException e){ e.printStackTrace(); } // Pro users - uncomment this code to get crash reports sent to you automatically /*Display.getInstance().addEdtErrorHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); Log.p("OS " + Display.getInstance().getPlatformName()); Log.p("Error " + evt.getSource()); Log.p("Current Form " + Display.getInstance().getCurrent().getName()); Log.e((Throwable)evt.getSource()); Log.sendLog(); } });*/ }
Example #6
Source File: StyleParser.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private Border createImageBorder(Resources theme) { int ilen = getImages().length; if (ilen == 9) { return Border.createImageBorder(getImage(theme, getImages()[0]), getImage(theme, getImages()[1]), getImage(theme, getImages()[2]), getImage(theme, getImages()[3]), getImage(theme, getImages()[4]), getImage(theme, getImages()[5]), getImage(theme, getImages()[6]), getImage(theme, getImages()[7]), getImage(theme, getImages()[8]) ); } if (ilen == 3) { return Border.createImageBorder(getImage(theme, getImages()[0]), getImage(theme, getImages()[1]), getImage(theme, getImages()[2]) ); } return Border.createEmpty(); }
Example #7
Source File: PhotoShare.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
public void init(Object context) { try { Resources theme = Resources.openLayered("/theme"); placeholder = (EncodedImage)theme.getImage("thumbnail.png"); THUMB_URL_PREFIX = THUMB_URL_PREFIX + "w=" + placeholder.getWidth() + "&h=" + placeholder.getHeight() + "&i="; UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch(IOException e){ e.printStackTrace(); } // Pro users - uncomment this code to get crash reports sent to you automatically /*Display.getInstance().addEdtErrorHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); Log.p("OS " + Display.getInstance().getPlatformName()); Log.p("Error " + evt.getSource()); Log.p("Current Form " + Display.getInstance().getCurrent().getName()); Log.e((Throwable)evt.getSource()); Log.sendLog(); } });*/ }
Example #8
Source File: StyleParser.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private static Image getImage(Resources theme, String imageStr) { Image im = null; try { if (imageStr.startsWith("/")) { im = Image.createImage(imageStr); } else { im = theme.getImage((String) imageStr); } } catch (IOException ex) { System.out.println("failed to parse image"); } return im; }
Example #9
Source File: LocalNotificationTest.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
public void init(Object context) { try { theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch(IOException e){ e.printStackTrace(); } // Pro users - uncomment this code to get crash reports sent to you automatically /*Display.getInstance().addEdtErrorHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); Log.p("OS " + Display.getInstance().getPlatformName()); Log.p("Error " + evt.getSource()); Log.p("Current Form " + Display.getInstance().getCurrent().getName()); Log.e((Throwable)evt.getSource()); Log.sendLog(); } });*/ }
Example #10
Source File: StateMachine.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
private void addPeople(Container c) { c.removeAll(); Resources r = fetchResourceFile(); for(int iter = 0 ; iter < C_NAMES.length ; iter++) { MultiButton mb = new MultiButton(); mb.setEmblem(null); mb.setHorizontalLayout(true); mb.setTextLine1(C_NAMES[iter]); mb.setTextLine2(C_DATE[iter]); mb.setTextLine3(C_LINE1[iter]); mb.setTextLine4(C_LINE2[iter]); mb.setMaskName("maskImage"); mb.setIconUIID("Avatar"); mb.setIcon(r.getImage(C_AVATAR[iter])); final int current = iter; mb.setCommand(new Command("") { public void actionPerformed(ActionEvent ev) { selectedOffset = current; showForm("Person", null); } }); c.addComponent(mb); } }
Example #11
Source File: Solitaire.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
public void init(Object context) { try { theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); int dpi = Preferences.get("dpi", calculateDPI()); cards = Resources.open("/gamedata.res",dpi); currentZoom = Preferences.get("zoom", defaultZoom); } catch(IOException e){ e.printStackTrace(); } // Pro users - uncomment this code to get crash reports sent to you automatically Display.getInstance().addEdtErrorHandler(new ActionListener() { public void actionPerformed(ActionEvent evt) { evt.consume(); Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); Log.p("OS " + Display.getInstance().getPlatformName()); Log.p("Error " + evt.getSource()); Log.p("Current Form " + Display.getInstance().getCurrent().getName()); Log.e((Throwable)evt.getSource()); Log.sendLog(); } }); }
Example #12
Source File: Solitaire.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
void refreshZoom(Container solitairContainer) { int dpi = DPIS[currentZoom / 5]; Preferences.set("dpi", dpi); Preferences.set("zoom", currentZoom); try { cards = Resources.open("/gamedata.res",dpi); cardImageCache.clear(); Image cardBack = getCardImage("card_back.png"); for(Component c : solitairContainer) { CardComponent crd = (CardComponent)c; crd.setImages(getCardImage(crd.getCard().getFileName()), cardBack); } solitairContainer.revalidate(); solitairContainer.getParent().replace(solitairContainer.getParent().getComponentAt(0), createPlacementContainer(solitairContainer), null); } catch(IOException e) { Log.e(e); } }
Example #13
Source File: DrSbaitso.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { Resources theme = UIManager.initFirstTheme("/theme"); userPicture = theme.getImage("duke_iphone.png"); tts = (TTS)NativeLookup.create(TTS.class); // Pro only feature, uncomment if you have a pro subscription //Log.bindCrashProtection(true); }
Example #14
Source File: CameraDemo.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { try { Resources theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); //Enable Toolbar to all Forms by default Toolbar.setGlobalToolbar(true); } catch (IOException e) { e.printStackTrace(); } }
Example #15
Source File: GeoVizDemo.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { try { Resources theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch(IOException e){ e.printStackTrace(); } }
Example #16
Source File: BlackBerryImplementation.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Installs the native theme, this is only applicable if hasNativeTheme() returned true. Notice that this method * might replace the DefaultLookAndFeel instance and the default transitions. */ public void installNativeTheme() { if (nativeThemeAvailable) { try { InputStream is = getResourceAsStream(getClass(), "/blackberry_theme.res"); Resources r = Resources.open(is); UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0])); is.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
Example #17
Source File: EmailShare.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
@Override public Image getIcon() { Image i = super.getIcon(); if(i == null) { i = Resources.getSystemResource().getImage("mail.png"); setIcon(i); } return i; }
Example #18
Source File: SMSShare.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
@Override public Image getIcon() { Image i = super.getIcon(); if(i == null) { i = Resources.getSystemResource().getImage("sms.png"); setIcon(i); } return i; }
Example #19
Source File: FacebookShare.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
@Override public Image getIcon() { Image i = super.getIcon(); if(i == null) { i = Resources.getSystemResource().getImage("facebook.png"); setIcon(i); } return i; }
Example #20
Source File: StyleParser.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
static Border parseBorder(Resources theme, String args) { BorderInfo info = parseBorder(new BorderInfo(), args); if (info == null) { return null; } return info.createBorder(theme); }
Example #21
Source File: StyleParser.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Creates the border that is described by this border info. * @param theme Theme resource file used to load images that are referenced. * @return A Border. */ public Border createBorder(Resources theme) { if (getType() == null || "empty".equals(getType()) || "none".equals(getType())) { return Border.createEmpty(); } if ("line".equals(getType())) { return createLineBorder(); } if ("dashed".equals(getType())) { return createDashedBorder(); } if ("dotted".equals(getType())) { return createDottedBorder(); } if ("underline".equals(getType())) { return createUnderlineBorder(); } if ("image".equals(getType())) { return createImageBorder(theme); } if ("horizontalImage".equals(getType())) { return createHorizontalImageBorder(theme); } if ("verticalImage".equals(getType())) { return createVerticalImageBorder(theme); } if ("splicedImage".equals(getType())) { return createSplicedImageBorder(theme); } if ("round".equals(getType())) { return createRoundBorder(); } if ("roundRect".equals(getType())) { return createRoundRectBorder(); } return Border.createEmpty(); }
Example #22
Source File: UIManager.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Same as the initFirstTheme method, but unlike that method this allows specifying the theme resource name * @param resourceFile the name of the resource file starting with / and without the res extension * @param resName the name of the theme to use from the file if it contains more than one theme * @return the resource file or null in case of a failure */ public static Resources initNamedTheme(String resourceFile, String resName) { try { Resources theme = Resources.openLayered(resourceFile); UIManager.getInstance().setThemeProps(theme.getTheme(resName)); Resources.setGlobalResources(theme); return theme; } catch(IOException e){ Log.e(e); } return null; }
Example #23
Source File: SignIn.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { try { theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch (IOException e) { e.printStackTrace(); } }
Example #24
Source File: FBDemo.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { System.out.println("init"); try { theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch (IOException e) { e.printStackTrace(); } }
Example #25
Source File: SignIn.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { try { theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); } catch (IOException e) { e.printStackTrace(); } }
Example #26
Source File: StateMachine.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
@Override protected void onMain_ToggleThemeAction(Component c, ActionEvent event) { Resources res = fetchResourceFile(); if(leatherTheme) { UIManager.getInstance().setThemeProps(res.getTheme("Native")); } else { UIManager.getInstance().setThemeProps(res.getTheme("Theme")); } leatherTheme = !leatherTheme; Display.getInstance().getCurrent().refreshTheme(); }
Example #27
Source File: StateMachine.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
@Override public Container createContainer(Resources res, String resourceName) { if(Display.getInstance().isTablet() && resourceName.equals("Main")) { return super.createContainer(res, "Person"); } return super.createContainer(res, resourceName); }
Example #28
Source File: MapsDemo.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context) { Resources theme = UIManager.initFirstTheme("/theme"); //Enable Toolbar to all Forms by default Toolbar.setGlobalToolbar(true); // Pro only feature, uncomment if you have a pro subscription //Log.bindCrashProtection(true); }
Example #29
Source File: KitchenSink.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
public void init(Object context){ //Log.setReportingLevel(Log.REPORTING_PRODUCTION); //DefaultCrashReporter.init(true, 2); Log.p("Init"); try{ res = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(res.getTheme(res.getThemeResourceNames()[0])); } catch(IOException e){ Log.e(e); } }
Example #30
Source File: PropertyCross.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
/** * This is a Codename One initialization callback that is invoked when the app is started */ public void init(Object context) { try { // loading the theme of the application Resources theme = Resources.openLayered("/theme"); UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0])); // the specification requires that only portrait would be supported Display.getInstance().lockOrientation(true); // We load the images that are stored in the resource file here so we can use them later placeholder = (EncodedImage)theme.getImage("placeholder"); favoriteSel = theme.getImage("favorite_sel"); favoriteUnsel = theme.getImage("favorite_unsel"); // We initialize the lists of favorites and recent entries here, we load them from storage and save // them whenever we change them favoritesList = (List<Map<String, Object>>)Storage.getInstance().readObject("favoritesList"); if(favoritesList == null) { favoritesList = new ArrayList<Map<String, Object>>(); } recentSearchesList = (List<Map<String, String>>)Storage.getInstance().readObject("recentSearches"); if(recentSearchesList == null) { recentSearchesList = new ArrayList<Map<String, String>>(); } } catch(IOException e){ e.printStackTrace(); } }