Skip to content

Commit

Permalink
Integrate GUI with the application.
Browse files Browse the repository at this point in the history
Issue JingMa87#15: I have added a JComboBox to select the type of generator which should process the input text, along with a separate text area to display the result. I have also added an event listener to the 'Generate Text' button. When the button is clicked, the application will create an object of the selected generator type with the text in the input area as a parameter to its constructor, and call the generateText() method. I have selected a word limit of 200 here, but I suppose a text field to enter the word limit could be added to the GUI at a later stage. Finally, I have added a JLabel at the bottom to display the time taken for execution (in milliseconds). The label contents are updated each time the 'Generate Text' button is clicked.
  • Loading branch information
yashugrankar committed Oct 30, 2016
1 parent ae10396 commit f089aa2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Binary file modified build/classes/random/text/generator/Gui$1.class
Binary file not shown.
Binary file modified build/classes/random/text/generator/Gui.class
Binary file not shown.
6 changes: 5 additions & 1 deletion nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/Ma%20Jing/Documents/NetBeansProjects/Random%20Text%20Generator/src/random/text/generator/SpaceEfficientGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/SpaceEfficientGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/SpeedEfficientGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/RandomTextGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/WordSet.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/Gui.java</file>
</group>
</open-files>
</project-private>
13 changes: 9 additions & 4 deletions src/random/text/generator/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ public void init() {
label.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(label);

JTextArea textField = new JTextArea(5, 5);
textField.setText("Not randomly generated text.");
textField.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(textField);
JTextArea inputTextArea = new JTextArea(5, 5);
inputTextArea.setText(RandomTextGenerator.getDefaultText());
inputTextArea.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(inputTextArea);

JTextArea outputTextArea = new JTextArea(5, 5);
outputTextArea.setText("Not randomly generated text.");
outputTextArea.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(outputTextArea);

JButton generateTextButton = new JButton("Generate text");
generateTextButton.setAlignmentX(Component.CENTER_ALIGNMENT);
Expand Down

0 comments on commit f089aa2

Please sign in to comment.