diff --git a/Twitter/build.xml b/Twitter/build.xml new file mode 100644 index 0000000..731b433 --- /dev/null +++ b/Twitter/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Twitter. + + + diff --git a/Twitter/build/classes/.netbeans_automatic_build b/Twitter/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/Twitter/build/classes/.netbeans_update_resources b/Twitter/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/Twitter/build/classes/ComposeTweet.class b/Twitter/build/classes/ComposeTweet.class new file mode 100644 index 0000000..d3f2191 Binary files /dev/null and b/Twitter/build/classes/ComposeTweet.class differ diff --git a/Twitter/build/classes/ComposeTweet.form b/Twitter/build/classes/ComposeTweet.form new file mode 100644 index 0000000..7a48d99 --- /dev/null +++ b/Twitter/build/classes/ComposeTweet.form @@ -0,0 +1,126 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Twitter/build/classes/Controller.class b/Twitter/build/classes/Controller.class new file mode 100644 index 0000000..1533b81 Binary files /dev/null and b/Twitter/build/classes/Controller.class differ diff --git a/Twitter/build/classes/Driver.class b/Twitter/build/classes/Driver.class new file mode 100644 index 0000000..09f1787 Binary files /dev/null and b/Twitter/build/classes/Driver.class differ diff --git a/Twitter/build/classes/FollowUser$1.class b/Twitter/build/classes/FollowUser$1.class new file mode 100644 index 0000000..5f8b077 Binary files /dev/null and b/Twitter/build/classes/FollowUser$1.class differ diff --git a/Twitter/build/classes/FollowUser.class b/Twitter/build/classes/FollowUser.class new file mode 100644 index 0000000..1b7c1d1 Binary files /dev/null and b/Twitter/build/classes/FollowUser.class differ diff --git a/Twitter/build/classes/FollowUser.form b/Twitter/build/classes/FollowUser.form new file mode 100644 index 0000000..908bd0a --- /dev/null +++ b/Twitter/build/classes/FollowUser.form @@ -0,0 +1,108 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Twitter/build/classes/HomeTimeline$1.class b/Twitter/build/classes/HomeTimeline$1.class new file mode 100644 index 0000000..6b9065e Binary files /dev/null and b/Twitter/build/classes/HomeTimeline$1.class differ diff --git a/Twitter/build/classes/HomeTimeline.class b/Twitter/build/classes/HomeTimeline.class new file mode 100644 index 0000000..59da750 Binary files /dev/null and b/Twitter/build/classes/HomeTimeline.class differ diff --git a/Twitter/build/classes/HomeTimeline.form b/Twitter/build/classes/HomeTimeline.form new file mode 100644 index 0000000..7808548 --- /dev/null +++ b/Twitter/build/classes/HomeTimeline.form @@ -0,0 +1,127 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Twitter/build/classes/TwitterModel.class b/Twitter/build/classes/TwitterModel.class new file mode 100644 index 0000000..bb2a7b7 Binary files /dev/null and b/Twitter/build/classes/TwitterModel.class differ diff --git a/Twitter/build/classes/View.class b/Twitter/build/classes/View.class new file mode 100644 index 0000000..afa01e6 Binary files /dev/null and b/Twitter/build/classes/View.class differ diff --git a/Twitter/manifest.mf b/Twitter/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/Twitter/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Twitter/nbproject/build-impl.xml b/Twitter/nbproject/build-impl.xml new file mode 100644 index 0000000..a36d93e --- /dev/null +++ b/Twitter/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/Twitter/nbproject/genfiles.properties b/Twitter/nbproject/genfiles.properties new file mode 100644 index 0000000..a764cfe --- /dev/null +++ b/Twitter/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=951f4296 +build.xml.script.CRC32=32a78edb +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=951f4296 +nbproject/build-impl.xml.script.CRC32=ea0f1bc6 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/Twitter/nbproject/private/private.properties b/Twitter/nbproject/private/private.properties new file mode 100644 index 0000000..7dc5a09 --- /dev/null +++ b/Twitter/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\GL552JX\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/Twitter/nbproject/private/private.xml b/Twitter/nbproject/private/private.xml new file mode 100644 index 0000000..d8b4c8e --- /dev/null +++ b/Twitter/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/C:/Users/GL552JX/Desktop/PBO_1301154255_RizkiAuliaZuhri_Task2/Twitter/src/Controller.java + + + diff --git a/Twitter/nbproject/project.properties b/Twitter/nbproject/project.properties new file mode 100644 index 0000000..c111f32 --- /dev/null +++ b/Twitter/nbproject/project.properties @@ -0,0 +1,76 @@ +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}/Twitter.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.twitter4j-core-4.0.4.jar=twitter4j-core-4.0.4.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.twitter4j-core-4.0.4.jar} +# 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 +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/Twitter/nbproject/project.xml b/Twitter/nbproject/project.xml new file mode 100644 index 0000000..1be1ebe --- /dev/null +++ b/Twitter/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Twitter + + + + + + + + + diff --git a/Twitter/src/ComposeTweet.form b/Twitter/src/ComposeTweet.form new file mode 100644 index 0000000..7a48d99 --- /dev/null +++ b/Twitter/src/ComposeTweet.form @@ -0,0 +1,126 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Twitter/src/ComposeTweet.java b/Twitter/src/ComposeTweet.java new file mode 100644 index 0000000..d6d3a5c --- /dev/null +++ b/Twitter/src/ComposeTweet.java @@ -0,0 +1,138 @@ + +import java.awt.event.ActionListener; +import javax.swing.JButton; + +/* + * 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. + */ + +/** + * + * @author GL552JX + */ +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() { + + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + txAreaTweet = new javax.swing.JTextArea(); + jLabel1 = new javax.swing.JLabel(); + btnTweet = new javax.swing.JButton(); + btnCancel = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + txAreaTweet.setColumns(20); + txAreaTweet.setRows(5); + jScrollPane1.setViewportView(txAreaTweet); + + jLabel1.setText("Compose new Tweet..."); + + btnTweet.setText("Tweet"); + + btnCancel.setText("cancel"); + + jLabel2.setText("140"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 186, Short.MAX_VALUE) + .addComponent(btnCancel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnTweet))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(16, 16, 16) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnTweet) + .addComponent(btnCancel) + .addComponent(jLabel2)) + .addContainerGap()) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(28, 28, 28) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + + + 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); + + } + + // 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.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTweet; + // End of variables declaration//GEN-END:variables +} diff --git a/Twitter/src/Controller.java b/Twitter/src/Controller.java new file mode 100644 index 0000000..d8aa80f --- /dev/null +++ b/Twitter/src/Controller.java @@ -0,0 +1,98 @@ + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JOptionPane; + + +/* + * 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. + */ + +/** + * + * @author GL552JX + */ +public class Controller implements ActionListener { + private TwitterModel model; + private View view; + + public void goToHomeTimeline(){ + HomeTimeline home = new HomeTimeline(); + home.setVisible(true); + home.addListener(this); + home.setTimeline(model.getHomeTimeline()); + view = home; + } + + public void goToComposeTweet(){ + ComposeTweet compose = new ComposeTweet(); + compose.setVisible(true); + compose.addListener(this); + view = compose; + } + + public void goToFollowUser(){ + FollowUser follow = new FollowUser(); + follow.setVisible(true); + follow.addListener(this); + view = follow; + } + + public Controller() { + model = new TwitterModel(); + goToHomeTimeline(); + } + + + public void actionPerformed(ActionEvent ae){ + Object source = ae.getSource(); + + 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 if (view instanceof FollowUser){ + + 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(""); + } + } + } + +} \ No newline at end of file diff --git a/Twitter/src/Driver.java b/Twitter/src/Driver.java new file mode 100644 index 0000000..b853ac9 --- /dev/null +++ b/Twitter/src/Driver.java @@ -0,0 +1,17 @@ +/* + * 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. + */ + +/** + * + * @author GL552JX + */ +public class Driver { + + public static void main(String[] args) { + Controller controller = new Controller(); + } + +} diff --git a/Twitter/src/FollowUser.form b/Twitter/src/FollowUser.form new file mode 100644 index 0000000..908bd0a --- /dev/null +++ b/Twitter/src/FollowUser.form @@ -0,0 +1,108 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Twitter/src/FollowUser.java b/Twitter/src/FollowUser.java new file mode 100644 index 0000000..8cf0522 --- /dev/null +++ b/Twitter/src/FollowUser.java @@ -0,0 +1,135 @@ + +import java.awt.event.ActionListener; +import javax.swing.JButton; + +/* + * 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. + */ + +/** + * + * @author GL552JX + */ +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() { + + jPanel1 = new javax.swing.JPanel(); + txFieldUser = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + btnCancel = new javax.swing.JButton(); + btnFollow = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + txFieldUser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txFieldUserActionPerformed(evt); + } + }); + + jLabel1.setText("Follow User"); + + btnCancel.setText("Cancel"); + + btnFollow.setText("Follow"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txFieldUser) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(btnCancel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 212, Short.MAX_VALUE) + .addComponent(btnFollow))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(25, 25, 25) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCancel) + .addComponent(btnFollow)) + .addContainerGap(20, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(35, 35, 35) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void txFieldUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txFieldUserActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_txFieldUserActionPerformed + + 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); + } + // 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.JPanel jPanel1; + private javax.swing.JTextField txFieldUser; + // End of variables declaration//GEN-END:variables +} diff --git a/Twitter/src/HomeTimeline.form b/Twitter/src/HomeTimeline.form new file mode 100644 index 0000000..7808548 --- /dev/null +++ b/Twitter/src/HomeTimeline.form @@ -0,0 +1,127 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Twitter/src/HomeTimeline.java b/Twitter/src/HomeTimeline.java new file mode 100644 index 0000000..221c65c --- /dev/null +++ b/Twitter/src/HomeTimeline.java @@ -0,0 +1,160 @@ +/* + * 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. + */ + + +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JTextArea; + +/** + * + * @author GL552JX + */ +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() { + + jPanel1 = new javax.swing.JPanel(); + 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"); + btnCompose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnComposeActionPerformed(evt); + } + }); + + btnFollow.setText("Follow User"); + + btnRefresh.setText("Refresh"); + + btnExit.setText("Exit"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(btnCompose) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(btnFollow) + .addGap(13, 13, 13) + .addComponent(btnRefresh) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(btnExit, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCompose) + .addComponent(btnFollow) + .addComponent(btnRefresh) + .addComponent(btnExit)) + .addContainerGap()) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void btnComposeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnComposeActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnComposeActionPerformed + + + 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); + } + + + + // 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.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTimeline; + // End of variables declaration//GEN-END:variables + + +} diff --git a/Twitter/src/TwitterModel.java b/Twitter/src/TwitterModel.java new file mode 100644 index 0000000..8f0c503 --- /dev/null +++ b/Twitter/src/TwitterModel.java @@ -0,0 +1,68 @@ +/* + * 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. + */ + + +import twitter4j.*; +import java.util.List; +import javax.swing.JOptionPane; + + +/** + * + * @author GL552JX + */ +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 (TwitterException ex) { + 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 (TwitterException ex) { + JOptionPane.showMessageDialog(null, "judul exception", + "pesan exception", JOptionPane.ERROR_MESSAGE); + } + } + + +} diff --git a/Twitter/src/View.java b/Twitter/src/View.java new file mode 100644 index 0000000..f0fcd7d --- /dev/null +++ b/Twitter/src/View.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. + */ + + +import java.awt.event.ActionListener; + +/** + * + * @author GL552JX + */ +public interface View { + + public void addListener(ActionListener e); + +} diff --git a/Twitter/twitter4j-core-4.0.4.jar b/Twitter/twitter4j-core-4.0.4.jar new file mode 100644 index 0000000..029abce Binary files /dev/null and b/Twitter/twitter4j-core-4.0.4.jar differ