当前位置: 首页>>代码示例>>Java>>正文


Java CheckBox.addListener方法代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.CheckBox.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBox.addListener方法的具体用法?Java CheckBox.addListener怎么用?Java CheckBox.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.scenes.scene2d.ui.CheckBox的用法示例。


在下文中一共展示了CheckBox.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: a

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
private void a(Skin paramSkin, c[] paramArrayOfc)
{
  int i = paramArrayOfc.length;
  for (int j = 0; j < i; j++)
  {
    c localc = paramArrayOfc[j];
    CheckBox localCheckBox = new CheckBox(localc.c, paramSkin);
    localCheckBox.setChecked(localc.d);
    localCheckBox.addListener(new b(this, localc, localCheckBox));
    localCheckBox.left();
    ((com.a.a.c)localCheckBox.getCells().get(0)).j();
    add(localCheckBox).a(Float.valueOf(0.85F), Float.valueOf(0.0F)).o().m().j(8.0F);
    this.a.put(Integer.valueOf(localc.a), localCheckBox);
    row();
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:17,代码来源:a.java

示例2: AContinentForm

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
public AContinentForm(Skin skin, AbstractSampler sampler, Samplers pool) {
	super(skin, sampler, pool);

	inputTable = new InputTable(skin);
	inputTable.setBackground(Styles.INNER_BACKGROUND);
	inputTable.addEntry(NAME_ITERATIONS, 60);
	inputTable.addEntry(NAME_GROWTH, 60);
	inputTable.addEntry(NAME_SIZE, 60);
	inputTable.addEntry(NAME_EDGE, 60);

	inputTable.setEntryValueListener(new InputTable.EntryValueListener() {
		@Override
		public void onChange(String entryName, String entryValue) {
			notifyChanges();
		}
	});

	add(inputTable);

	row();
	cbSmoothEdge = new CheckBox("Smooth edge", skin);
	cbSmoothEdge.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			notifyChanges();
		}
	});
	add(cbSmoothEdge);
}
 
开发者ID:aphex-,项目名称:Opus-Prototype,代码行数:30,代码来源:AContinentForm.java

示例3: createStaticMenu

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
private void createStaticMenu() {
	Table container = new Table();
	container.setFillParent(true);
	container.top();
	stage.addActor(container);

	Label title = new Label("Configuration", uiSkin, "title");
	Label musicLabel = new Label("Musique :", uiSkin);
	
	CheckBox musicCheckBox = new CheckBox("", uiSkin);
	musicCheckBox.setChecked(GlobalConfiguration.musicOn);
	musicCheckBox.addListener(new MusicCheckBoxListener());
	
	Label seedLabel = new Label("Seed :", uiSkin);
	String configuredSeed = (GlobalConfiguration.configuredSeed == null) ? null : ""+GlobalConfiguration.configuredSeed;
	TextField seedField = new TextField(configuredSeed, uiSkin);
	TextButton saveButton = new TextButton("Sauvegarder", uiSkin);
	saveButton.addListener(new SaveConfigListener(seedField, stage));
	
	Label returnLabel = new Label("Menu", uiSkin);
	returnLabel.addListener(new ButtonRedirectListener(game, new MainMenuScreen(game)));
	
	Table actorContainer = new Table();
	actorContainer.add(musicLabel);
	actorContainer.add(musicCheckBox);
	actorContainer.row().padTop(10);
	actorContainer.add(seedLabel).padRight(10);
	actorContainer.add(seedField);
	actorContainer.row().padTop(10);
	actorContainer.add(saveButton).colspan(2);
	
	container.add(title).padTop(10);
	container.row();
	container.add(actorContainer).expand();
	container.row();
	container.add(returnLabel).bottom().left().pad(10);
}
 
开发者ID:gcleenew,项目名称:RottenCave,代码行数:38,代码来源:ConfigurationScreen.java

