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


Java Dialog.key方法代碼示例

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


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

示例1: yesNoDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
public void yesNoDialog(String title, String text,
        ConfirmationListener listener) {
    Dialog dialog = new Dialog(title, main.getSkin(), "bg") {
        @Override
        protected void result(Object object) {
            listener.selected((int) object);
        }
    };
    dialog.getTitleTable().getCells().first().padLeft(5.0f);
    Label label = new Label(text, main.getSkin());
    label.setAlignment(Align.center);
    dialog.text(label);
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Yes", 0);
    dialog.button("No", 1);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ESCAPE, 1);
    dialog.show(main.getStage());
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:22,代碼來源:DialogFactory.java

示例2: yesNoCancelDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
public void yesNoCancelDialog(String title, String text,
        ConfirmationListener listener) {
    Dialog dialog = new Dialog(title, main.getSkin(), "bg") {
        @Override
        protected void result(Object object) {
            listener.selected((int) object);
        }
    };
    dialog.getTitleTable().getCells().first().padLeft(5.0f);
    Label label = new Label(text, main.getSkin());
    label.setAlignment(Align.center);
    dialog.text(label);
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Yes", 0);
    dialog.button("No", 1);
    dialog.button("Cancel", 2);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(2).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ESCAPE, 2);
    dialog.show(main.getStage());
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:24,代碼來源:DialogFactory.java

示例3: onClientConnected

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
@Override
public void onClientConnected(IOException e) {
	connectingDialog.setVisible(false);
	if (e == null) {
		game.pushScreen("lobby");
	} else {
		game.setCurrentSession(null);

		Dialog dialog = new Dialog("Fehler", skin);
		dialog.text(e.getMessage());
		dialog.button("Ok", true);
		dialog.key(Keys.ENTER, true);
		dialog.show(stage);
	}
}
 
開發者ID:eskalon,項目名稱:ProjektGG,代碼行數:16,代碼來源:ServerBrowserScreen.java

示例4: onHostStarted

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
@Override
public void onHostStarted(IOException e) {
	connectingDialog.setVisible(false);
	if (e == null) {
		game.pushScreen("lobby");
	} else {
		game.setCurrentSession(null);
		Dialog dialog = new Dialog("Fehler", skin);
		dialog.text(e.getMessage());
		dialog.button("Ok", true);
		dialog.key(Keys.ENTER, true);
		dialog.show(stage);
	}
}
 
開發者ID:eskalon,項目名稱:ProjektGG,代碼行數:15,代碼來源:LobbyCreationScreen.java

示例5: showConfirmDeleteDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * Shows a dialog to confirm deletion of all TintedDrawables based on the
 * provided drawable data. This is called when the delete button is pressed
 * on a drawable in the drawable list.
 * @param drawable 
 */
