本文整理匯總了Java中java.lang.reflect.Field.setBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java Field.setBoolean方法的具體用法?Java Field.setBoolean怎麽用?Java Field.setBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.reflect.Field
的用法示例。
在下文中一共展示了Field.setBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copyPrivateDataInto
import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
* Copies all private data from this event into that.
* Space is allocated for the copied data that will be
* freed when the that is finalized. Upon completion,
* this event is not changed.
*/
void copyPrivateDataInto(AWTEvent that) {
that.bdata = this.bdata;
// Copy canAccessSystemClipboard value from this into that.
if (this instanceof InputEvent && that instanceof InputEvent) {
Field field = get_InputEvent_CanAccessSystemClipboard();
if (field != null) {
try {
boolean b = field.getBoolean(this);
field.setBoolean(that, b);
} catch(IllegalAccessException e) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e);
}
}
}
}
that.isSystemGenerated = this.isSystemGenerated;
}
示例2: onCreate
import java.lang.reflect.Field; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
actionBar = getSupportActionBar();
// Hack. Forcing overflow button on actionbar on devices with hardware menu button
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {
// Ignore
}
}
示例3: setValue
import java.lang.reflect.Field; //導入方法依賴的package包/類
public void setValue(boolean value) {
this.value = value;
Field[] arrfield = this.mod.getClass().getDeclaredFields();
int n = arrfield.length;
int n2 = 0;
while (n2 < n) {
Field field = arrfield[n2];
field.setAccessible(true);
if (field.isAnnotationPresent(Op.class) && field.getName().equalsIgnoreCase(this.name)) {
try {
field.setBoolean(this.mod, value);
}
catch (Exception e) {
e.printStackTrace();
}
}
++n2;
}
if (Gui.instance != null) {
Gui.instance.reloadOptions();
}
OptionManager.save();
}
示例4: setValueHard
import java.lang.reflect.Field; //導入方法依賴的package包/類
public void setValueHard(boolean value) {
this.value = value;
Field[] arrfield = this.mod.getClass().getDeclaredFields();
int n = arrfield.length;
int n2 = 0;
while (n2 < n) {
Field field = arrfield[n2];
field.setAccessible(true);
if (field.isAnnotationPresent(Op.class) && field.getName().equalsIgnoreCase(this.name)) {
try {
field.setBoolean(this.mod, value);
}
catch (Exception e) {
e.printStackTrace();
}
}
++n2;
}
if (Gui.instance != null) {
Gui.instance.reloadOptions();
}
OptionManager.save();
}
示例5: NametagEntity
import java.lang.reflect.Field; //導入方法依賴的package包/類
public NametagEntity(final Player player)
{
super(((CraftWorld)player.getWorld()).getHandle());
final Location location = player.getLocation();
this.setInvisible(true);
this.setPosition(location.getX(), location.getY(), location.getZ());
try {
final Field invulnerable = Entity.class.getDeclaredField("invulnerable");
invulnerable.setAccessible(true);
invulnerable.setBoolean(this, true);
}
catch (Exception e) {
e.printStackTrace();
}
this.world.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
this.persistent = true;
this.hideTag(player);
}
示例6: disableShiftMode
import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
* 取消BottomNavigationView各item切換時的位移動效
*
* @param navigationView 底部導航欄視圖
*/
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例7: dispatched
import java.lang.reflect.Field; //導入方法依賴的package包/類
void dispatched() {
if (this instanceof InputEvent) {
Field field = get_InputEvent_CanAccessSystemClipboard();
if (field != null) {
try {
field.setBoolean(this, false);
} catch(IllegalAccessException e) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("AWTEvent.dispatched() got IllegalAccessException ", e);
}
}
}
}
}
示例8: forceShowOverflowMenu
import java.lang.reflect.Field; //導入方法依賴的package包/類
public static void forceShowOverflowMenu(Context context) {
try {
ViewConfiguration config = ViewConfiguration.get(context);
Field menuKeyField = ViewConfiguration.class.
getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: hookLayoutInflater
import java.lang.reflect.Field; //導入方法依賴的package包/類
private void hookLayoutInflater(Context context) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
try {
Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
field.setAccessible(true);
field.setBoolean(layoutInflater, false);
LayoutInflaterCompat.setFactory2(layoutInflater, AndroidSkinFactory.from(context,layoutInflater));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例10: onCreate
import java.lang.reflect.Field; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
// force to sow the overflow menu icon
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {
// Ignore
}
}
示例11: installLayoutFactory
import java.lang.reflect.Field; //導入方法依賴的package包/類
private void installLayoutFactory(Context context) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
try {
Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
field.setAccessible(true);
field.setBoolean(layoutInflater, false);
LayoutInflaterCompat.setFactory(layoutInflater, getSkinDelegate(context));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例12: maybeDisableExportControls
import java.lang.reflect.Field; //導入方法依賴的package包/類
public static void maybeDisableExportControls() {
// This sorry story is documented in https://bugs.openjdk.java.net/browse/JDK-7024850
// Oracle received permission to ship AES-256 by default in 2011, but didn't get around to it for Java 8
// even though that shipped in 2014! That's dumb. So we disable the ridiculous US government mandated DRM
// for AES-256 here, as Tor/BIP38 requires it.
if (done) return;
done = true;
if (Utils.isAndroidRuntime())
return;
try {
Field gate = Class.forName("javax.crypto.JceSecurity").getDeclaredField("isRestricted");
gate.setAccessible(true);
gate.setBoolean(null, false);
final Field allPerm = Class.forName("javax.crypto.CryptoAllPermission").getDeclaredField("INSTANCE");
allPerm.setAccessible(true);
Object accessAllAreasCard = allPerm.get(null);
final Constructor<?> constructor = Class.forName("javax.crypto.CryptoPermissions").getDeclaredConstructor();
constructor.setAccessible(true);
Object coll = constructor.newInstance();
Method addPerm = Class.forName("javax.crypto.CryptoPermissions").getDeclaredMethod("add", java.security.Permission.class);
addPerm.setAccessible(true);
addPerm.invoke(coll, accessAllAreasCard);
Field defaultPolicy = Class.forName("javax.crypto.JceSecurity").getDeclaredField("defaultPolicy");
defaultPolicy.setAccessible(true);
defaultPolicy.set(null, coll);
} catch (Exception e) {
log.warn("Failed to deactivate AES-256 barrier logic, Tor mode/BIP38 decryption may crash if this JVM requires it: " + e.getMessage());
}
}
示例13: setAutomaticRefreshEnabled
import java.lang.reflect.Field; //導入方法依賴的package包/類
private void setAutomaticRefreshEnabled (boolean flag) throws Exception {
Field f = FilesystemInterceptor.class.getDeclaredField("AUTOMATIC_REFRESH_ENABLED");
f.setAccessible(true);
f.setBoolean(FilesystemInterceptor.class, flag);
assert ((Boolean) f.get(FilesystemInterceptor.class)).equals(flag);
}
示例14: testFix217212_ActivatePanel
import java.lang.reflect.Field; //導入方法依賴的package包/類
public void testFix217212_ActivatePanel() throws Exception {
InstanceContent ic = new InstanceContent();
GlobalLookup4TestImpl nodesLkp = new GlobalLookup4TestImpl(ic);
UnitTestUtils.prepareTest(new String[]{
"/META-INF/generated-layer.xml"},
Lookups.singleton(nodesLkp));
TestLookupHint hint = new TestLookupHint("annotation/tester");
ic.add(hint);
final NavigatorTC navTC = NavigatorTC.getInstance();
Field field = NavigatorController.class.getDeclaredField("updateWhenNotShown");
field.setAccessible(true);
field.setBoolean(navTC.getController(), true);
try {
Mutex.EVENT.readAccess(new Mutex.ExceptionAction() {
@Override
public Object run() throws Exception {
navTC.getController().propertyChange(
new PropertyChangeEvent(navTC, TopComponent.Registry.PROP_TC_OPENED, null, navTC));
return null;
}
});
waitForProviders(navTC);
NavigatorPanel selPanel = navTC.getSelectedPanel();
assertNotNull("Selected panel is null", selPanel);
List<? extends NavigatorPanel> panels = navTC.getPanels();
assertEquals(2, panels.size());
NavigatorPanel lazyPanel1 = panels.get(0);
Method method = LazyPanel.class.getDeclaredMethod("initialize");
method.setAccessible(true);
NavigatorPanel delegate1 = (NavigatorPanel) method.invoke(lazyPanel1);
NavigatorPanel lazyPanel2 = panels.get(1);
method = LazyPanel.class.getDeclaredMethod("initialize");
method.setAccessible(true);
NavigatorPanel delegate2 = (NavigatorPanel) method.invoke(lazyPanel2);
System.out.println("selected panel before: " + selPanel.getDisplayName());
//find not-selected panel
final NavigatorPanel toActivate;
final NavigatorPanel toActivateLazy;
if (selPanel.equals(lazyPanel1)) {
toActivate = delegate2;
toActivateLazy = lazyPanel2;
} else {
toActivate = delegate1;
toActivateLazy = lazyPanel1;
}
Mutex.EVENT.readAccess(new Mutex.ExceptionAction() {
@Override
public Object run() throws Exception {
NavigatorHandler.activatePanel(toActivate);
return null;
}
});
assertTrue(selPanel != navTC.getSelectedPanel());
assertTrue(toActivateLazy == navTC.getSelectedPanel());
System.out.println("selected panel after: " + navTC.getSelectedPanel().getDisplayName());
} finally {
navTC.getController().propertyChange(
new PropertyChangeEvent(navTC, TopComponent.Registry.PROP_TC_CLOSED, null, navTC));
}
}
示例15: toggleEnabled
import java.lang.reflect.Field; //導入方法依賴的package包/類
private void toggleEnabled(String fieldName, boolean value) throws NoSuchFieldException, IllegalAccessException {
Field cthField = null;
cthField = TextInputLayout.class.getDeclaredField(fieldName);
cthField.setAccessible(true);
cthField.setBoolean(this, value);
}