示例4: GameSelectionDialog

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
public GameSelectionDialog(String title, Game game, Skin skin) {
	super(title, skin);
	
	this.game = game;
	
	TextButton enterGameButton = new TextButton("Start", skin);
	Label nameLabel = new Label("Dein Name", skin);
	Label passwordLabel = new Label("Passwort", skin);
	nameText = new TextFieldActor("", skin);
	passwordText = new TextFieldActor("", skin);
	CheckBox showPasswordCheckBox = new CheckBox("Passwort anzeigen", skin);
	showPasswordCheckBox.right();
	
	getButtonTable().defaults().width(175).height(100);
	
	getContentTable().padTop(40);
	getContentTable().add(nameLabel).center().row();
	getContentTable().add(nameText).width(200).center().row();
	getContentTable().add(passwordLabel).center().row();
	getContentTable().add(passwordText).width(200).center().row();
	getContentTable().add(showPasswordCheckBox).center().colspan(2).center();
	getButtonTable().padTop(30);
	button(enterGameButton, "Start");
	
	passwordText.setPasswordCharacter('*');
	passwordText.setPasswordMode(true);
	showPasswordCheckBox.setChecked(false);
	
	showPasswordCheckBox.addListener(new ChangeListener() {
		public void changed (ChangeEvent event, Actor actor) {
			passwordText.setPasswordMode(!passwordText.isPasswordMode());
		}
	});
}
 
开发者ID:javosuher,项目名称:Terminkalender,代码行数:35,代码来源:GameSelectionDialog.java

示例5: CreateGameDialogActor

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
public CreateGameDialogActor(Skin skin) {
	super("", skin);
	createGameDialog = new CreateGameDialog();
	
	TextButton createGameButton = new TextButton("Create Game", skin, "textButtonLarge");
	Label gameNameLabel = new Label("Game Name", skin);
	Label gamePasswordLabel = new Label("Password", skin);
	Label gamePasswordRepeatLabel = new Label("Repeat password", skin);
	TextField gameNameText = createGameDialog.getGameNameText();
	final TextField gamePasswordText = createGameDialog.getGamePasswordText();
	final TextField gamePasswordRepeatText = createGameDialog.getGamePasswordRepeatText();
	CheckBox showPasswordCheckBox = new CheckBox("  Show Password", skin);
	
	getButtonTable().defaults().width(175).height(100);
	
	getContentTable().padTop(40);
	getContentTable().add(gameNameLabel);
	getContentTable().add(gameNameText).row();
	getContentTable().add(gamePasswordLabel);
	getContentTable().add(gamePasswordText).row();
	getContentTable().add(gamePasswordRepeatLabel);
	getContentTable().add(gamePasswordRepeatText).row();
	getContentTable().add(showPasswordCheckBox).colspan(2).center();
	getButtonTable().padTop(50);
	button(createGameButton, "Register");
	
	gamePasswordText.setPasswordCharacter('*');
	gamePasswordText.setPasswordMode(true);
	gamePasswordRepeatText.setPasswordCharacter('*');
	gamePasswordRepeatText.setPasswordMode(true);
	
	showPasswordCheckBox.addListener(new ChangeListener() {
		public void changed (ChangeEvent event, Actor actor) {
			gamePasswordText.setPasswordMode(!gamePasswordText.isPasswordMode());
			gamePasswordRepeatText.setPasswordMode(!gamePasswordRepeatText.isPasswordMode());
		}
	});
}
 
开发者ID:javosuher,项目名称:Terminkalender,代码行数:39,代码来源:CreateGameDialogActor.java

示例6: TeacherRegisterDialogActor

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
public TeacherRegisterDialogActor(Skin skin) {
	super("", skin);
	teacherRegisterDialog = new TeacherRegisterDialog(); 

	TextButton registerButton = new TextButton("Register", skin, "textButtonLarge");
	Label userLabel = new Label("Username", skin);
	Label passwordLabel = new Label("Password", skin);
	Label passwordRepeatLabel = new Label("Repeat password", skin);
	TextField userText = teacherRegisterDialog.getUserText();
	final TextField passwordText = teacherRegisterDialog.getPasswordText();
	final TextField passwordRepeatText = teacherRegisterDialog.getPasswordRepeatText();
	CheckBox showPasswordCheckBox = new CheckBox("  Show Password", skin);
	
	getButtonTable().defaults().width(175).height(100);
	
	getContentTable().padTop(40);
	getContentTable().add(userLabel);
	getContentTable().add(userText).row();
	getContentTable().add(passwordLabel);
	getContentTable().add(passwordText).row();
	getContentTable().add(passwordRepeatLabel);
	getContentTable().add(passwordRepeatText).row();
	getContentTable().add(showPasswordCheckBox).colspan(2).center();
	getButtonTable().padTop(50);
	button(registerButton, "Register");
	
	passwordText.setPasswordCharacter('*');
	passwordText.setPasswordMode(true);
	passwordRepeatText.setPasswordCharacter('*');
	passwordRepeatText.setPasswordMode(true);
	
	showPasswordCheckBox.addListener(new ChangeListener() {
		public void changed (ChangeEvent event, Actor actor) {
			passwordText.setPasswordMode(!passwordText.isPasswordMode());
			passwordRepeatText.setPasswordMode(!passwordRepeatText.isPasswordMode());
		}
	});
}
 