private void showConfirmDeleteDialog(DrawableData drawable) {
    Dialog dialog = new Dialog("Delete duplicates?", getSkin(), "bg"){
        @Override
        protected void result(Object object) {
            if ((boolean) object) {
                main.getProjectData().setChangesSaved(false);
                removeDuplicateDrawables(drawable.file);
                gatherDrawables();
                sortBySelectedMode();
            }
        }
    };
    
    dialog.getTitleTable().padLeft(5.0f);
    dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
    dialog.getButtonTable().padBottom(15.0f);
    
    dialog.text("Deleting this drawable will also delete one or more tinted drawables.\n"
            + "Delete duplicates?");
    dialog.button("OK", true);
    dialog.button("Cancel", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ENTER, true);
    dialog.key(Input.Keys.ESCAPE, false);
    dialog.show(getStage());
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:34,代碼來源:DialogDrawables.java

示例6: showRemoveDuplicatesDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * Shows a dialog to confirm removal of duplicate drawables that have the
 * same name without extension. This is called after selecting new drawables.
 * @param unhandledFiles
 * @param backup
 * @param filesToProcess 
 */
private void showRemoveDuplicatesDialog(Array<FileHandle> unhandledFiles, Array<DrawableData> backup, Array<FileHandle> filesToProcess) {
    Dialog dialog = new Dialog("Delete duplicates?", getSkin(), "bg"){
        @Override
        protected void result(Object object) {
            if ((boolean) object) {
                for (FileHandle fileHandle : unhandledFiles) {
                    removeDuplicateDrawables(fileHandle);
                    filesToProcess.add(fileHandle);
                }
            }
            finalizeDrawables(backup, filesToProcess);
        }
    };
    
    dialog.getTitleTable().padLeft(5.0f);
    dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
    dialog.getButtonTable().padBottom(15.0f);
    
    dialog.text("Adding this drawable will overwrite one or more drawables\n"
            + "Delete duplicates?");
    dialog.button("OK", true);
    dialog.button("Cancel", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ENTER, true);
    dialog.key(Input.Keys.ESCAPE, false);
    dialog.show(getStage());
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:36,代碼來源:DialogDrawables.java

示例7: showMsgDlg

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * Display a dialog with a notice
 */
public void showMsgDlg(String title, String message, Stage stage) {
    Dialog dlg = new Dialog(title, skin);
    dlg.pad(20);
    dlg.getContentTable().add(message).pad(20);
    dlg.button("OK", true);
    dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
    dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, true);
    dlg.show(stage);
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:13,代碼來源:SkinEditorGame.java

示例8: showDeleteDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * 
 */
protected void showDeleteDialog() {

	// Check if it used by other style prior to delete it
	// FIXME: TODO

	Dialog dlgStyle = new Dialog("Delete Style", game.skin) {

		@Override
		protected void result(Object object) {
			if ((Boolean) object == false) {
				return;
			}

			// Now we really add it!
			game.skinProject.remove((String) listStyles.getSelected(), currentStyle.getClass());
			refresh();
			game.screenMain.saveToSkin();
			game.screenMain.panePreview.refresh();

		}

	};

	dlgStyle.pad(20);
	dlgStyle.getContentTable().add("You are sure you want to delete this style?");
	dlgStyle.button("OK", true);
	dlgStyle.button("Cancel", false);
	dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
	dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
	dlgStyle.show(getStage());

}
 
開發者ID:cobolfoo,項目名稱:gdx-skineditor,代碼行數:36,代碼來源:OptionsPane.java

示例9: showNewProjectDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * 
 */
private void showNewProjectDialog() {

	final TextField textProject = new TextField("", game.skin);
	Dialog dlg = new Dialog("New Project", game.skin) {

		@Override
		protected void result(Object object) {
			if ((Boolean) object == false) {
				return;
			}

			String projectName = textProject.getText();
			projectName = projectName.replace(".", "_");
			projectName = projectName.replace("/", "_");
			projectName = projectName.replace("\\", "_");
			projectName = projectName.replace("-", "_");
			if (projectName.isEmpty() == true)
				return;

			createProject(projectName);

		}

	};

	dlg.pad(20);
	dlg.getContentTable().add("Project Name:");
	dlg.getContentTable().add(textProject).pad(20);
	dlg.button("OK", true);
	dlg.button("Cancel", false);
	dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
	dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
	dlg.setWidth(480);
	dlg.show(stage);
	stage.setKeyboardFocus(textProject);
}
 
開發者ID:cobolfoo,項目名稱:gdx-skineditor,代碼行數:40,代碼來源:WelcomeScreen.java

示例10: showDeleteDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * 
 */
private void showDeleteDialog() {
	
	Dialog dlgStyle = new Dialog("Delete Project", game.skin) {

		@Override
		protected void result(Object object) {
			if ((Boolean) object == false) {
				return;
			}

			// We delete it
			FileHandle projectFolder = Gdx.files.local("projects/" + (String) listProjects.getSelected());
			projectFolder.deleteDirectory();
			
			refreshProjects();
		}

	};

	dlgStyle.pad(20);
	dlgStyle.getContentTable().add(
			"You are sure you want to delete this project?");
	dlgStyle.button("OK", true);
	dlgStyle.button("Cancel", false);
	dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
	dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
	dlgStyle.show(stage);
	
}
 
開發者ID:cobolfoo,項目名稱:gdx-skineditor,代碼行數:33,代碼來源:WelcomeScreen.java

示例11: showNotice

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
/**
 * Display a dialog with a notice
 */
public void showNotice(String title, String message, Stage stage) {
	Dialog dlg = new Dialog(title, skin);
	dlg.pad(20);
	dlg.getContentTable().add(message).pad(20);
	dlg.button("OK", true);
	dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
	dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
	dlg.show(stage);
}
 
開發者ID:cobolfoo,項目名稱:gdx-skineditor,代碼行數:13,代碼來源:SkinEditorGame.java

示例12: showNewStyleDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
public void showNewStyleDialog(Skin skin, Stage stage) {
    Class selectedClass = main.getRootTable().getSelectedClass();

    final TextField textField = new TextField("", skin);
    Dialog dialog = new Dialog("New Style", skin, "bg") {
        @Override
        protected void result(Object object) {
            if ((Boolean) object) {
                main.getUndoableManager().addUndoable(new NewStyleUndoable(selectedClass, textField.getText(), main), true);
            }
        }
    };
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("OK", true).button("Cancel", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();

    textField.setTextFieldListener((TextField textField1, char c) -> {
        if (c == '\n') {
            if (!okButton.isDisabled()) {
                main.getUndoableManager().addUndoable(new NewStyleUndoable(selectedClass, textField1.getText(), main), true);
                dialog.hide();
            }
            main.getStage().setKeyboardFocus(textField1);
        }
    });

    textField.addListener(main.getIbeamListener());

    dialog.getTitleLabel().setAlignment(Align.center);
    dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
    dialog.text("What is the name of the new style?");
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getContentTable().row();
    dialog.getContentTable().add(textField).growX();
    okButton.setDisabled(true);

    Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
    textField.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            boolean disable = !StyleData.validate(textField.getText());

            if (!disable) {
                for (StyleData data : currentStyles) {
                    if (data.name.equals(textField.getText())) {
                        disable = true;
                        break;
                    }
                }
            }

            okButton.setDisabled(disable);
        }
    });

    dialog.key(Input.Keys.ESCAPE, false);

    dialog.show(stage);
    stage.setKeyboardFocus(textField);
    textField.setFocusTraversal(false);
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:64,代碼來源:DialogFactory.java

示例13: showDuplicateStyleDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
public void showDuplicateStyleDialog(Skin skin, Stage stage) {
    Class selectedClass = main.getRootTable().getSelectedClass();
    StyleData originalStyle = main.getRootTable().getSelectedStyle();

    final TextField textField = new TextField("", skin);
    Dialog dialog = new Dialog("Duplicate Style", skin, "bg") {
        @Override
        protected void result(Object object) {
            if ((Boolean) object) {
                main.getUndoableManager().addUndoable(new DuplicateStyleUndoable(originalStyle, textField.getText(), main), true);
            }
        }
    };

    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("OK", true).button("Cancel", false);
    final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();
    okButton.addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());

    textField.setTextFieldListener((TextField textField1, char c) -> {
        if (c == '\n') {
            if (!okButton.isDisabled()) {
                main.getUndoableManager().addUndoable(new DuplicateStyleUndoable(originalStyle, textField.getText(), main), true);
                dialog.hide();
            }
            main.getStage().setKeyboardFocus(textField1);
        }
    });

    textField.addListener(main.getIbeamListener());

    dialog.getTitleLabel().setAlignment(Align.center);
    dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
    dialog.text("What is the name of the new, duplicated style?");
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getContentTable().row();
    dialog.getContentTable().add(textField).growX();
    okButton.setDisabled(true);

    Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
    textField.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            boolean disable = !StyleData.validate(textField.getText());

            if (!disable) {
                for (StyleData data : currentStyles) {
                    if (data.name.equals(textField.getText())) {
                        disable = true;
                        break;
                    }
                }
            }

            okButton.setDisabled(disable);
        }
    });

    dialog.key(Input.Keys.ESCAPE, false);

    dialog.show(stage);
    stage.setKeyboardFocus(textField);

    textField.setFocusTraversal(false);
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:67,代碼來源:DialogFactory.java

