diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..86075ca --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Task6. + + + diff --git a/build/classes/.netbeans_automatic_build b/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/.netbeans_update_resources b/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/Controller/Controller.class b/build/classes/Controller/Controller.class new file mode 100644 index 0000000..972af26 Binary files /dev/null and b/build/classes/Controller/Controller.class differ diff --git a/build/classes/Driver/Driver.class b/build/classes/Driver/Driver.class new file mode 100644 index 0000000..6194834 Binary files /dev/null and b/build/classes/Driver/Driver.class differ diff --git a/build/classes/Gui/ComposeTweet.class b/build/classes/Gui/ComposeTweet.class new file mode 100644 index 0000000..f32b236 Binary files /dev/null and b/build/classes/Gui/ComposeTweet.class differ diff --git a/build/classes/Gui/ComposeTweet.form b/build/classes/Gui/ComposeTweet.form new file mode 100644 index 0000000..570e2f7 --- /dev/null +++ b/build/classes/Gui/ComposeTweet.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/classes/Gui/FollowUser.class b/build/classes/Gui/FollowUser.class new file mode 100644 index 0000000..ffbaf50 Binary files /dev/null and b/build/classes/Gui/FollowUser.class differ diff --git a/build/classes/Gui/FollowUser.form b/build/classes/Gui/FollowUser.form new file mode 100644 index 0000000..d33c2a8 --- /dev/null +++ b/build/classes/Gui/FollowUser.form @@ -0,0 +1,82 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/classes/Gui/HomeTimeline.class b/build/classes/Gui/HomeTimeline.class new file mode 100644 index 0000000..c914087 Binary files /dev/null and b/build/classes/Gui/HomeTimeline.class differ diff --git a/build/classes/Gui/HomeTimeline.form b/build/classes/Gui/HomeTimeline.form new file mode 100644 index 0000000..6e47fcc --- /dev/null +++ b/build/classes/Gui/HomeTimeline.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/build/classes/Interface/View.class b/build/classes/Interface/View.class new file mode 100644 index 0000000..5bdabf8 Binary files /dev/null and b/build/classes/Interface/View.class differ diff --git a/build/classes/TwitterModel/TwitterModel.class b/build/classes/TwitterModel/TwitterModel.class new file mode 100644 index 0000000..7043ae3 Binary files /dev/null and b/build/classes/TwitterModel/TwitterModel.class differ diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..ac7f89a --- /dev/null +++ b/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/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..443533b --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c7431df5 +build.xml.script.CRC32=71db5873 +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=c7431df5 +nbproject/build-impl.xml.script.CRC32=4eac25e4 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..f2af676 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\Guntur Fatmawan\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..5062aae --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,15 @@ + + + + + + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/Gui/ComposeTweet.java + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/Driver/Driver.java + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/TwitterModel/TwitterModel.java + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/Interface/View.java + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/Controller/Controller.java + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/Gui/HomeTimeline.java + file:/D:/Telkom%20University/Semester%204/PBO/Task_6/Task6/src/Gui/FollowUser.java + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..13c78bc --- /dev/null +++ b/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}/Task6.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${libs.twitter4j-core-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.Driver +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/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..2e08c4c --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Task6 + + + + + + + + + diff --git a/src/Controller/Controller.java b/src/Controller/Controller.java new file mode 100644 index 0000000..f086290 --- /dev/null +++ b/src/Controller/Controller.java @@ -0,0 +1,108 @@ +/* + * 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 Guntur Fatmawan + */ +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 = (HomeTimeline) view; + 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()); + } + } +} \ No newline at end of file diff --git a/src/Driver/Driver.java b/src/Driver/Driver.java new file mode 100644 index 0000000..6366509 --- /dev/null +++ b/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 Guntur Fatmawan + */ +public class Driver { + public static void main (String[] args) { + Controller a = new Controller (); + } +} diff --git a/src/Gui/ComposeTweet.form b/src/Gui/ComposeTweet.form new file mode 100644 index 0000000..570e2f7 --- /dev/null +++ b/src/Gui/ComposeTweet.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/ComposeTweet.java b/src/Gui/ComposeTweet.java new file mode 100644 index 0000000..adb83ac --- /dev/null +++ b/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 Guntur Fatmawan + */ +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/src/Gui/FollowUser.form b/src/Gui/FollowUser.form new file mode 100644 index 0000000..d33c2a8 --- /dev/null +++ b/src/Gui/FollowUser.form @@ -0,0 +1,82 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/FollowUser.java b/src/Gui/FollowUser.java new file mode 100644 index 0000000..d18dc05 --- /dev/null +++ b/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 Guntur Fatmawan + */ +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/src/Gui/HomeTimeline.form b/src/Gui/HomeTimeline.form new file mode 100644 index 0000000..6e47fcc --- /dev/null +++ b/src/Gui/HomeTimeline.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/Gui/HomeTimeline.java b/src/Gui/HomeTimeline.java new file mode 100644 index 0000000..dda73ca --- /dev/null +++ b/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 Guntur Fatmawan + */ +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/src/Interface/View.java b/src/Interface/View.java new file mode 100644 index 0000000..53ce20f --- /dev/null +++ b/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/src/TwitterModel/TwitterModel.java b/src/TwitterModel/TwitterModel.java new file mode 100644 index 0000000..9d8f32e --- /dev/null +++ b/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 Guntur Fatmawan + */ +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); + } + } +} diff --git a/twitter4j-core-4.0.4.jar b/twitter4j-core-4.0.4.jar new file mode 100644 index 0000000..029abce Binary files /dev/null and b/twitter4j-core-4.0.4.jar differ diff --git a/twitter4j.properties.txt b/twitter4j.properties.txt new file mode 100644 index 0000000..a2b2cbf --- /dev/null +++ b/twitter4j.properties.txt @@ -0,0 +1,5 @@ +debug=true +oauth.consumerKey=5A3WCORLek8gjirMfC3HQxO8c +oauth.consumerSecret=0HfVFH5Y1c5ABdP3baJmIwJZlZJSEWr305JivQftHjoLC8v26b +oauth.accessToken=1157187974-IGMTiz5VrTaywGfi4g7aAECJMgJEjrnNUBCIWNE +oauth.accessTokenSecret=RKRofcDtV8QGcJ8zx1oQISZeE1IdgsPALBA4lrfoNo4v5 \ No newline at end of file