开发者ID:javosuher,项目名称:Terminkalender,代码行数:39,代码来源:TeacherRegisterDialogActor.java

示例7: TeacherLoginDialogActor

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
public TeacherLoginDialogActor(Skin skin) {
	super("", skin);
	teacherLoginDialog = new TeacherLoginDialog(); 

	TextButton registerButton = new TextButton("Login", skin, "textButtonLarge");
	Label userLabel = new Label("Username", skin);
	Label passwordLabel = new Label("Password", skin);
	TextField userText = teacherLoginDialog.getUserText();
	final TextField passwordText = teacherLoginDialog.getPasswordText();
	CheckBox showPasswordCheckBox = new CheckBox("  Show Password", skin);
	showPasswordCheckBox.right();
	
	getButtonTable().defaults().width(175).height(100);
	
	getContentTable().padTop(40);
	getContentTable().add(userLabel);
	getContentTable().add(userText).row();
	getContentTable().add(passwordLabel);
	getContentTable().add(passwordText).row();
	getContentTable().add(showPasswordCheckBox).colspan(2).center();
	getButtonTable().padTop(50);
	button(registerButton, "Login");
	
	passwordText.setPasswordCharacter('*');
	passwordText.setPasswordMode(true);
	showPasswordCheckBox.setChecked(false);
	
	showPasswordCheckBox.addListener(new ChangeListener() {
		public void changed (ChangeEvent event, Actor actor) {
			passwordText.setPasswordMode(!passwordText.isPasswordMode());
		}
	});
}
 
开发者ID:javosuher,项目名称:Terminkalender,代码行数:34,代码来源:TeacherLoginDialogActor.java

示例8: makeHapticFeedbackCheckbox

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
private CheckBox makeHapticFeedbackCheckbox() {
	final CheckBox checkBox = FontManager.Roboto18.makeCheckBox("Vibrate on touch");
	checkBox.setChecked(VibrateClickListener.isVibrateEnabled());
	checkBox.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			VibrateClickListener.setVibrateEnabled(checkBox.isChecked());
			preferences.putBoolean("vibrateOnTouch", checkBox.isChecked());
			preferences.flush();
		}
	});
	return checkBox;
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:14,代码来源:OptionsDialog.java