示例14: showRenameStyleDialog

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
public void showRenameStyleDialog(Skin skin, Stage stage) {
    Class selectedClass = main.getRootTable().getSelectedClass();

    final TextField textField = new TextField(main.getRootTable().getSelectedStyle().name, skin);
    Dialog dialog = new Dialog("Rename Style", skin, "bg") {
        @Override
        protected void result(Object object) {
            if ((Boolean) object) {
                main.getUndoableManager().addUndoable(new UndoableManager.RenameStyleUndoable(main.getRootTable().getSelectedStyle(), main, textField.getText()), true);
            }
        }
    };
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("OK", true).button("Cancel", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();

    textField.setTextFieldListener((TextField textField1, char c) -> {
        if (c == '\n') {
            if (!okButton.isDisabled()) {
                main.getUndoableManager().addUndoable(new UndoableManager.RenameStyleUndoable(main.getRootTable().getSelectedStyle(), main, textField1.getText()), true);
                dialog.hide();
            }
            main.getStage().setKeyboardFocus(textField1);
        }
    });

    textField.addListener(main.getIbeamListener());

    dialog.getTitleLabel().setAlignment(Align.center);
    dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
    dialog.text("What would you like to rename the style \"" + main.getRootTable().getSelectedStyle().name + "\" to?");
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getContentTable().row();
    dialog.getContentTable().add(textField).growX();
    okButton.setDisabled(true);

    Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
    textField.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            boolean disable = !StyleData.validate(textField.getText());

            if (!disable) {
                for (StyleData data : currentStyles) {
                    if (data.name.equals(textField.getText())) {
                        disable = true;
                        break;
                    }
                }
            }

            okButton.setDisabled(disable);
        }
    });

    dialog.key(Input.Keys.ESCAPE, false);

    dialog.show(stage);
    stage.setKeyboardFocus(textField);
    textField.selectAll();
    textField.setFocusTraversal(false);
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:65,代碼來源:DialogFactory.java

