/** * Called by {@link #getResourceMap} to construct {@code ResourceMaps}. * By default this method is effectively just: * <pre> * return new ResourceMap(parent, classLoader, bundleNames); * </pre> * Custom ResourceManagers might override this method to construct their * own ResourceMap subclasses. */ protected ResourceMap createResourceMap(ClassLoader classLoader, ResourceMap parent, List<String> bundleNames) { return new ResourceMap(parent, classLoader, bundleNames); }
/** * Returns true if this resourceMap or its parent (recursively) contains * the specified key. * * @return true if this resourceMap or its parent contains the specified key. * @see #getParent * @see #keySet */ public boolean containsKey(String key) { checkNullKey(key); if (containsResourceKey(key)) { return true; } else { ResourceMap parent = getParent(); return (parent != null) && parent.containsKey(key); } }
private synchronized Set<String> getBundlesMapKeys() { if (bundlesMapKeysP == null) { Set<String> allKeys = new HashSet<String>(getResourceKeySet()); ResourceMap parent = getParent(); if (parent != null) { allKeys.addAll(parent.keySet()); } bundlesMapKeysP = Collections.unmodifiableSet(allKeys); } return bundlesMapKeysP; }
/** * By default this method is used by {@code getObject} to see * if a resource is defined by this ResourceMap. This method lazily * loads the ResourceBundles named by the constructor. * <p> * The protected {@code getResource}, {@code putResource}, and * {@code containsResourceKey}, {@code getResourceKeySet} abstract * the internal representation of this ResourceMap's list of * {@code ResourceBundles}. Most applications can ignore them. * <p> * If {@code key} is null, an IllegalArgumentException is thrown. * * @param key the name of the resource * @return true if a resource named {@code key} is defined in this ResourceMap * @see #getResource * @see #putResource * @see #getResourceKeySet */ protected boolean containsResourceKey(String key) { checkNullKey(key); Map<String, Object> bundlesMap = getBundlesMap(); return (bundlesMap != null) && bundlesMap.containsKey(key); }
String text = resourceMap.getString(baseName + ".Action.text"); if (text != null) { MnemonicText.configure(this, text); Integer mnemonic = resourceMap.getKeyCode(baseName + ".Action.mnemonic"); if (mnemonic != null) { putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic); Integer index = resourceMap.getInteger(baseName + ".Action.displayedMnemonicIndex"); if (index != null) { putValue(DISPLAYED_MNEMONIC_INDEX_KEY, index); KeyStroke key = resourceMap.getKeyStroke(baseName + ".Action.accelerator"); if (key != null) { putValue(javax.swing.Action.ACCELERATOR_KEY, key); Icon icon = resourceMap.getIcon(baseName + ".Action.icon"); if (icon != null) { putValue(javax.swing.Action.SMALL_ICON, icon); Icon smallIcon = resourceMap.getIcon(baseName + ".Action.smallIcon"); if (smallIcon != null) { putValue(javax.swing.Action.SMALL_ICON, smallIcon); Icon largeIcon = resourceMap.getIcon(baseName + ".Action.largeIcon"); if (largeIcon != null) { putValue(LARGE_ICON_KEY, largeIcon); String shortDescription = resourceMap.getString(baseName +
checkNullKey(key); if (type == null) { throw new IllegalArgumentException("null type"); if (resourceMapNode.containsResourceKey(key)) { value = resourceMapNode.getResource(key); break; resourceMapNode = resourceMapNode.getParent(); value = evaluateStringExpression((String)value); resourceMapNode.putResource(key, value); try { value = stringConverter.parseString(sValue, resourceMapNode); resourceMapNode.putResource(key, value);
/** * Initialize the hierarchy with the specified root by * injecting resources. * <p> * By default the {@code show} methods * {@link ResourceMap#injectComponents inject resources} before * initializing the JFrame or JDialog's size, location, * and restoring the window's session state. If the app * is showing a window whose resources have already been injected, * or that shouldn't be initialized via resource injection, * this method can be overridden to defeat the default * behavior. * * @param root the root of the component hierarchy * @see ResourceMap#injectComponents * @see #show(JComponent) * @see #show(JFrame) * @see #show(JDialog) */ protected void configureWindow(Window root) { getContext().getResourceMap().injectComponents(root); }
setTitle(resourceMap.getString("Form.title")); // NOI18N setName("Form"); // NOI18N jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N jLabel2.setName("jLabel2"); // NOI18N jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N jLabel3.setName("jLabel3"); // NOI18N jScrollPane1.setViewportView(jTextArea1); jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N jLabel4.setName("jLabel4"); // NOI18N jTextField1.setBackground(resourceMap.getColor("jTextField1.background")); // NOI18N jTextField1.setEditable(false); jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N jTextField1.setName("jTextField1"); // NOI18N
/** * Return the JFrame used to show this View * * <p> * This method may be called at any time; the JFrame is created lazily * and cached. For example: * <pre> * @Override protected void startup() { * getFrame().setJMenuBar(createMenuBar()); * show(createMainPanel()); * } * </pre> * * @return this application's main frame */ public JFrame getFrame() { if (frame == null) { ResourceMap resourceMap = getContext().getResourceMap(); String title = resourceMap.getString(KEY_APPLICATION_TITLE); frame = new JFrame(title); frame.setName(MAIN_FRAME_NAME); if (resourceMap.containsKey(KEY_APPLICATION_ICON)) { Image icon = resourceMap.getImageIcon(KEY_APPLICATION_ICON).getImage(); frame.setIconImage(icon); } } return frame; }
resource.injectComponents(frame); frame.setTitle(resource.getString("frameTitleMask", book.getRadix()));
jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N jLabel2.setName("jLabel2"); // NOI18N jScrollPane1.setViewportView(jTextArea1); jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N jButton1.setName("jButton1"); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N jLabel3.setName("jLabel3"); // NOI18N jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N jButton2.setName("jButton2"); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() {
appResourceMap.putResource(ResourceMap.KEY_PLATFORM, platform); String lnfResource = appResourceMap.getString(key); String lnf = (lnfResource == null) ? "system" : lnfResource; try {
/** * Applies {@link #injectComponent} to each Component in the * hierarchy with root <tt>root</tt>. * * @param root the root of the component hierarchy * @throws PropertyInjectionException if a property specified by a resource can't be set * @throws IllegalArgumentException if target is null * @see #injectComponent */ public void injectComponents(Component root) { injectComponent(root); if (root instanceof JMenu) { /* Warning: we're bypassing the popupMenu here because * JMenu#getPopupMenu creates it; doesn't seem right * to do so at injection time. Unfortunately, this * means that attempts to inject the popup menu's * "label" property will fail. */ JMenu menu = (JMenu) root; for (Component child : menu.getMenuComponents()) { injectComponents(child); } } else if (root instanceof Container) { Container container = (Container) root; for (Component child : container.getComponents()) { injectComponents(child); } } }
checkNullKey(key); setPlatform((PlatformType) value); } else { Map<String, Object> bundlesMap = getBundlesMap(); if (bundlesMap != null) { bundlesMap.put(key, (value == null) ? NULL_RESOURCE : value);
private void injectComponentProperty(Component component, PropertyDescriptor pd, String key) { Method setter = pd.getWriteMethod(); Class type = pd.getPropertyType(); if ((setter != null) && (type != null) && containsKey(key)) { Object value = getObject(key, type); String propertyName = pd.getName(); try {
public DesignResourceMap getDesignParent() { ResourceMap parent = super.getParent(); return parent instanceof DesignResourceMap ? (DesignResourceMap) parent : null; }
/** * By default this method is used by {@code keySet} to * get the names of the resources defined in this ResourceMap. * This method lazily loads the ResourceBundles named * by the constructor. * <p> * The protected {@code getResource}, {@code putResource}, and * {@code containsResourceKey}, {@code getResourceKeySet} abstract * the internal representation of this ResourceMap's list of * {@code ResourceBundles}. Most applications can ignore them. * * @return the names of the resources defined in this ResourceMap * @see #getResource * @see #putResource * @see #containsResourceKey */ protected Set<String> getResourceKeySet() { Map<String, Object> bundlesMap = getBundlesMap(); if (bundlesMap == null) { return Collections.emptySet(); } else { return bundlesMap.keySet(); } }
String bpn = bundlePackageName(bundleNames.get(0)); for (String bn : bundleNames) { if (!bpn.equals(bundlePackageName(bn))) { throw new IllegalArgumentException("bundles not colocated: \"" + bn + "\" != \"" + bpn + "\"");
String text = resourceMap.getString(baseName + ".Action.text"); if (text != null) { MnemonicText.configure(this, text); Integer mnemonic = resourceMap.getKeyCode(baseName + ".Action.mnemonic"); if (mnemonic != null) { putValue(javax.swing.Action.MNEMONIC_KEY, mnemonic); Integer index = resourceMap.getInteger(baseName + ".Action.displayedMnemonicIndex"); if (index != null) { putValue(DISPLAYED_MNEMONIC_INDEX_KEY, index); KeyStroke key = resourceMap.getKeyStroke(baseName + ".Action.accelerator"); if (key != null) { putValue(javax.swing.Action.ACCELERATOR_KEY, key); Icon icon = resourceMap.getIcon(baseName + ".Action.icon"); if (icon != null) { putValue(javax.swing.Action.SMALL_ICON, icon); Icon smallIcon = resourceMap.getIcon(baseName + ".Action.smallIcon"); if (smallIcon != null) { putValue(javax.swing.Action.SMALL_ICON, smallIcon); Icon largeIcon = resourceMap.getIcon(baseName + ".Action.largeIcon"); if (largeIcon != null) { putValue(LARGE_ICON_KEY, largeIcon); resourceMap.getString(baseName + ".Action.shortDescription"));