本文整理匯總了Java中java.util.prefs.PreferenceChangeEvent.getNewValue方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceChangeEvent.getNewValue方法的具體用法?Java PreferenceChangeEvent.getNewValue怎麽用?Java PreferenceChangeEvent.getNewValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.prefs.PreferenceChangeEvent
的用法示例。
在下文中一共展示了PreferenceChangeEvent.getNewValue方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(final PreferenceChangeEvent e) {
if (e.getKey().toLowerCase().contains("imu")) {
davisChip.getLog().info(this + " preferenceChange(): event=" + e + " key=" + e.getKey() + " newValue=" + e.getNewValue());
}
if (e.getNewValue() == null) {
return;
}
try {
if (e.getKey().contains("IMU.AccelScale")) {
setAccelScale(ImuAccelScale.valueOf(e.getNewValue()));
}
else if (e.getKey().contains("IMU.GyroScale")) {
setGyroScale(ImuGyroScale.valueOf(e.getNewValue()));
}
else if (e.getKey().contains("IMU.displayEnabled")) {
setDisplayImu(Boolean.valueOf(e.getNewValue()));
}
}
catch (final IllegalArgumentException iae) {
davisChip.getLog().warning(iae.toString() + ": Preference value=" + e.getNewValue() + " for the preferenc with key="
+ e.getKey() + " is not a proper enum for an IMU setting");
}
}
示例2: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
// potential NPE fix; key ought not be null, but guard against it.
if (evt.getKey() == null) {
return;
}
ignorePut.set(true);
String k = evt.getKey();
String v = evt.getNewValue();
try {
if (evt.getSource() == stored) {
// not important, obnly local storage should refire, except clearing of the local value
if (!isOverriden(k) && v != null) {
return;
}
// try to recover the inherited value
if (v == null) {
v = inherited.get(k, null);
}
} else if (isOverriden(k)) {
return;
}
// potential NPE, null values should be reported as removals.
if (v == null) {
remove(k);
} else {
put(k, v);
}
} finally {
ignorePut.set(false);
}
}
示例3: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
changeCount++;
this.key = evt.getKey();
this.value = evt.getNewValue();
latch.countDown();
}
示例4: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(final PreferenceChangeEvent e) {
// TODO we get pref change events here but by this time the new values have already been set and there is no
// change in value so the GUI elements are not updated
try {
final String base = prefsKey() + TowerOnChip6BitVDAC.SEP;
final String key = e.getKey();
if (!key.startsWith(base)) {
return;
}
final String val = e.getNewValue();
// log.info("key="+key+" value="+val);
if (key.equals(base + TowerOnChip6BitVDAC.KEY_VDAC_VALUE)) {
if (getVdacBitValue() != Integer.parseInt(val)) {
Pot.log.info("reference voltage bit value change from preferences");
}
setVdacBitValue(Integer.parseInt(val));
}
else if (key.equals(base + TowerOnChip6BitVDAC.KEY_BUFFER_VALUE)) {
if (getBufferBitValue() != Integer.parseInt(val)) {
Pot.log.info("regulator bit value changed from preferences");
}
setBufferBitValue(Integer.parseInt(val));
}
}
catch (final Exception ex) {
Pot.log.warning("while responding to preference change event " + e + ", caught " + ex.toString());
}
}
示例5: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(PreferenceChangeEvent e) {
// TODO we get pref change events here but by this time the new values have already been set and there is no change in value so the GUI elements are not updated
try {
String base = prefsKey() + SEP;
String key = e.getKey();
if(!key.startsWith(base)) {
return;
}
String val = e.getNewValue();
// log.info("key="+key+" value="+val);
if (key.equals(base + KEY_BITVALUE_FINE)) {
if(getFineBitValue()!=Integer.parseInt(val)){
log.info(base+" fine bit value change from "+getFineBitValue()+" to "+ Integer.parseInt(val)+" from preferences");
}
setFineBitValue(Integer.parseInt(val));
} else if (key.equals(base + KEY_BITVALUE_COARSE)) {
if(getCoarseBitValue()!=Integer.parseInt(val)){
log.info("coarse bit value change from preferences");
}
setCoarseBitValue(Integer.parseInt(val));
} else if (key.equals(base + KEY_ENABLED)) {
setEnabled(Boolean.parseBoolean(val));
} else if (key.equals(base + KEY_LOWCURRENT_ENABLED)) {
setLowCurrentModeEnabled(Boolean.parseBoolean(val));
} else if (key.equals(base + KEY_SEX)) {
setSex(Pot.Sex.valueOf(val));
} else if (key.equals(base + KEY_TYPE)) {
setType(Pot.Type.valueOf(val));
}
} catch (Exception ex) {
log.warning("while responding to preference change event " + e + ", caught " + ex.toString());
}
}
示例6: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(PreferenceChangeEvent e) {
// TODO we get pref change events here but by this time the new values have already been set and there is no change in value so the GUI elements are not updated
try {
String base = prefsKey() + SEP;
String key = e.getKey();
if (!key.startsWith(base)) {
return;
}
String val = e.getNewValue();
// log.info("key="+key+" value="+val);
if (key.equals(base + KEY_REFVALUE)) {
if (getRefBitValue()!= Integer.parseInt(val)) {
log.info("reference voltage bit value change from preferences");
}
setRefBitValue(Integer.parseInt(val));
} else if (key.equals(base + KEY_REGVALUE)) {
if (getRegBitValue()!= Integer.parseInt(val)) {
log.info("regulator bit value changed from preferences");
}
setRegBitValue(Integer.parseInt(val));
} else if (key.equals(base + KEY_OPERATINGMODE)) {
setOperatingMode(OperatingMode.valueOf(val));
} else if (key.equals(base + KEY_VOLTAGELEVEL)) {
setVoltageLevel(VoltageLevel.valueOf(val));
}
} catch (Exception ex) {
log.warning("while responding to preference change event " + e + ", caught " + ex.toString());
}
}
示例7: preferenceChange
import java.util.prefs.PreferenceChangeEvent; //導入方法依賴的package包/類
@Override
public void preferenceChange(PreferenceChangeEvent e) {
// TODO we get pref change events here but by this time the new values have already been set and there is no change in value so the GUI elements are not updated
try {
String base = prefsKey() + SEP;
String key = e.getKey();
if(!key.startsWith(base)) return;
String val = e.getNewValue();
// log.info("key="+key+" value="+val);
if (key.equals(base + KEY_BITVALUE)) {
if(getBitValue()!=Integer.parseInt(val)){
log.info("bit value change from preferences");
}
setBitValue(Integer.parseInt(val));
} else if (key.equals(base + KEY_BUFFER_BITVALUE)) {
setBufferBitValue(Integer.parseInt(val));
} else if (key.equals(base + KEY_ENABLED)) {
setEnabled(Boolean.parseBoolean(val));
} else if (key.equals(base + KEY_LOWCURRENT_ENABLED)) {
setLowCurrentModeEnabled(Boolean.parseBoolean(val));
} else if (key.equals(base + KEY_SEX)) {
setSex(Pot.Sex.valueOf(val));
} else if (key.equals(base + KEY_TYPE)) {
setType(Pot.Type.valueOf(val));
}
} catch (Exception ex) {
log.warning("while responding to preference change event " + e + ", caught " + ex.toString());
}
}