diff --git a/Task6/build.xml b/Task6/build.xml new file mode 100644 index 0000000..86075ca --- /dev/null +++ b/Task6/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Task6. + + + diff --git a/Task6/manifest.mf b/Task6/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/Task6/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Task6/nbproject/build-impl.xml b/Task6/nbproject/build-impl.xml new file mode 100644 index 0000000..ac7f89a --- /dev/null +++ b/Task6/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/Task6/nbproject/genfiles.properties b/Task6/nbproject/genfiles.properties new file mode 100644 index 0000000..443533b --- /dev/null +++ b/Task6/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/Task6/nbproject/private/config.properties b/Task6/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/Task6/nbproject/private/private.properties b/Task6/nbproject/private/private.properties new file mode 100644 index 0000000..c2dafb2 --- /dev/null +++ b/Task6/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=true +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=C:\\Users\\Alienware\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/Task6/nbproject/private/private.xml b/Task6/nbproject/private/private.xml new file mode 100644 index 0000000..8cbc88f --- /dev/null +++ b/Task6/nbproject/private/private.xml @@ -0,0 +1,12 @@ + + + + + + file:/E:/CLO3/Task6/Task6/src/task6/View.java + file:/E:/CLO3/Task6/Task6/src/task6/FollowUser.java + file:/E:/CLO3/Task6/Task6/src/task6/ComposeTweett.java + file:/E:/CLO3/Task6/Task6/src/task6/TwitterModel.java + + + diff --git a/Task6/nbproject/project.properties b/Task6/nbproject/project.properties new file mode 100644 index 0000000..af715e0 --- /dev/null +++ b/Task6/nbproject/project.properties @@ -0,0 +1,78 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=Task6 +application.vendor=MuRa23 +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 +endorsed.classpath= +excludes= +file.reference.twitter4j-core-4.0.1.zip=D:\\Tugas\\Task6\\twitter4j-core-4.0.1.zip +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.twitter4j-core-4.0.1.zip} +# 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=task6.Task6 +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/Task6/nbproject/project.xml b/Task6/nbproject/project.xml new file mode 100644 index 0000000..2e08c4c --- /dev/null +++ b/Task6/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Task6 + + + + + + + + + diff --git a/Task6/src/task6/ComposeTweett.form b/Task6/src/task6/ComposeTweett.form new file mode 100644 index 0000000..e03cdff --- /dev/null +++ b/Task6/src/task6/ComposeTweett.form @@ -0,0 +1,92 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Task6/src/task6/ComposeTweett.java b/Task6/src/task6/ComposeTweett.java new file mode 100644 index 0000000..b9df704 --- /dev/null +++ b/Task6/src/task6/ComposeTweett.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 task6; + +import java.awt.event.ActionListener; + +/** + * + * @author MuRa23 + */ +public class ComposeTweett extends javax.swing.JFrame implements View{ + + /** + * Creates new form ComposeTweett + */ + public ComposeTweett() { + initComponents(); + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + btnTweet = new javax.swing.JButton(); + btnCancel = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + txAreaTweet = new javax.swing.JTextArea(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setText("Compose new tweet"); + + btnTweet.setText("Tweet"); + btnTweet.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnTweetActionPerformed(evt); + } + }); + + btnCancel.setText("Cancel"); + + txAreaTweet.setColumns(20); + txAreaTweet.setRows(5); + jScrollPane1.setViewportView(txAreaTweet); + + 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(406, 406, 406) + .addComponent(btnTweet) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnCancel) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jScrollPane1) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnTweet) + .addComponent(btnCancel)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void btnTweetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTweetActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnTweetActionPerformed + + public Object getBtncancel(){ + return btnCancel; + } + + public Object getBtnTweet(){ + return btnTweet; + } + + public String getTweet(){ + return txAreaTweet.getText(); + } + + public void addListener(ActionListener e){ + btnTweet.addActionListener(e); + btnCancel.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.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTweet; + // End of variables declaration//GEN-END:variables +} diff --git a/Task6/src/task6/Controller.java b/Task6/src/task6/Controller.java new file mode 100644 index 0000000..ff3b204 --- /dev/null +++ b/Task6/src/task6/Controller.java @@ -0,0 +1,99 @@ +/* + * 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 task6; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JOptionPane; + +/** + * + * @author Alienware + */ +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() { + ComposeTweett compose = new ComposeTweett(); + 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 ComposeTweett){ + + ComposeTweett compose = (ComposeTweett) 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.followeUser(user); + follow.setUser(""); + } + } + }catch (Exception e) { + JOptionPane.showMessageDialog((Component) view, e.getMessage()); + } + } + } + diff --git a/Task6/src/task6/Driver.java b/Task6/src/task6/Driver.java new file mode 100644 index 0000000..09cd4fe --- /dev/null +++ b/Task6/src/task6/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. + */ +package task6; + +/** + * + * @author Alienware + */ +public class Driver { + public static void main(String[] args) { + Controller a = new Controller(); + } +} + diff --git a/Task6/src/task6/FollowUser.form b/Task6/src/task6/FollowUser.form new file mode 100644 index 0000000..4e4664e --- /dev/null +++ b/Task6/src/task6/FollowUser.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Task6/src/task6/FollowUser.java b/Task6/src/task6/FollowUser.java new file mode 100644 index 0000000..369513d --- /dev/null +++ b/Task6/src/task6/FollowUser.java @@ -0,0 +1,116 @@ +/* + * 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 task6; + +import java.awt.event.ActionListener; + +/** + * + * @author Alienware + */ +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(); + jScrollPane1 = new javax.swing.JScrollPane(); + txFieldUser = new javax.swing.JTextArea(); + btnFollow = new javax.swing.JButton(); + btnCancel = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setText("Follow User"); + + txFieldUser.setColumns(20); + txFieldUser.setRows(5); + jScrollPane1.setViewportView(txFieldUser); + + btnFollow.setText("Follow"); + + btnCancel.setText("Cancel"); + + 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() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(btnFollow) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 414, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1))) + .addContainerGap(27, Short.MAX_VALUE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(25, 25, 25) + .addComponent(btnCancel) + .addContainerGap(352, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnFollow) + .addGap(24, 24, 24)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(91, Short.MAX_VALUE) + .addComponent(btnCancel) + .addGap(22, 22, 22))) + ); + + pack(); + }// //GEN-END:initComponents + + 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.JScrollPane jScrollPane1; + private javax.swing.JTextArea txFieldUser; + // End of variables declaration//GEN-END:variables +} diff --git a/Task6/src/task6/HomeTimeline.form b/Task6/src/task6/HomeTimeline.form new file mode 100644 index 0000000..d508ef5 --- /dev/null +++ b/Task6/src/task6/HomeTimeline.form @@ -0,0 +1,107 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task6/src/task6/HomeTimeline.java b/Task6/src/task6/HomeTimeline.java new file mode 100644 index 0000000..23f162e --- /dev/null +++ b/Task6/src/task6/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 task6; + +import java.awt.event.ActionListener; + +/** + * + * @author MuRa23 + */ +public class HomeTimeline extends javax.swing.JFrame implements View{ + + /** + * Creates new form FollowUser + */ + 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(); + btnFollow = new javax.swing.JButton(); + btnRefresh = new javax.swing.JButton(); + btnExit = new javax.swing.JButton(); + btnCompose = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + txAreaTimeline.setColumns(20); + txAreaTimeline.setRows(5); + jScrollPane1.setViewportView(txAreaTimeline); + + btnFollow.setText("Follow User"); + + btnRefresh.setText("Refresh"); + + btnExit.setText("Exit"); + + btnCompose.setText("Compose"); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + jLabel1.setText("Home Timeline"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(147, Short.MAX_VALUE) + .addComponent(btnCompose) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnFollow) + .addGap(18, 18, 18) + .addComponent(btnRefresh) + .addGap(18, 18, 18) + .addComponent(btnExit) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnFollow) + .addComponent(btnRefresh) + .addComponent(btnExit) + .addComponent(btnCompose))) + ); + + pack(); + }// //GEN-END:initComponents + + 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.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTimeline; + // End of variables declaration//GEN-END:variables +} diff --git a/Task6/src/task6/TwitterModel.java b/Task6/src/task6/TwitterModel.java new file mode 100644 index 0000000..c2c436d --- /dev/null +++ b/Task6/src/task6/TwitterModel.java @@ -0,0 +1,61 @@ +/* + * 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 task6; + +/** + * + * @author MuRa23 + */ + +import twitter4j.*; +import java.util.List; +import javax.swing.JOptionPane; + +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 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 followeUser(String user){ + try { + twitter.createFriendship(user); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Judul Exception", "Pesan Exception",JOptionPane.ERROR_MESSAGE); + } +} + +} diff --git a/Task6/src/task6/View.java b/Task6/src/task6/View.java new file mode 100644 index 0000000..34be63d --- /dev/null +++ b/Task6/src/task6/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. + */ +package task6; + +import java.awt.event.ActionListener; + +/** + * + * @author MuRa23 + */ +public interface View { + public interface view { + public void addlistener (ActionListener e); + } +} diff --git a/twitter4j-core-4.0.1.zip b/twitter4j-core-4.0.1.zip new file mode 100644 index 0000000..fbbd6d7 Binary files /dev/null and b/twitter4j-core-4.0.1.zip differ diff --git a/twitter4j.properties.txt b/twitter4j.properties.txt new file mode 100644 index 0000000..8269ecd --- /dev/null +++ b/twitter4j.properties.txt @@ -0,0 +1,5 @@ +debug=true +oauth.consumerKey=chbJDmu6opsjCKCiIULjua9Xn +oauth.consumerSecret=IHdD4aQCJtnKnhHMSTpW51xufj3APVzQpZr1jd91OMA7xeDTfD +oauth.accessToken=865911713811410944-Kco4Bkljey9rzDEKQuWrcTVJAw9b3WC +oauth.accessTokenSecret=RjPdD9Q2R9T1ETcNaABpBOozIhqR12TVVAgXy1hLrj88y \ No newline at end of file