示例9: buildControls

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
private void buildControls() {
	boolean unlockedJanitors = AchievementEngine.instance().findById("build5commercialspaces").hasGivenReward();
	boolean unlockedMaids = AchievementEngine.instance().findById("build8hotelroom").hasGivenReward();

	for (final Overlays overlay : Overlays.values()) {
		if (overlay.equals(Overlays.DIRT_LEVEL) && (!unlockedJanitors || !unlockedMaids)) {
			continue;
		}

		final CheckBox checkBox = FontManager.Roboto18.makeCheckBox(overlay.toString());
		checkBox.align(Align.left);
		checkBox.getLabelCell().padLeft(0).spaceLeft(Display.devicePixel(8));
		checkBox.addListener(new VibrateClickListener() {
			public void onClick(InputEvent event, float x, float y) {
				if (checkBox.isChecked()) {
					for (Actor otherCheckbox : getActors()) {
						if (otherCheckbox instanceof CheckBox && otherCheckbox != checkBox) {
							((CheckBox) otherCheckbox).setChecked(false);
						}
					}

					gameGridRenderer.setActiveOverlay(overlay);
				} else {
					gameGridRenderer.setActiveOverlay(null);
				}
			}
		});

		Image colorSwatch = new Image(drawable(TowerAssetManager.WHITE_SWATCH), Scaling.stretch);
		colorSwatch.setColor(overlay.getColor(1f));

		row().left();
		add(checkBox).pad(0).fillX();
		add(colorSwatch).width(16).height(16);
	}
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:37,代码来源:DataOverlayPopOver.java

示例10: addCheckBox

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
public void addCheckBox(String text, boolean checked, Consumer<Boolean> lis) {
  CheckBoxStyle style = skin.get(CheckBoxStyle.class);
  CheckBox cb = new CheckBox(text, style);
  cb.setChecked(checked);
  if (lis != null)
    cb.addListener(new ChangeListener() {
      @Override
      public void changed(ChangeEvent event, Actor actor) {
        lis.accept(Boolean.valueOf(cb.isChecked()));
      }
    });

  table.add(cb).colspan(nbColumns).minHeight(cb.getMinHeight()).prefHeight(cb.getPrefHeight());
  table.row();
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:16,代码来源:FramedMenu.java

示例11: addAlignOrientationToLinearVelocityController

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
protected void addAlignOrientationToLinearVelocityController (Table table, final SteeringActor character) {
	CheckBox alignOrient = new CheckBox("Align orient.to velocity", container.skin);
	alignOrient.setChecked(character.isIndependentFacing());
	alignOrient.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			CheckBox checkBox = (CheckBox)event.getListenerActor();
			character.setIndependentFacing(checkBox.isChecked());
		}
	});
	table.add(alignOrient);
}
 
开发者ID:libgdx,项目名称:gdx-ai,代码行数:13,代码来源:Scene2dSteeringTest.java

示例12: show

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
@Override
public void show() {
	stage = new Stage();

	Gdx.input.setInputProcessor(stage);

	skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), new TextureAtlas("ui/atlas.pack"));

	table = new Table(skin);
	table.setFillParent(true);

	final CheckBox vSyncCheckBox = new CheckBox("vSync", skin,"default");
	vSyncCheckBox.setChecked(vSync());

	final TextField levelDirectoryInput = new TextField(levelDirectory().path(), skin,"default"); // creating a new TextField with the current level directory already written in it
	levelDirectoryInput.setMessageText("Nivel de directorio"); // set the text to be shown when nothing is in the TextField

	final TextButton back = new TextButton("Atras", skin,"default");
	back.pad(10);

	ClickListener buttonHandler = new ClickListener() {

		@Override
		public void clicked(InputEvent event, float x, float y) {
			//AssetLoaderSpace.music_menu.stop();
			// event.getListenerActor() returns the source of the event, e.g. a button that was clicked
			if(event.getListenerActor() == vSyncCheckBox) {
				// save vSync
				Gdx.app.getPreferences(LittleNibolas.TITLE).putBoolean("vsync", vSyncCheckBox.isChecked());

				// set vSync
				Gdx.graphics.setVSync(vSync());

				Gdx.app.log(LittleNibolas.TITLE, "vSync " + (vSync() ? "enabled" : "disabled"));
			} else if(event.getListenerActor() == back) {
				// save level directory
				String actualLevelDirectory = levelDirectoryInput.getText().trim().equals("") ? Gdx.files.getExternalStoragePath() + LittleNibolas.TITLE + "/levels" : levelDirectoryInput.getText().trim(); // shortened form of an if-statement: [boolean] ? [if true] : [else] // String#trim() removes spaces on both sides of the string
				Gdx.app.getPreferences(LittleNibolas.TITLE).putString("NivelDeDirectorio", actualLevelDirectory);

				// save the settings to preferences file (Preferences#flush() writes the preferences in memory to the file)
				Gdx.app.getPreferences(LittleNibolas.TITLE).flush();

				Gdx.app.log(LittleNibolas.TITLE, "Configuración guardada");

				stage.addAction(sequence(moveTo(0, stage.getHeight(), .5f), run(new Runnable() {

					@Override
					public void run() {
						((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu(game));
					}
				})));
			}
		}
	};

	vSyncCheckBox.addListener(buttonHandler);

	back.addListener(buttonHandler);

	// putting everything in the table
	table.add(new Label("Opciones", skin, "big")).spaceBottom(50).colspan(3).expandX().row();
	table.add();
	table.add("Nivel de directorio");
	table.add().row();
	table.add(vSyncCheckBox).top().expandY();
	table.add(levelDirectoryInput).top().fillX();
	table.add(back).bottom().right();

	stage.addActor(table);

	stage.addAction(sequence(moveTo(0, stage.getHeight()), moveTo(0, 0, .5f))); // coming in from top animation
}
 
