當前位置: 首頁>>代碼示例>>Java>>正文


Java Preferences.putBoolean方法代碼示例

本文整理匯總了Java中java.util.prefs.Preferences.putBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.putBoolean方法的具體用法?Java Preferences.putBoolean怎麽用?Java Preferences.putBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.prefs.Preferences的用法示例。


在下文中一共展示了Preferences.putBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPreferencies

import java.util.prefs.Preferences; //導入方法依賴的package包/類
@RandomlyFails // NB-Core-Build #7956
public void testPreferencies() throws Exception {
    UIHandler.registerExceptionHandler(true);
    Installer o = Installer.findObject(Installer.class, true);
    assertNotNull("Installer wasn't created.", o);
    o.restored();

    Preferences prefs = NbPreferences.forModule(WritablePreferences131128Test.class);
    prefs.putBoolean("anything", true);
    Thread.sleep(1000);
    assertTrue("Musn't cycle when preferences are not writable.", MockPreferencesProviderImpl.flushSpiCount <= 4);
    assertTrue("DialogDisplayer.notify not called to inform user about not writable preferences.", Displayer.notifyCalled);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:WritablePreferences131128Test.java

示例2: testNewLineIndentationInsideAbsolutLabeledStatement

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testNewLineIndentationInsideAbsolutLabeledStatement() throws Exception {
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.putBoolean("absoluteLabelIndent", true);
    try {
        performNewLineIndentationTest("package t;\npublic class T {\n    public void op() {\nmylabel:|\n    }\n}\n",
                "package t;\npublic class T {\n    public void op() {\nmylabel:\n        \n    }\n}\n");
    } finally {
        preferences.remove("absoluteLabelIndent");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:ReindenterTest.java

示例3: testRemoveLocallyRemovedKeyNothingInherited

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * If a key is locally removed from ProxyPrefs, then it is removed from the underlying storage as well,
 * ProxyPrefs attempt to recover the value through inheritance. If the value is not inherited at all,
 * no event should be produced, as the removal was already done (in-memory).
 */
public void testRemoveLocallyRemovedKeyNothingInherited() throws Exception {
    Preferences stored = new MapPreferences();
    Preferences inherited = new MapPreferences();
    
    stored.putBoolean("toBeRemoved", Boolean.TRUE);

    MemoryPreferences mem = MemoryPreferences.getWithInherited(this, inherited, stored);
    Preferences test = mem.getPreferences();
    
    PL pl = new PL();
    test.addPreferenceChangeListener(pl);

    pl.arm();
    test.remove("toBeRemoved");
    pl.waitEvent();
    
    // check the first removal was fired properly
    assertNull(test.get("toBeRemoved", null));
    assertEquals(1, pl.changeCount);
    assertNull(pl.value);
    assertEquals("toBeRemoved", pl.key);
    
    pl.arm();
    stored.remove("toBeRemoved");
    pl.waitEvent();
    // no additional event was seen
    assertEquals(1, pl.changeCount);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:ProxyPreferencesImplTest.java

示例4: removeNotify

import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Override
public void removeNotify() {
    //remember filter settings
    if( null != filterStates ) {
        Preferences prefs = getPreferences();
        for( String filterName : filterStates.keySet() ) {
            prefs.putBoolean( filterName, filterStates.get( filterName ) );
        }
    }
    super.removeNotify();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:FiltersManager.java

示例5: actionPerformed

import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    boolean b = showAsPackages();
    Preferences prefs = NbPreferences.root().node(PREF_RESOURCES_UI); //NOI18N
    prefs.putBoolean(SHOW_AS_PACKAGES, !b); //NOI18N
    try {
        prefs.flush();
    } catch (BackingStoreException ex) {
        Exceptions.printStackTrace(ex);
    }
    ((OthersRootChildren)getChildren()).doRefresh();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:OthersRootNode.java

示例6: SearchDependencyCustomizer

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/** Creates new form SearchDependencyCustomizer */
public SearchDependencyCustomizer(Preferences p) {
    this.p = p;
    initComponents();
    boolean b = p.getBoolean(SearchClassDependencyHint.OPTION_DIALOG, true);
    if (b) {
        jrOptionDialog.setSelected(true);
    }else{
        jrOptionInplace.setSelected(true);
    }
    p.putBoolean(SearchClassDependencyHint.OPTION_DIALOG, jrOptionDialog.isSelected());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:SearchDependencyCustomizer.java

示例7: checkPreferencesAction

import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void checkPreferencesAction(Action a, Preferences prefsNode) throws Exception {
    prefsNode.putBoolean("myKey", true);
    prefsNode.sync();
    class L implements PreferenceChangeListener {
        boolean notified;

        public synchronized void preferenceChange(PreferenceChangeEvent evt) {
            notified = true;
            notifyAll();
        }

        public synchronized void waitFor() throws Exception {
            while (!notified) {
                wait();
            }
            notified = false;
        }
    }
    L listener = new L();

    // Verify value
    assertTrue("Expected true as preference value", prefsNode.getBoolean("myKey", false));

    TestCase.assertTrue("Expected to be instance of Presenter.Menu", a instanceof Presenter.Menu);
    JMenuItem item = ((Presenter.Menu) a).getMenuPresenter();
    TestCase.assertTrue("Expected to be selected", item.isSelected());
    prefsNode.addPreferenceChangeListener(listener);
    prefsNode.putBoolean("myKey", false);
    prefsNode.sync();
    listener.waitFor();
    TestCase.assertFalse("Expected to not be selected", item.isSelected());
    a.actionPerformed(null); // new ActionEvent(null, 0, ""));
    listener.waitFor();
    TestCase.assertTrue("Expected to be selected", item.isSelected());
    prefsNode.putBoolean("myKey", false);
    prefsNode.sync();
    listener.waitFor();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:AlwaysEnabledActionTest.java

示例8: save

import java.util.prefs.Preferences; //導入方法依賴的package包/類
void save( Preferences prefs, String prefix ) throws BackingStoreException {
    prefs.putBoolean( prefix+"_allTrue", allTrue ); //NOI18N
    prefs.putInt( prefix+"_count", appliedConditions.size() ); //NOI18N
    for( int i=0; i<appliedConditions.size(); i++ ) {
        appliedConditions.get( i ).save( prefs, prefix+"_condition_" + i ); //NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:KeywordsFilter.java

示例9: store

import java.util.prefs.Preferences; //導入方法依賴的package包/類
void store() {
    Preferences pref = NbPreferences.forModule(TimelinePanel.class);

    // flags
    pref.putBoolean(MapFlag.WALK.getPrefKey(), walkFlagCheckBox.isSelected());
    pref.putBoolean(MapFlag.FLY.getPrefKey(), flyFlagCheckBox.isSelected());

    pref.putBoolean(MapFlag.SWIM.getPrefKey(), swimFlagCheckBox.isSelected());
    pref.putBoolean(MapFlag.JUMP.getPrefKey(), jumpFlagCheckBox.isSelected());

    pref.putBoolean(MapFlag.DOOR.getPrefKey(), doorFlagCheckBox.isSelected());
    pref.putBoolean(MapFlag.SPECIAL.getPrefKey(), specialFlagCheckBox.isSelected());

    pref.putBoolean(MapFlag.LADDER.getPrefKey(), ladderFlagCheckBox.isSelected());
    pref.putBoolean(MapFlag.PROSCRIBED.getPrefKey(), proscribedFlagCheckBox.isSelected());

    pref.putBoolean(MapFlag.FORCED.getPrefKey(), forcedFlagCheckBox.isSelected());
    pref.putBoolean(MapFlag.PLAYER_ONLY.getPrefKey(), playerOnlyFlagCheckBox.isSelected());

    // Low Color
    Color lowColor = this.lowColorArea.getBackground();
    pref.putInt(MapColor.LOW_COLOR_KEY.getPrefKey(), lowColor.getRGB());

    // High Color
    Color highColor = this.highColorArea.getBackground();
    pref.putInt(MapColor.HIGH_COLOR_KEY.getPrefKey(), highColor.getRGB());

    // Waypoints
    Color waypointsColor = this.waypointsColorArea.getBackground();
    pref.putInt(MapColor.WAYPOINTS_COLOR_KEY.getPrefKey(), waypointsColor.getRGB());

    pref.putBoolean(INCLUDE_FLAG_KEY, includeFlagsRadioButton.isSelected());
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:34,代碼來源:TimelinePanel.java

示例10: setEnabled

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void setEnabled(boolean enabled) {
    this.enabled = enabled;
    Preferences statsPrefs = NbPreferences.forModule(StatsCollector.class);
    statsPrefs.putBoolean("stats.enabled", enabled);
    try {
        statsPrefs.flush();
    } catch (BackingStoreException ex) {
        LOG.log(Level.FINE, null, ex);
    }
}
 
開發者ID:NBANDROIDTEAM,項目名稱:NBANDROID-V2,代碼行數:11,代碼來源:StatsCollector.java

示例11: testNewLineIndentationBeforeAbsolutLabeledStatement

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testNewLineIndentationBeforeAbsolutLabeledStatement() throws Exception {
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.putBoolean("absoluteLabelIndent", true);
    try {
        performNewLineIndentationTest("package t;\npublic class T {\n    public void op() {|mylabel:\n    }\n}\n",
                "package t;\npublic class T {\n    public void op() {\nmylabel:\n    }\n}\n");
    } finally {
        preferences.remove("absoluteLabelIndent");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:ReindenterTest.java

示例12: estimateCustomStartTime

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Makes an estimate how fast a custom indexer is
 *
 * @param indexerName
 * @return estimate time [ms] for indexer start completion
 */
private int estimateCustomStartTime(CustomIndexerFactory srcFactory) {
    // PENDING: modify the time, if the source root is a remote or otherwise slow filesystem
    if (modifiedResourceCount == 0 && allResourceCount == 0) {
        return -1;
    }
    Preferences moduleNode = indexerProfileNode(srcFactory);
    int c1 = moduleNode.getInt("modifiedStartTime", 500); // NOI18N
    int c2 = moduleNode.getInt("fileStartTime", 300); // NOI18N
    int c3 = moduleNode.getInt("startBaseTime", 300); // NOI18N
    moduleNode.putBoolean("hello", true);
    int threshold = Math.max(modifiedResourceCount * c1, allResourceCount * c2) + c3;
    return threshold;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:RepositoryUpdater.java

示例13: setButtonSelected

import java.util.prefs.Preferences; //導入方法依賴的package包/類
private static void setButtonSelected(String name, boolean selected) {
    Preferences preferences = NbPreferences.forModule(VariablesViewButtons.class).node(PREFERENCES_NAME);
    preferences.putBoolean(name, selected);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:VariablesViewButtons.java

示例14: save

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Save these settings.
 */
@FromAnyThread
public synchronized void save() {

    final Preferences prefs = Preferences.userNodeForPackage(Editor.class);
    prefs.putInt(PREF_GRAPHIC_ANISOTROPY, getAnisotropy());
    prefs.putBoolean(PREF_GRAPHIC_FXAA, isFXAA());
    prefs.putBoolean(PREF_GRAPHIC_GAMA_CORRECTION, isGammaCorrection());
    prefs.putBoolean(PREF_GRAPHIC_STOP_RENDER_ON_LOST_FOCUS, isStopRenderOnLostFocus());
    prefs.putBoolean(PREF_GRAPHIC_TONEMAP_FILTER, isToneMapFilter());
    prefs.putInt(PREF_SCREEN_HEIGHT, getScreenHeight());
    prefs.putInt(PREF_SCREEN_WIDTH, getScreenWidth());
    prefs.putBoolean(PREF_SCREEN_MAXIMIZED, isMaximized());
    prefs.putInt(PREF_OTHER_GLOBAL_LEFT_TOOL_WIDTH, getGlobalLeftToolWidth());
    prefs.putBoolean(PREF_OTHER_GLOBAL_LEFT_TOOL_COLLAPSED, isGlobalLeftToolCollapsed());
    prefs.putInt(PREF_OTHER_GLOBAL_BOTTOM_TOOL_WIDTH, getGlobalBottomToolHeight());
    prefs.putBoolean(PREF_OTHER_GLOBAL_BOTTOM_TOOL_COLLAPSED, isGlobalBottomToolCollapsed());
    prefs.putBoolean(PREF_OTHER_ANALYTICS, isAnalytics());
    prefs.putBoolean(PREF_OTHER_NATIVE_FILE_CHOOSER, isNativeFileChooser());
    prefs.putInt(PREF_GRAPHIC_FRAME_RATE, getFrameRate());
    prefs.putInt(PREF_GRAPHIC_CAMERA_ANGLE, getCameraAngle());
    prefs.putBoolean(PREF_EDITING_AUTO_TANGENT_GENERATING, isAutoTangentGenerating());
    prefs.putBoolean(PREF_EDITING_DEFAULT_USE_FLIPPED_TEXTURE, isDefaultUseFlippedTexture());
    prefs.putBoolean(PREF_EDITING_CAMERA_LAMP_ENABLED, isDefaultEditorCameraEnabled());
    prefs.putBoolean(PREF_OTHER_ANALYTICS_QUESTION, isAnalyticsQuestion());
    prefs.putInt(PREF_OTHER_THEME, getTheme().ordinal());
    prefs.putInt(PREF_GRAPHIC_OPEN_GL, getOpenGLVersion().ordinal());

    final Vector3f whitePoint = getToneMapFilterWhitePoint();

    prefs.put(PREF_GRAPHIC_TONEMAP_FILTER_WHITE_POINT, whitePoint.getX() + "," + whitePoint.getY() + "," + whitePoint.getZ());

    if (currentAsset != null && !Files.exists(currentAsset)) {
        currentAsset = null;
    }

    if (librariesPath != null && !Files.exists(librariesPath)) {
        librariesPath = null;
    }

    if (currentAsset != null) {
        prefs.put(PREF_ASSET_CURRENT_ASSET, currentAsset.toUri().toString());
    } else {
        prefs.remove(PREF_ASSET_CURRENT_ASSET);
    }

    if (librariesPath != null) {
        prefs.put(PREF_OTHER_LIBRARIES_FOLDER, librariesPath.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_LIBRARIES_FOLDER);
    }

    if (classesPath != null) {
        prefs.put(PREF_OTHER_CLASSES_FOLDER, classesPath.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_CLASSES_FOLDER);
    }

    if (additionalEnvs != null) {
        prefs.put(PREF_OTHER_ADDITIONAL_ENVS, additionalEnvs.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_ADDITIONAL_ENVS);
    }

    final List<String> lastOpenedAssets = getLastOpenedAssets();

    prefs.putByteArray(PREF_ASSET_LAST_OPENED_ASSETS, EditorUtil.serialize((Serializable) lastOpenedAssets));
    try {
        prefs.flush();
    } catch (final BackingStoreException e) {
        throw new RuntimeException(e);
    }

    System.setProperty("jfx.frame.transfer.camera.angle", String.valueOf(getCameraAngle()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:78,代碼來源:EditorConfig.java

示例15: setReplaceLiteralsWithUnderscores

import java.util.prefs.Preferences; //導入方法依賴的package包/類
static void setReplaceLiteralsWithUnderscores(Preferences prefs, boolean value) {
    prefs.putBoolean(KEY_ALSO_WITH_UNDERSCORES, value);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:AddUnderscores.java


注:本文中的java.util.prefs.Preferences.putBoolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。