本文整理匯總了Java中java.util.prefs.Preferences.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.get方法的具體用法?Java Preferences.get怎麽用?Java Preferences.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAndShow
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void createAndShow() throws Exception{
Preferences Config = TEdit.getConfig();
JTextArea area = new JTextArea(10,40);
area.setEditable(false);
String Font_Name = Config.get("FONT_NAME","Monospaced");
int Font_Size = Config.getInt("FONT_SIZE",12);
int Font_Style = Config.getInt("FONT_STYLE",Font.PLAIN);
area.setFont(new Font(Font_Name,Font_Style,Font_Size));
JScrollPane scroll = new JScrollPane(area,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
this.add(scroll,BorderLayout.CENTER);
if(txt == null){
BufferedReader br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("org/ioblako/edit/resources/Help.txt"), "UTF-8"));
for (int c = br.read(); c != -1; c = br.read()) sb.append((char)c);
txt=sb.toString();
}
area.setText(txt);
this.setTitle("Help");
this.pack();
this.setVisible(true);
}
示例2: getPreferredUIClass
import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
* Checks Preferences for look and feel class name that user selected in Options window.
* @return Look and feel class selected in Options window or null.
*/
private static Class getPreferredUIClass() {
Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N
String uiClassName = prefs.get( "laf", null ); //NOI18N
if( null == uiClassName )
return null;
ClassLoader loader = Lookup.getDefault().lookup( ClassLoader.class );
if( null == loader )
loader = ClassLoader.getSystemClassLoader();
try {
Class uiClass = loader.loadClass( uiClassName );
return uiClass;
} catch( ClassNotFoundException ex ) {
//HACK ModuleInstall.uninstalled() is never called so let's check if Dark Themes module has been uninstalled
if( prefs.getBoolean( "dark.themes.installed", false) ) {
prefs.remove( "laf" ); //NOI18N
prefs.remove( "dark.themes.installed" ); //NOI18N
} else {
Logger.getLogger( CoreBridgeImpl.class.getName() ).log( Level.INFO, "Cannot use look and feel class: " + uiClassName, ex ); //NOI18N
}
}
return null;
}
示例3: arePrefsChanged
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private boolean arePrefsChanged(String mimeType) {
boolean isChanged = false;
Preferences prefs = pf.getPreferences(mimeType);
Preferences savedPrefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
HashSet<String> hashSet = new HashSet<String>();
try {
hashSet.addAll(Arrays.asList(prefs.keys()));
hashSet.addAll(Arrays.asList(savedPrefs.keys()));
} catch (BackingStoreException ex) {
return false;
}
for (String key : hashSet) {
String current = prefs.get(key, null);
String saved = savedPrefs.get(key, null);
if (saved == null) {
saved = selector.getSavedValue(mimeType, key);
}
isChanged |= current == null ? saved != null : !current.equals(saved);
if (isChanged) { // no need to iterate further
return true;
}
}
return isChanged;
}
示例4: arePrefsChanged
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private boolean arePrefsChanged(String mimeType, PreferencesCustomizer c) {
boolean isChanged = false;
Preferences prefs = selector.getCustomizerPreferences(c);
Preferences savedPrefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
HashSet<String> hashSet = new HashSet<String>();
try {
hashSet.addAll(Arrays.asList(prefs.keys()));
hashSet.addAll(Arrays.asList(savedPrefs.keys()));
} catch (BackingStoreException ex) {
return false;
}
for (String key : hashSet) {
if (key.equals(FormattingPanelController.OVERRIDE_GLOBAL_FORMATTING_OPTIONS)) {
continue;
}
isChanged |= (prefs.get(key, null) == null ? savedPrefs.get(key, null) != null : !prefs.get(key, null).equals(savedPrefs.get(key, null)))
|| (prefs.get(key, null) == null ? savedPrefs.get(key, null) != null : !prefs.get(key, null).equals(savedPrefs.get(key, null)));
}
return isChanged;
}
示例5: loadListData
import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Override
protected void loadListData(JList list, String optionID, Preferences node) {
DefaultListModel model = new DefaultListModel();
String value = node.get(optionID, getDefaultAsString(optionID));
for (String s : value.trim().split("\\s*[,;]\\s*")) { //NOI18N
if (classMembersOrder.equals(optionID)) {
Element e = new Element();
if (s.startsWith("STATIC ")) { //NOI18N
e.isStatic = true;
s = s.substring(7);
}
e.kind = ElementKind.valueOf(s);
model.addElement(e);
} else {
Visibility v = new Visibility();
v.kind = s;
model.addElement(v);
}
}
list.setModel(model);
}
示例6: getSpi
import java.util.prefs.Preferences; //導入方法依賴的package包/類
protected @Override String getSpi(String key) {
String bareKey;
boolean returnValue;
if (key.startsWith(JAVATYPE_KEY_PREFIX)) {
bareKey = key.substring(JAVATYPE_KEY_PREFIX.length());
returnValue = false;
} else {
bareKey = key;
returnValue = true;
}
if (getLocal().containsKey(bareKey)) {
TypedValue typedValue = getLocal().get(bareKey);
return returnValue ? typedValue.getValue() : typedValue.getJavaType();
} else {
Preferences inheritedPrefs = getInherited();
return inheritedPrefs != null ? inheritedPrefs.get(key, null) : null;
}
}
示例7: removeFromPreferences
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void removeFromPreferences(ProjectInfo selectedItem) {
Preferences p = Preferences.userNodeForPackage(this.getClass());
String[] keys;
try {
keys = p.keys();
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
String fName = p.get(key, null);
if (fName.equals(selectedItem.getFolder())) {
p.remove(key);
break;
}
}
} catch (BackingStoreException e) {
return;
}
}
示例8: init
import java.util.prefs.Preferences; //導入方法依賴的package包/類
protected void init(){
Preferences prefs = this.getPreferences();
String flagString = prefs.get(PROP_FLAGS, CfgPreferencesDefaults.DEFAULT_FLAGSTRING);
flagsSetting = new FlagsSetting(flagString);
node_color = this.getColorProperty(PROP_NODE_COLOR, CfgPreferencesDefaults.DEFAUT_NODE_COLOR);
background_color = this.getColorProperty(PROP_BACKGROUND_COLOR, CfgPreferencesDefaults.DEFAULT_BACKGROUND_COLOR);
backedge_color = this.getColorProperty(PROP_BACK_EDGE_COLOR, CfgPreferencesDefaults.DEFAULT_BACKEDGE_COLOR);
edge_color = this.getColorProperty(PROP_EDGE_COLOR, CfgPreferencesDefaults.DEFAULT_EDGE_COLOR);
selection_color_fg= this.getColorProperty(PROP_SELECTION_COLOR_FG, CfgPreferencesDefaults.DEFAULT_SELECTION_COLOR_FOREGROUND);
border_color = this.getColorProperty(PROP_BORDER_COLOR, CfgPreferencesDefaults.DEFAULT_BORDER_COLOR);
exceptionEdgeColor = this.getColorProperty(PROP_EXCEPTION_EDGE_COLOR, CfgPreferencesDefaults.DEFAULT_EXCEPTIONEDGE_COLOR);
text_color= this.getColorProperty(PROP_TEXT_COLOR, CfgPreferencesDefaults.DEFAULT_TEXT_COLOR);
selection_color_bg = this.getColorProperty(PROP_SELECTION_COLOR_BG, CfgPreferencesDefaults.DEFAULT_SELECTION_COLOR_BACKGROUND);
selection_color_fg = this.getColorProperty(PROP_SELECTION_COLOR_FG, CfgPreferencesDefaults.DEFAULT_SELECTION_COLOR_FOREGROUND);
text_font = this.getFontProperty(PROP_TEXT_FONT, CfgPreferencesDefaults.DEFAULT_TEXT_FONT);
}
示例9: restoreRecentConnectionsList
import java.util.prefs.Preferences; //導入方法依賴的package包/類
void restoreRecentConnectionsList() {
Preferences prefs = NbPreferences.forModule(ConnectionManager.class);
synchronized (recentConnections) {
recentConnections.clear();
int idx = 0;
while (true) {
String id = prefs.get(getConnectoinsHistoryKey(idx), null);
if (id == null) {
break;
}
recentConnections.add(ExecutionEnvironmentFactory.fromUniqueID(id));
idx++;
}
}
}
示例10: ProfileProvider
import java.util.prefs.Preferences; //導入方法依賴的package包/類
ProfileProvider (@NonNull Context ctx) {
final Preferences prefs = ctx.getSettings();
final String profileName = prefs == null ?
null :
prefs.get(ProfilesCustomizerProvider.PROP_PROFILE_TO_CHECK, null);
profile = profileName == null ?
null :
SourceLevelQuery.Profile.forName(profileName);
}
示例11: init
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void init() {
Preferences prefs = NbPreferences.forModule(this.getClass());
try {
for (String kid:prefs.childrenNames()) {
if (kid.startsWith(RULE_PREFIX)) {
Preferences p = NbPreferences.forModule(this.getClass()).node(kid);
String displayName = p.get("display.name", "unknown");
create(kid.substring(RULE_PREFIX.length()), displayName);
}
}
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
int configurationsVersion = prefs.getInt(KEY_CONFIGURATIONS_VERSION, 0);
if (configs.isEmpty()) {
create("default", NbBundle.getMessage(ConfigurationsManager.class, "DN_Default"));
Configuration jdk7 = create("jdk7", NbBundle.getMessage(ConfigurationsManager.class, "DN_ConvertToJDK7"));
jdk7.enable("Javac_canUseDiamond");
jdk7.enable("org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch");
jdk7.enable("org.netbeans.modules.java.hints.jdk.ConvertToARM");
jdk7.enable("org.netbeans.modules.java.hints.jdk.JoinCatches");
// #215546 - requires user inspection
// jdk7.enable("org.netbeans.modules.java.hints.jdk.UseSpecificCatch");
//jdk7.enable("java.util.Objects");
}
if (configurationsVersion < 1 && !configurationExists("organizeImports")) {
Configuration organizeImports = create("organizeImports", NbBundle.getMessage(ConfigurationsManager.class, "DN_OrganizeImports"));
organizeImports.enable("org.netbeans.modules.java.hints.OrganizeImports");
}
prefs.putInt(KEY_CONFIGURATIONS_VERSION, CURRENT_CONFIGURATIONS_VERSION);
}
示例12: getIndentEngine
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public static final IndentEngine getIndentEngine(MimePath mimePath) {
IndentEngine eng = null;
Preferences prefs = MimeLookup.getLookup(mimePath).lookup(Preferences.class);
String handle = prefs.get(NbEditorDocument.INDENT_ENGINE, null);
if (handle != null && handle.indexOf('.') == -1) { //NOI18N
// looks like Lookup handle from previous version
Lookup.Template<IndentEngine> query = new Lookup.Template(IndentEngine.class, handle, null);
Collection<? extends IndentEngine> all = Lookup.getDefault().lookup(query).allInstances();
if (!all.isEmpty()) {
eng = all.iterator().next();
}
} else {
eng = (IndentEngine) SettingsConversions.callFactory(prefs, mimePath, NbEditorDocument.INDENT_ENGINE, null);
}
if (eng == null) {
EditorKit kit = MimeLookup.getLookup(mimePath).lookup(EditorKit.class);
Object legacyFormatter = null;
if (kit != null) {
try {
Method createFormatterMethod = kit.getClass().getDeclaredMethod("createFormatter"); //NOI18N
legacyFormatter = createFormatterMethod.invoke(kit);
} catch (Exception e) {
}
}
if (legacyFormatter == null) {
eng = new DefaultIndentEngine();
}
}
return eng;
}
示例13: getOnExpandAction
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public OnExpandAction getOnExpandAction() {
Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
String action = prefs.get(CODE_TEMPLATE_ON_EXPAND_ACTION, null);
if (action != null) {
return OnExpandAction.valueOf(action);
}
return OnExpandAction.FORMAT;
}
示例14: createFromUserPreferences
import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
* Charge les paramètres depuis les préférences utilisateur.
* @return Parameters
* @throws BackingStoreException e
*/
public static Parameters createFromUserPreferences() throws BackingStoreException {
final Properties properties = new Properties();
final Preferences prefs = Preferences.userNodeForPackage(Parameters.class);
for (final String key : prefs.keys()) {
final String value = prefs.get(key, null);
if (value != null && !value.isEmpty()) {
properties.put(key, value);
}
}
return new Parameters(properties);
}
示例15: start
import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Override
public void start(final Stage primaryStage) throws Exception
{
primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.getIcons().add(new Image("/com/matthieu42/steamtradertools/bundles/images/Icon_STTBluepng.png"));
Preferences prefs = Preferences.userNodeForPackage(com.matthieu42.steamtradertools.model.Main.class);
String language = prefs.get(PreferencesKeys.LANGUAGE.toString(),Locale.ENGLISH.getDisplayLanguage());
Locale locale;
if(language.equals(Locale.FRENCH.getDisplayLanguage()))
{
locale = Locale.FRENCH;
}
else
locale = Locale.ENGLISH;
I18n.setLocale(locale);
I18n.setBundle("com/matthieu42/steamtradertools/bundles/lang",locale);
final AllAppList allAppList = new AllAppList();
final UserAppList userAppList = new UserAppList();
File steamAppList = new File("steamAppList.xml");
if (!steamAppList.exists())
{
FXMLLoader splashLoader = new FXMLLoader(getClass().getResource("/com/matthieu42/steamtradertools/view/loadview.fxml"),I18n.getResourceBundle());
AnchorPane pane = splashLoader.load();
primaryStage.setScene(new Scene(pane));
primaryStage.show();
Task<Void> syncApp = allAppList.init();
syncApp.setOnSucceeded(t ->
{
allAppList.saveToXml();
continueLaunch(allAppList,userAppList,primaryStage);
});
syncApp.setOnFailed(t ->
{
return;
});
new Thread(syncApp).start();
} else
{
allAppList.loadFromXml();
continueLaunch(allAppList,userAppList,primaryStage);
}
}