开发者ID:CODA-Masters,项目名称:Little-Nibolas,代码行数:73,代码来源:Settings.java

示例13: show

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
@Override
public void show() {
	stage = new Stage();

	Gdx.input.setInputProcessor(stage);

	skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), new TextureAtlas("ui/atlas.pack"));

	table = new Table(skin);
	table.setFillParent(true);

	final CheckBox vSyncCheckBox = new CheckBox("vSync", skin,"default");
	vSyncCheckBox.setChecked(vSync());

	final TextField levelDirectoryInput = new TextField(levelDirectory().path(), skin,"default"); // creating a new TextField with the current level directory already written in it
	levelDirectoryInput.setMessageText("Nivel de directorio"); // set the text to be shown when nothing is in the TextField

	final TextButton back = new TextButton("Atras", skin,"default");
	back.pad(10);

	ClickListener buttonHandler = new ClickListener() {

		@Override
		public void clicked(InputEvent event, float x, float y) {
			//AssetLoaderSpace.music_menu.stop();
			// event.getListenerActor() returns the source of the event, e.g. a button that was clicked
			if(event.getListenerActor() == vSyncCheckBox) {
				// save vSync
				Gdx.app.getPreferences(LittleNibolas.TITLE).putBoolean("vsync", vSyncCheckBox.isChecked());

				// set vSync
				Gdx.graphics.setVSync(vSync());

				Gdx.app.log(LittleNibolas.TITLE, "vSync " + (vSync() ? "enabled" : "disabled"));
			} else if(event.getListenerActor() == back) {
				// save level directory
				String actualLevelDirectory = levelDirectoryInput.getText().trim().equals("") ? Gdx.files.getExternalStoragePath() + LittleNibolas.TITLE + "/levels" : levelDirectoryInput.getText().trim(); // shortened form of an if-statement: [boolean] ? [if true] : [else] // String#trim() removes spaces on both sides of the string
				Gdx.app.getPreferences(LittleNibolas.TITLE).putString("NivelDeDirectorio", actualLevelDirectory);

				// save the settings to preferences file (Preferences#flush() writes the preferences in memory to the file)
				Gdx.app.getPreferences(LittleNibolas.TITLE).flush();

				Gdx.app.log(LittleNibolas.TITLE, "Configuración guardada");

				stage.addAction(sequence(moveTo(0, stage.getHeight(), .5f), run(new Runnable() {

					@Override
					public void run() {
						((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
					}
				})));
			}
		}
	};

	vSyncCheckBox.addListener(buttonHandler);

	back.addListener(buttonHandler);

	// putting everything in the table
	table.add(new Label("Opciones", skin, "big")).spaceBottom(50).colspan(3).expandX().row();
	table.add();
	table.add("Nivel de directorio");
	table.add().row();
	table.add(vSyncCheckBox).top().expandY();
	table.add(levelDirectoryInput).top().fillX();
	table.add(back).bottom().right();

	stage.addActor(table);

	stage.addAction(sequence(moveTo(0, stage.getHeight()), moveTo(0, 0, .5f))); // coming in from top animation
}
 
开发者ID:CODA-Masters,项目名称:Little-Nibolas,代码行数:73,代码来源:Settings.java

示例14: initialize

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
@Override
public void initialize() {
    computeGaiaScan = new CheckBox(" " + txt("gui.gaiascan.enable"), skin);
    computeGaiaScan.setName("compute gaia scan");
    computeGaiaScan.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.instance.post(Events.COMPUTE_GAIA_SCAN_CMD, txt("gui.gaiascan.compute"), computeGaiaScan.isChecked());
            return true;
        }
        return false;
    });
    computeGaiaScan.setChecked(GlobalConf.scene.COMPUTE_GAIA_SCAN);

    transitColor = new CheckBox(" " + txt("gui.gaiascan.colour"), skin);
    transitColor.setName("transit color");
    transitColor.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.instance.post(Events.TRANSIT_COLOUR_CMD, txt("gui.gaiascan.transit"), transitColor.isChecked());
            return true;
        }
        return false;
    });
    transitColor.setChecked(GlobalConf.scene.STAR_COLOR_TRANSIT);

    //        onlyObservedStars = new CheckBox(txt("gui.gaiascan.onlyobserved"), skin);
    //        onlyObservedStars.setName("only observed stars");
    //        onlyObservedStars.addListener(new EventListener() {
    //            @Override
    //            public boolean handle(Event event) {
    //                if (event instanceof ChangeEvent) {
    //                    EventManager.instance.post(Events.ONLY_OBSERVED_STARS_CMD, txt("gui.gaiascan.only"), onlyObservedStars.isChecked());
    //                    return true;
    //                }
    //                return false;
    //            }
    //        });
    //        onlyObservedStars.setChecked(GlobalConf.scene.ONLY_OBSERVED_STARS);

    VerticalGroup gaiaGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left);
    gaiaGroup.addActor(computeGaiaScan);
    gaiaGroup.addActor(transitColor);
    //gaiaGroup.addActor(onlyObservedStars);

    component = gaiaGroup;

}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:47,代码来源:GaiaComponent.java

