public class SolveExercisePane
extends java.lang.Object
SolveExerciseDialog
in an easy way.Modifier and Type | Method and Description |
---|---|
static boolean |
showDialog(PluginHost host,
AlgorithmExercise<?> exercise,
SolveExerciseDialog.SolutionEntry<?>[] entries)
Shows the dialog to solve an exercise by requesting a user input.
|
static boolean |
showDialog(PluginHost host,
AlgorithmExercise<?> exercise,
SolveExerciseDialog.SolutionEntry<?>[] entries,
LanguageFile langFile,
java.lang.String langID)
Shows the dialog to solve an exercise by requesting a user input.
|
static boolean |
showDialog(PluginHost host,
AlgorithmExercise<?> exercise,
SolveExerciseDialog.SolutionEntry<?>[] entries,
LanguageFile langFile,
java.lang.String langID,
java.lang.String inputHint)
Shows the dialog to solve an exercise by requesting a user input.
|
static boolean |
showDialog(PluginHost host,
AlgorithmExercise<?> exercise,
SolveExerciseDialog.SolutionEntry<?>[] entries,
java.lang.String inputHint)
Shows the dialog to solve an exercise by requesting a user input.
|
public static boolean showDialog(PluginHost host, AlgorithmExercise<?> exercise, SolveExerciseDialog.SolutionEntry<?>[] entries) throws java.lang.IllegalArgumentException
host
- the host that is used to center the dialog in the application or null
(centers the dialog in the screen)exercise
- the exercise that should be solvedentries
- the entries where the user has to enter or select the solutionstrue
if the user has clicked ok otherwise false
java.lang.IllegalArgumentException
- public static boolean showDialog(PluginHost host, AlgorithmExercise<?> exercise, SolveExerciseDialog.SolutionEntry<?>[] entries, java.lang.String inputHint) throws java.lang.IllegalArgumentException
host
- the host that is used to center the dialog in the application or null
(centers the dialog in the screen)exercise
- the exercise that should be solvedentries
- the entries where the user has to enter or select the solutionsinputHint
- a hint for the user how to format the inputtrue
if the user has clicked ok otherwise false
java.lang.IllegalArgumentException
- public static boolean showDialog(PluginHost host, AlgorithmExercise<?> exercise, SolveExerciseDialog.SolutionEntry<?>[] entries, LanguageFile langFile, java.lang.String langID) throws java.lang.IllegalArgumentException
host
- the host that is used to center the dialog in the application or null
(centers the dialog in the screen)exercise
- the exercise that should be solvedentries
- the entries where the user has to enter or select the solutionslangFile
- the language file or null
if the dialog should not use language dependent labels for the title, the ok button and the cancel button (in this case the predefined labels are shown)langID
- the language idtrue
if the user has clicked ok otherwise false
java.lang.IllegalArgumentException
- public static boolean showDialog(PluginHost host, AlgorithmExercise<?> exercise, SolveExerciseDialog.SolutionEntry<?>[] entries, LanguageFile langFile, java.lang.String langID, java.lang.String inputHint) throws java.lang.IllegalArgumentException
SolveExerciseDialog.SolutionEntry
s one below the other like:
Label Entry 1 | Component Entry 1 --------------------------------- Label Entry 2 | Component Entry 2 --------------------------------- Label Entry 3 | Component Entry 3 --------------------------------- ...Example: The user should enter two sets A and B.
final SolutionEntry<JTextField> entryA = new SolutionEntry<JTextField>("A:", new JTextField()); final SolutionEntry<JTextField> entryB = new SolutionEntry<JTextField>("B:", new JTextField());After that we create the array of entries:
final SolutionEntry<?>[] entries = new SolutionEntry<?>[] { entryA, entryB };Finally we display the dialog to the user:
if(SolveExercisePane.showDialog(myExercise, entries, myLangFile, myLangID)) { System.out.println("The solution the user has entered:"); System.out.println("A: " + entryA.getComponent().getText()); System.out.println("B: " + entryB.getComponent().getText()); } else System.out.println("The user canceled the dialog!");
host
- the host that is used to center the dialog in the application or null
(centers the dialog in the screen)exercise
- the exercise that should be solvedentries
- the entries where the user has to enter or select the solutionslangFile
- the language file or null
if the dialog should not use language dependent labels for the title, the ok button and the cancel button (in this case the predefined labels are shown)langID
- the language idinputHint
- a hint for the user how to format the inputtrue
if the user has clicked ok otherwise false
java.lang.IllegalArgumentException
-