From f089aa2d9e1ffee758a1f6c7ebb5c37173ccdbae Mon Sep 17 00:00:00 2001 From: Yash Ugrankar Date: Sun, 30 Oct 2016 18:55:09 +0530 Subject: [PATCH] Integrate GUI with the application. Issue #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. --- .../classes/random/text/generator/Gui$1.class | Bin 515 -> 515 bytes build/classes/random/text/generator/Gui.class | Bin 2089 -> 2266 bytes nbproject/private/private.xml | 6 +++++- src/random/text/generator/Gui.java | 13 +++++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build/classes/random/text/generator/Gui$1.class b/build/classes/random/text/generator/Gui$1.class index 2cb0a3ed2820e055fe1602e80f9ec47ed679dde0..86169fc06065535740d254704d3cef08e8a6c9e4 100644 GIT binary patch delta 23 ecmZo>X=d5b&d6v!xr5Px)slgO!D{kZMl%3QVFmI4 delta 23 ecmZo>X=d5b&d6vqxr5Px)r5hA!F2LjMl%3P&;{cF diff --git a/build/classes/random/text/generator/Gui.class b/build/classes/random/text/generator/Gui.class index 60e263c73494dc3f87e8a78cb7c1dfee1548b20b..b52581d308cb2fb59b103d4babf606b3c1789ef4 100644 GIT binary patch delta 891 zcmYjQO-~b16g_XI(>Dx5g~kAbVDSTNX|dq9paKd4il~5M{Xj=3rBGTdQ$R!!MBSJe zGp^VemL|qTF)c!Z3peT?FmdC;|6#n3lHgmMx#!*c?mPG1H*fQQ70mwlySfhG5T0wO zLW>3;&T_P>Xwx90UBEex^BOo>I65@s;DR8X92Yg{xFpDB4PEFKR*yJvh2yGJwTsE%Qb*pnM1 zrehRw`@K|D5-VFI@Tw=*!pwbBU6RW2$qi;@C z2COO#=>ri7K|&XW0{L*D04hzRhM1lWMlB8yW1>BTl!(2ALc;>S+cVD5p%v^%qttM? z3)3hI7>+cGd)HuuR5gQ=I>k`jJB44_^eb7vC*&^AU{{^fa0 z%2Tl=aFCi*!)s^9QGsci^BlZ*LGRI~N*CeB5{Y|9;+CnLRg%0;qQ8>lZ}fUaF>P7F zo5g7OLi>lQoFaV05ges9^w2Di;W#y71bwKZZaL_NlQ=<^Lb=PxKGhE=J@N)LW;;RQ u5?Mg*8Y)8>>|23%OS48!P;QNKY&A3&O*l>a63%R3GpQH90HdnJQvU(7N0y%e delta 757 zcmZva$xjqP6vlr&%}_l>#|)#WBN1Ex(HU*Q6;O~x5JcQY5L`zYaaeU2S=`{@jl=}| z|#}w@vMYEzq6XLi5or)70mo5WNYEE(5?9P~ivx_HimRG(qc6!d#dSsh{L+`Q zP&PG{ZB3_!`z_XW4kjm(Q{MPwdUU|+NJykHlSWn&3@ zTNF7d4rFNDdX5Jzs*6XZ$;@+`ZllD}oTG&QnK5F}rGFa4kSBUZ#usx{Rm zy^+#IHq{2B!N}Sio8!@7j`cmU99v>mj;*o09A$5$D1agCrpW)Os%A2B`O{P|EAufY z0-vyhr$V$KM9(Gjg-9`C>X!-siP1b`kIa@l4)g3|znq$o?*Ip-ks%IKL#;G3$42Tn zByvOIt6!Ecv4HHL-~;XDy^B=5W7~={Em5RdEvKzqLjesO5r2TjzqUzqn&GoVzgf;7 Dm - file:/C:/Users/Ma%20Jing/Documents/NetBeansProjects/Random%20Text%20Generator/src/random/text/generator/SpaceEfficientGenerator.java + file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/SpaceEfficientGenerator.java + file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/SpeedEfficientGenerator.java + file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/RandomTextGenerator.java + file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/WordSet.java + file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/Gui.java diff --git a/src/random/text/generator/Gui.java b/src/random/text/generator/Gui.java index 719b426..772015c 100644 --- a/src/random/text/generator/Gui.java +++ b/src/random/text/generator/Gui.java @@ -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);