示例15: getDialog

import com.badlogic.gdx.scenes.scene2d.ui.CheckBox; //导入方法依赖的package包/类
@Override
public Dialog getDialog(Object... arguments) {
	// First argument is the title of the dialog
	String dialogTitle = (String) arguments[0];
	// Second and last argument is the body of the dialog
	String dialogMessage = (String) arguments[1];

	// Third argument should be a ConfirmationDialogClosedListener
	closedListener = (ConfirmationDialogClosedListener) arguments[2];

	// Fourth argument is optional. If present, should be a
	// ConfirmationDialogClosedListener,
	// meaning a checkbox should be added to the dialog.
	String checkboxText = null;
	if (arguments.length > 3) {
		checkboxListener = (ConfirmationDialogCheckboxListener) arguments[3];
		// Fifth argument is also optional: the text for the checkbox
		checkboxText = (String) arguments[4];
	}

	Skin skin = controller.getApplicationAssets().getSkin();
	I18N i18N = controller.getApplicationAssets().getI18N();
	dialogController = new DialogController(skin);

	// Main part of the dialog
	LinearLayout messageContainer = new LinearLayout(false);
	Label text = new Label(dialogMessage, skin);
	text.setWidth(LABEL_WIDTH);
	text.setWrap(true);
	messageContainer.add(text).top();

	// If required, add a checkbox
	if (checkboxListener != null) {
		final CheckBox checkBox = new CheckBox(checkboxText, skin);
		checkBox.setChecked(checkboxListener.isMarked());
		checkBox.addListener(new EventListener() {
			@Override
			public boolean handle(Event event) {
				Gdx.app.debug(
						this.getClass().getCanonicalName(),
						"Notifying a change in checkbox:"
								+ checkBox.isChecked());
				checkboxListener.checkboxChanged(checkBox.isChecked());
				return true;
			}
		});
		messageContainer.add(checkBox).top();
	}

	Dialog dialog = dialogController.title(dialogTitle)
			.content(messageContainer).getDialog();

	dialogController.button(i18N.m("general.ok"),
			new DialogController.DialogButtonListener() {
				@Override
				public void selected() {
					buttonActivated(true);
				}
			});
	dialogController.button(i18N.m("general.cancel"),
			new DialogController.DialogButtonListener() {
				@Override
				public void selected() {
					buttonActivated(false);
				}
			});

	dialog.setWidth(DIALOG_WIDTH);

	return dialog;

}
 
开发者ID:e-ucm,项目名称:ead,代码行数:73,代码来源:ConfirmationDialogBuilder.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.CheckBox.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。