diff --git a/.gitignore b/.gitignore index 7f59e8c..a9208ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -twitter4j.properties \ No newline at end of file +/Task_6/build/ \ No newline at end of file diff --git a/Task_6/.gitignore b/Task_6/.gitignore new file mode 100644 index 0000000..4b14170 --- /dev/null +++ b/Task_6/.gitignore @@ -0,0 +1,2 @@ +twitter4j.properties +/Task_6/nbproject/private/ \ No newline at end of file diff --git a/README.md b/Task_6/README.md similarity index 100% rename from README.md rename to Task_6/README.md diff --git a/asset/01.PNG b/Task_6/asset/01.PNG similarity index 100% rename from asset/01.PNG rename to Task_6/asset/01.PNG diff --git a/asset/02.PNG b/Task_6/asset/02.PNG similarity index 100% rename from asset/02.PNG rename to Task_6/asset/02.PNG diff --git a/asset/03.PNG b/Task_6/asset/03.PNG similarity index 100% rename from asset/03.PNG rename to Task_6/asset/03.PNG diff --git a/asset/04.PNG b/Task_6/asset/04.PNG similarity index 100% rename from asset/04.PNG rename to Task_6/asset/04.PNG diff --git a/asset/05.PNG b/Task_6/asset/05.PNG similarity index 100% rename from asset/05.PNG rename to Task_6/asset/05.PNG diff --git a/asset/06.PNG b/Task_6/asset/06.PNG similarity index 100% rename from asset/06.PNG rename to Task_6/asset/06.PNG diff --git a/asset/07.PNG b/Task_6/asset/07.PNG similarity index 100% rename from asset/07.PNG rename to Task_6/asset/07.PNG diff --git a/asset/08.PNG b/Task_6/asset/08.PNG similarity index 100% rename from asset/08.PNG rename to Task_6/asset/08.PNG diff --git a/asset/09.PNG b/Task_6/asset/09.PNG similarity index 100% rename from asset/09.PNG rename to Task_6/asset/09.PNG diff --git a/asset/10.PNG b/Task_6/asset/10.PNG similarity index 100% rename from asset/10.PNG rename to Task_6/asset/10.PNG diff --git a/asset/11.PNG b/Task_6/asset/11.PNG similarity index 100% rename from asset/11.PNG rename to Task_6/asset/11.PNG diff --git a/asset/12.PNG b/Task_6/asset/12.PNG similarity index 100% rename from asset/12.PNG rename to Task_6/asset/12.PNG diff --git a/asset/13.PNG b/Task_6/asset/13.PNG similarity index 100% rename from asset/13.PNG rename to Task_6/asset/13.PNG diff --git a/asset/14.PNG b/Task_6/asset/14.PNG similarity index 100% rename from asset/14.PNG rename to Task_6/asset/14.PNG diff --git a/asset/15.PNG b/Task_6/asset/15.PNG similarity index 100% rename from asset/15.PNG rename to Task_6/asset/15.PNG diff --git a/asset/16.PNG b/Task_6/asset/16.PNG similarity index 100% rename from asset/16.PNG rename to Task_6/asset/16.PNG diff --git a/asset/17.PNG b/Task_6/asset/17.PNG similarity index 100% rename from asset/17.PNG rename to Task_6/asset/17.PNG diff --git a/asset/18.PNG b/Task_6/asset/18.PNG similarity index 100% rename from asset/18.PNG rename to Task_6/asset/18.PNG diff --git a/asset/19.PNG b/Task_6/asset/19.PNG similarity index 100% rename from asset/19.PNG rename to Task_6/asset/19.PNG diff --git a/asset/20.PNG b/Task_6/asset/20.PNG similarity index 100% rename from asset/20.PNG rename to Task_6/asset/20.PNG diff --git a/asset/21.PNG b/Task_6/asset/21.PNG similarity index 100% rename from asset/21.PNG rename to Task_6/asset/21.PNG diff --git a/asset/22.PNG b/Task_6/asset/22.PNG similarity index 100% rename from asset/22.PNG rename to Task_6/asset/22.PNG diff --git a/asset/23.PNG b/Task_6/asset/23.PNG similarity index 100% rename from asset/23.PNG rename to Task_6/asset/23.PNG diff --git a/asset/24.PNG b/Task_6/asset/24.PNG similarity index 100% rename from asset/24.PNG rename to Task_6/asset/24.PNG diff --git a/asset/25.PNG b/Task_6/asset/25.PNG similarity index 100% rename from asset/25.PNG rename to Task_6/asset/25.PNG diff --git a/asset/26.PNG b/Task_6/asset/26.PNG similarity index 100% rename from asset/26.PNG rename to Task_6/asset/26.PNG diff --git a/asset/27.PNG b/Task_6/asset/27.PNG similarity index 100% rename from asset/27.PNG rename to Task_6/asset/27.PNG diff --git a/asset/28.PNG b/Task_6/asset/28.PNG similarity index 100% rename from asset/28.PNG rename to Task_6/asset/28.PNG diff --git a/asset/29.PNG b/Task_6/asset/29.PNG similarity index 100% rename from asset/29.PNG rename to Task_6/asset/29.PNG diff --git a/asset/30.PNG b/Task_6/asset/30.PNG similarity index 100% rename from asset/30.PNG rename to Task_6/asset/30.PNG diff --git a/asset/31.PNG b/Task_6/asset/31.PNG similarity index 100% rename from asset/31.PNG rename to Task_6/asset/31.PNG diff --git a/asset/32.PNG b/Task_6/asset/32.PNG similarity index 100% rename from asset/32.PNG rename to Task_6/asset/32.PNG diff --git a/asset/33.PNG b/Task_6/asset/33.PNG similarity index 100% rename from asset/33.PNG rename to Task_6/asset/33.PNG diff --git a/asset/34.PNG b/Task_6/asset/34.PNG similarity index 100% rename from asset/34.PNG rename to Task_6/asset/34.PNG diff --git a/asset/35.PNG b/Task_6/asset/35.PNG similarity index 100% rename from asset/35.PNG rename to Task_6/asset/35.PNG diff --git a/asset/36.PNG b/Task_6/asset/36.PNG similarity index 100% rename from asset/36.PNG rename to Task_6/asset/36.PNG diff --git a/asset/37.PNG b/Task_6/asset/37.PNG similarity index 100% rename from asset/37.PNG rename to Task_6/asset/37.PNG diff --git a/asset/38.PNG b/Task_6/asset/38.PNG similarity index 100% rename from asset/38.PNG rename to Task_6/asset/38.PNG diff --git a/asset/39.PNG b/Task_6/asset/39.PNG similarity index 100% rename from asset/39.PNG rename to Task_6/asset/39.PNG diff --git a/asset/40.PNG b/Task_6/asset/40.PNG similarity index 100% rename from asset/40.PNG rename to Task_6/asset/40.PNG diff --git a/asset/a01.PNG b/Task_6/asset/a01.PNG similarity index 100% rename from asset/a01.PNG rename to Task_6/asset/a01.PNG diff --git a/asset/a02.PNG b/Task_6/asset/a02.PNG similarity index 100% rename from asset/a02.PNG rename to Task_6/asset/a02.PNG diff --git a/asset/a03.PNG b/Task_6/asset/a03.PNG similarity index 100% rename from asset/a03.PNG rename to Task_6/asset/a03.PNG diff --git a/asset/a04.PNG b/Task_6/asset/a04.PNG similarity index 100% rename from asset/a04.PNG rename to Task_6/asset/a04.PNG diff --git a/asset/a05.PNG b/Task_6/asset/a05.PNG similarity index 100% rename from asset/a05.PNG rename to Task_6/asset/a05.PNG diff --git a/asset/a06.PNG b/Task_6/asset/a06.PNG similarity index 100% rename from asset/a06.PNG rename to Task_6/asset/a06.PNG diff --git a/asset/a07.PNG b/Task_6/asset/a07.PNG similarity index 100% rename from asset/a07.PNG rename to Task_6/asset/a07.PNG diff --git a/asset/a08.PNG b/Task_6/asset/a08.PNG similarity index 100% rename from asset/a08.PNG rename to Task_6/asset/a08.PNG diff --git a/Task_6/build.xml b/Task_6/build.xml new file mode 100644 index 0000000..f92cc1b --- /dev/null +++ b/Task_6/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Task_6. + + + diff --git a/Task_6/manifest.mf b/Task_6/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/Task_6/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Task_6/nbproject/build-impl.xml b/Task_6/nbproject/build-impl.xml new file mode 100644 index 0000000..de77309 --- /dev/null +++ b/Task_6/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6/nbproject/genfiles.properties b/Task_6/nbproject/genfiles.properties new file mode 100644 index 0000000..d2d310e --- /dev/null +++ b/Task_6/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=7d1ef66c +build.xml.script.CRC32=ae0fe4b8 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=7d1ef66c +nbproject/build-impl.xml.script.CRC32=b7747462 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/Task_6/nbproject/private/private.properties b/Task_6/nbproject/private/private.properties new file mode 100644 index 0000000..15f91d6 --- /dev/null +++ b/Task_6/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\Geb\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/Task_6/nbproject/private/private.xml b/Task_6/nbproject/private/private.xml new file mode 100644 index 0000000..6807a2b --- /dev/null +++ b/Task_6/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Task_6/nbproject/project.properties b/Task_6/nbproject/project.properties new file mode 100644 index 0000000..4aa2149 --- /dev/null +++ b/Task_6/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Task_6.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${libs.twitter4j-4.0.4.classpath} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=Driver.Task_6 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/Task_6/nbproject/project.xml b/Task_6/nbproject/project.xml new file mode 100644 index 0000000..ed7068e --- /dev/null +++ b/Task_6/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Task_6 + + + + + + + + + diff --git a/Task_6/src/Controller/Controller.java b/Task_6/src/Controller/Controller.java new file mode 100644 index 0000000..75bd431 --- /dev/null +++ b/Task_6/src/Controller/Controller.java @@ -0,0 +1,104 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Controller; + +import Gui.ComposeTweet; +import Gui.FollowUser; +import Gui.HomeTimeline; +import Interface.View; +import TwitterModel.TwitterModel; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JOptionPane; + + +/** + * + * @author Geb + */ +public class Controller implements ActionListener{ + + private TwitterModel model; + private View view; + + public Controller() { + model = new TwitterModel(); + goToHomeTimeline(); + } + + public void goToHomeTimeline() { + HomeTimeline home = new HomeTimeline(); + home.setVisible(true); + home.addListener(this); + home.setTimeline(model.getHomeTimeline()); + view = home; + } + + private void goToComposeTweet() { + ComposeTweet compose = new ComposeTweet(); + compose.setVisible(true); + compose.addListener(this); + view = compose; + } + + private void goToFollowUser() { + FollowUser follow = new FollowUser(); + follow.setVisible(true); + follow.addListener(this); + view = follow; + } + + public void actionPerformed(ActionEvent ae) { + Object source = ae.getSource(); + try { + if (view instanceof HomeTimeline) { + HomeTimeline home = new HomeTimeline(); + if(source.equals(home.getBtnCompose())) { + goToComposeTweet(); + home.dispose(); + } else if (source.equals(home.getBtnFollow())) { + goToFollowUser(); + home.dispose(); + } else if (source.equals(home.getBtnRefresh())) { + String timeline = model.getHomeTimeline(); + home.setTimeline(timeline); + } else if (source.equals(home.getBtnExit())) { + JOptionPane.showMessageDialog(null, "Thank You"); + System.exit(0); + } + } else if (view instanceof ComposeTweet) { + + ComposeTweet compose = (ComposeTweet) view; + if (source.equals(compose.getBtnCancel())) { + goToHomeTimeline(); + compose.dispose(); + } else if (source.equals(compose.getBtntweet())) { + String tweet = compose.getTweet(); + model.tweetStatus(tweet); + goToHomeTimeline(); + compose.dispose(); + } + } + else + { + + FollowUser follow = (FollowUser) view; + if (source.equals(follow.getBtnCancel())) { + goToHomeTimeline(); + follow.dispose(); + } else if (source.equals(follow.getBtnFollow())) { + String user = follow.getUser(); + model.followUser(user); + follow.setUser(""); + } + } + + } catch (Exception e) { + JOptionPane.showMessageDialog((Component) view, e.getMessage()); + } + } +} diff --git a/Task_6/src/Driver/Driver.java b/Task_6/src/Driver/Driver.java new file mode 100644 index 0000000..9cfdabf --- /dev/null +++ b/Task_6/src/Driver/Driver.java @@ -0,0 +1,18 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Driver; + +import Controller.Controller; + +/** + * + * @author Geb + */ +public class Driver { + public static void main(String[] args) { + Controller a = new Controller(); + } +} diff --git a/Task_6/src/Gui/ComposeTweet.form b/Task_6/src/Gui/ComposeTweet.form new file mode 100644 index 0000000..570e2f7 --- /dev/null +++ b/Task_6/src/Gui/ComposeTweet.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6/src/Gui/ComposeTweet.java b/Task_6/src/Gui/ComposeTweet.java new file mode 100644 index 0000000..5a6c2d0 --- /dev/null +++ b/Task_6/src/Gui/ComposeTweet.java @@ -0,0 +1,128 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Gui; + +import Interface.View; +import java.awt.event.ActionListener; + +/** + * + * @author Geb + */ +public class ComposeTweet extends javax.swing.JFrame implements View { + + /** + * Creates new form ComposeTweet + */ + public ComposeTweet() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + txAreaTweet = new javax.swing.JTextArea(); + jLabel2 = new javax.swing.JLabel(); + btnCancel = new javax.swing.JButton(); + btnTweet = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel1.setText("Compose new Tweet...."); + + txAreaTweet.setColumns(20); + txAreaTweet.setRows(5); + jScrollPane1.setViewportView(txAreaTweet); + + jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + jLabel2.setText("140"); + + btnCancel.setText("Cancel"); + + btnTweet.setText("Tweet"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1)) + .addGroup(layout.createSequentialGroup() + .addGap(27, 27, 27) + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(21, 21, 21) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 167, Short.MAX_VALUE) + .addComponent(btnCancel) + .addGap(53, 53, 53) + .addComponent(btnTweet))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(26, 26, 26) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnTweet) + .addComponent(btnCancel) + .addComponent(jLabel2))) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancel; + private javax.swing.JButton btnTweet; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTweet; + // End of variables declaration//GEN-END:variables + + public Object getBtnCancel () { + return btnCancel; + } + + public Object getBtnTweet () { + return btnTweet; + } + + public String getTweet () { + return txAreaTweet.getText (); + } + + public void addListener (ActionListener e) { + btnCancel.addActionListener(e); + btnTweet.addActionListener(e); + } + + public Object getBtntweet() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} diff --git a/Task_6/src/Gui/FollowUser.form b/Task_6/src/Gui/FollowUser.form new file mode 100644 index 0000000..d33c2a8 --- /dev/null +++ b/Task_6/src/Gui/FollowUser.form @@ -0,0 +1,82 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6/src/Gui/FollowUser.java b/Task_6/src/Gui/FollowUser.java new file mode 100644 index 0000000..9720cae --- /dev/null +++ b/Task_6/src/Gui/FollowUser.java @@ -0,0 +1,111 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Gui; + +import Interface.View; +import java.awt.event.ActionListener; + +/** + * + * @author Geb + */ +public class FollowUser extends javax.swing.JFrame implements View { + + /** + * Creates new form FollowUser + */ + public FollowUser() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + txFieldUser = new javax.swing.JTextField(); + btnCancel = new javax.swing.JButton(); + btnFollow = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel1.setText("Follow User"); + + btnCancel.setText("Cancel"); + + btnFollow.setText("Follow"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(btnCancel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnFollow)) + .addComponent(txFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(25, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCancel) + .addComponent(btnFollow)) + .addContainerGap(172, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancel; + private javax.swing.JButton btnFollow; + private javax.swing.JLabel jLabel1; + private javax.swing.JTextField txFieldUser; + // End of variables declaration//GEN-END:variables + + public Object getBtnCancel () { + return btnCancel; + } + + public Object getBtnFollow () { + return btnFollow; + } + + public String getUser () { + return txFieldUser.getText (); + } + + public void setUser (String s) { + txFieldUser.setText (s); + } + + public void addListener (ActionListener e) { + btnCancel.addActionListener(e); + btnFollow.addActionListener(e); + } +} diff --git a/Task_6/src/Gui/HomeTimeline.form b/Task_6/src/Gui/HomeTimeline.form new file mode 100644 index 0000000..6e47fcc --- /dev/null +++ b/Task_6/src/Gui/HomeTimeline.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Task_6/src/Gui/HomeTimeline.java b/Task_6/src/Gui/HomeTimeline.java new file mode 100644 index 0000000..00aafb6 --- /dev/null +++ b/Task_6/src/Gui/HomeTimeline.java @@ -0,0 +1,129 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Gui; + +import Interface.View; +import java.awt.event.ActionListener; + +/** + * + * @author Geb + */ +public class HomeTimeline extends javax.swing.JFrame implements View { + + /** + * Creates new form HomeTimeline + */ + public HomeTimeline() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + txAreaTimeline = new javax.swing.JTextArea(); + btnCompose = new javax.swing.JButton(); + btnFollow = new javax.swing.JButton(); + btnRefresh = new javax.swing.JButton(); + btnExit = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + txAreaTimeline.setEditable(false); + txAreaTimeline.setColumns(20); + txAreaTimeline.setRows(5); + jScrollPane1.setViewportView(txAreaTimeline); + + btnCompose.setText("Compose"); + + btnFollow.setText("Follow User"); + + btnRefresh.setText("Refresh"); + + btnExit.setText("Exit"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(btnCompose) + .addGap(31, 31, 31) + .addComponent(btnFollow) + .addGap(27, 27, 27) + .addComponent(btnRefresh) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE) + .addComponent(btnExit)) + .addComponent(jScrollPane1)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(26, 26, 26) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCompose) + .addComponent(btnFollow) + .addComponent(btnRefresh) + .addComponent(btnExit)) + .addGap(51, 51, 51)) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCompose; + private javax.swing.JButton btnExit; + private javax.swing.JButton btnFollow; + private javax.swing.JButton btnRefresh; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTimeline; + // End of variables declaration//GEN-END:variables + + public Object getBtnCompose () { + return btnCompose; + } + + public Object getBtnExit () { + return btnExit; + } + + public Object getBtnFollow () { + return btnFollow; + } + + public Object getBtnRefresh () { + return btnRefresh; + } + + public void setTimeline (String s) { + txAreaTimeline.setText(s); + } + + public void addListener (ActionListener e) { + btnCompose.addActionListener(e); + btnExit.addActionListener(e); + btnFollow.addActionListener(e); + btnRefresh.addActionListener(e); + } +} diff --git a/Task_6/src/Interface/View.java b/Task_6/src/Interface/View.java new file mode 100644 index 0000000..53ce20f --- /dev/null +++ b/Task_6/src/Interface/View.java @@ -0,0 +1,16 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Interface; + +import java.awt.event.ActionListener; + +/** + * + * @author Guntur Fatmawan + */ +public interface View { + public void addListener (ActionListener e); +} diff --git a/Task_6/src/TwitterModel/TwitterModel.java b/Task_6/src/TwitterModel/TwitterModel.java new file mode 100644 index 0000000..e631b66 --- /dev/null +++ b/Task_6/src/TwitterModel/TwitterModel.java @@ -0,0 +1,54 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package TwitterModel; + +import twitter4j.*; +import java.util.List; +import javax.swing.JOptionPane; + +/** + * + * @author Geb + */ +public class TwitterModel { + private Twitter twitter; + + public TwitterModel () { + twitter = new TwitterFactory().getInstance(); + } + + public void tweetStatus (String tweet) { + try { + twitter.updateStatus(tweet); + JOptionPane.showMessageDialog(null, "Pesan Berhasil"); + }catch (Exception e) { + JOptionPane.showMessageDialog (null, "Judul Exception" , "Pesan exception", JOptionPane.ERROR_MESSAGE); + } + } + + public String getHomeTimeline () { + try { + String s = " "; + List status = twitter.getHomeTimeline(); + for (int i = 0; i < status.size(); i++) { + s = s+ status.get(i).getUser().getScreenName()+ " - " + + status.get(i).getText()+ "\n\n"; + } + return s; + }catch (Exception e) { + JOptionPane.showMessageDialog (null, "Judul Exception", "Pesan Exception", JOptionPane.ERROR_MESSAGE); + } + return null; + } + + public void followUser(String user) { + try { + twitter.createFriendship(user); + }catch (Exception e) { + JOptionPane.showMessageDialog (null, "Judul Exception", "Pesan Exception", JOptionPane.ERROR_MESSAGE); + } + } +}