示例15: finished

import com.badlogic.gdx.scenes.scene2d.ui.Dialog; //導入方法依賴的package包/類
@Override
public void finished(final Color color) {
    if (color != null) {
        final TextField nameTextField = new TextField("???", game.skin);
        Dialog dlg0 = new Dialog("name your color", game.skin) {

            @Override
            protected void result(Object object) {
                if ((Boolean) object == false) {
                    return;
                }

                String colorName = nameTextField.getText();

                if ((colorName != null) && (colorName.isEmpty() == false)) {
                    // Verify if the color name is already in use
                    if (colors.containsKey(colorName) == true) {
                        game.showMsgDlg("Error", "Color name already in use!", game.screenMain.stage);
                    } else {
                        // add the color (asuming RGBA)

                        SkinColor newColor = new SkinColor(color);
                        newColor.skinName = colorName;
                        colors.put(colorName, newColor);
                        game.screenMain.saveToSkin();

                        // update table
                        updateTable();
                    }
                }
            }
        };
        dlg0.pad(20);
        dlg0.getContentTable().add("Resource name:");
        dlg0.getContentTable().add(nameTextField).pad(20);
        dlg0.button("OK", true);
        dlg0.button("Cancel", false);
        dlg0.key(com.badlogic.gdx.Input.Keys.ENTER, true);
        dlg0.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
        dlg0.show(getStage());

    }
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:44,代碼來源:ColorPickerDialog.java


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