diff --git a/Task_6-master/README.md b/Task_6-master/README.md new file mode 100644 index 0000000..5c27eef --- /dev/null +++ b/Task_6-master/README.md @@ -0,0 +1,211 @@ +# Task_6 +Exercise on API using Twitter4J + +## Aplikasi Java Twitter +Buatlah aplikasi java twitter yaitu aplikasi yang untuk mengakses social media twitter melaui apikasi java. Aplikasi java twitter ini memiliki spesifikasi sebagai berikut + +### 0. Twitter OAuth Token +* log in ke akun Twitter +* buka halaman [apps.twitter.com] (apps.twitter.com) +* buatlag aplikasi baru dengan mengekklik create new App
+![a01](https://cloud.githubusercontent.com/assets/13241336/26094915/eb49062a-3a45-11e7-9301-5fb7853a8c81.PNG)
+* tuliskan nama dan deskripsi aplikasi, tuliskan website aplikasi (jika ada) atau tuliskan alamat URL akun Twitter masing-masing
+![a02](https://cloud.githubusercontent.com/assets/13241336/26094917/eb6f85f2-3a45-11e7-84e3-8ac7be0c3904.PNG)
+* check Developer Agreement, dan klik Create your Twitter application
+![a03](https://cloud.githubusercontent.com/assets/13241336/26094916/eb5df760-3a45-11e7-8b8e-5ab83a152678.PNG)
+* setelah aplikasi dibuat, navigasikan ke tab Keys and Access Tokens +* akan terlihat 25-character Consumer Key dan 50-character Consumer Secret aplikasi yang baru dibuat
+![a04](https://cloud.githubusercontent.com/assets/13241336/26094918/eb81127c-3a45-11e7-87ad-129ccaa57bab.PNG)
+* scroll down dan klik create your new access token
+![a05](https://cloud.githubusercontent.com/assets/13241336/26094920/eb8e3236-3a45-11e7-9914-f0b46e0e7b5f.PNG)
+* akan terlihat 49-digit-dash-character Access Token dan 45-character Access Token Secret
+![a06](https://cloud.githubusercontent.com/assets/13241336/26094921/eb8f657a-3a45-11e7-96d4-d6dc7452b194.PNG)
+* buatlah sebuah file text dengan filename twitter4j.properties
+![a07](https://cloud.githubusercontent.com/assets/13241336/26094919/eb8dcd3c-3a45-11e7-8dab-1ac66ea75be8.PNG)
+* tuliskan Consumer Key, Consumer Secret, Access Token, and Access Token Secret ke dalam twitter4j.properties sebagai berikut
+![a08](https://cloud.githubusercontent.com/assets/13241336/26094922/eb9884ac-3a45-11e7-94c0-135f0cdb9f69.PNG)
+* twitter4j.properties telah terdaftar di dalam .gitignore, sehingga file twitter4j.properties tidak akan disinkronisasikan (push) ke repositori +* see more [here] (https://dev.twitter.com/oauth/overview/application-owner-access-tokens) + + +### 1. TwitterModel.java +* download library for Twitter API dari [Twitter4J] (http://twitter4j.org) +* temukan lib jar twitter4j-core-4.0.1.jar +* Buatlah sebuah project NetBeans +* Copy kan library twitter4j-core-4.0.1.jar dan twitter4j.properties pada folder project anda +* Tambahkan (add) seluruh library tersebut pada project NetBeans Anda +* Buatlah sebuah kelas dengan nama TwitterModel.java dengan spesifikasi sbb:
+ +![01](https://cloud.githubusercontent.com/assets/13241336/26094875/e9e65382-3a45-11e7-84ae-de47cc5a864d.PNG)
+* Tambahkan import twitter4j
+![02](https://cloud.githubusercontent.com/assets/13241336/26094878/e9f02ba0-3a45-11e7-9b3b-085560d27c93.PNG)
+* Terdapat sebuah variable private Twitter dengan nama twitter + +* a. Constructor TwitterModel + * Constructor akan menginstansiasi object twitter
+![03](https://cloud.githubusercontent.com/assets/13241336/26094874/e9e5a720-3a45-11e7-8569-a7f108056a0c.PNG)
+ +* b. Method tweetStatus ( tweet : String ) + * lakukan syntax berikut di dalam blok try-catch + * Method akan mengirimkan String tweet ke akun twitter
+![04](https://cloud.githubusercontent.com/assets/13241336/26094876/e9ea1cb0-3a45-11e7-85ce-f067047c45fc.PNG)
+ * Tampilkan pesan status berhasil diposting dengan
+![05](https://cloud.githubusercontent.com/assets/13241336/26094877/e9ee986c-3a45-11e7-9617-f5fa2881f6bd.PNG)
+ * tambahkan pesan di blok catch untuk menampilkan pesan error
+![06](https://cloud.githubusercontent.com/assets/13241336/26094879/e9f38200-3a45-11e7-975b-b66b137c80d3.PNG)
+ +* c. Method getHomeTimeline() : String + * lakukan syntax berikut di dalam blok try-catch + * Method akan mengambil tweet yang ada pada home timeline dan mengembalikan isi String s
+![07](https://cloud.githubusercontent.com/assets/13241336/26094880/ea163020-3a45-11e7-8a95-66984970647c.PNG)
+ * tambahkan pesan di blok catch untuk menampilkan pesan error
![06](https://cloud.githubusercontent.com/assets/13241336/26094879/e9f38200-3a45-11e7-975b-b66b137c80d3.PNG)
+ * jika terjadi error, method akan mengembalikan nilai null + +* d. Method followUser ( user : String ) + * lakukan syntax berikut di dalam blok try-catch + * Method akan membuat akun memfollow sebuah akun twitter dengan syntax
+![08](https://cloud.githubusercontent.com/assets/13241336/26094881/ea180206-3a45-11e7-8497-a82cf7ec480a.PNG)
+ * tambahkan pesan di blok catch untuk menampilkan pesan error
![06](https://cloud.githubusercontent.com/assets/13241336/26094879/e9f38200-3a45-11e7-975b-b66b137c80d3.PNG)
+ +### 2. interface View.java +* terdapat method abstrak addListener
+![18](https://cloud.githubusercontent.com/assets/13241336/26094891/ea72b552-3a45-11e7-96a6-0185fc25308b.PNG)
+ +### 3. HomeTimeline.java +Buatlah class JFrame HomeTimeline.java dengan tampilan sebagai berikut
+![09](https://cloud.githubusercontent.com/assets/13241336/26094882/ea1bd4da-3a45-11e7-94cc-f66ac2f8a135.PNG)
+* terdapat komponen : + * JTextArea : txAreaTimeline, set Editable = false + * JButton : btnCompose, btnFollow, btnRefresh, btnExit +* kelas mengimplementasikan interface View +* hapus main method (psvm) di dalam GUI +* tambahkan method getter objek untuk mengembalikan setiap objek button
+![10](https://cloud.githubusercontent.com/assets/13241336/26094884/ea25431c-3a45-11e7-9ecc-28e3f119cb8b.PNG)
+* tambahkan method setTimeline untuk mengeset String pada text area Timeline
+![11](https://cloud.githubusercontent.com/assets/13241336/26094883/ea1f41ec-3a45-11e7-99fd-43693349c0ff.PNG)
+* tambahkan add listener pada setiap tombol dengan memanggil method addActionListener
+![12](https://cloud.githubusercontent.com/assets/13241336/26094885/ea26728c-3a45-11e7-9875-b3132271e3a4.PNG)
+ +### 4. ComposeTweet.java +Buatlah class JFrame ComposeTweet.java dengan tampilan sebagai berikut
+![13](https://cloud.githubusercontent.com/assets/13241336/26094887/ea4a0986-3a45-11e7-8114-101753a1dec7.PNG)
+* terdapat komponen : + * JTextArea : txAreaTweet + * JButton : btnCancel, btnTweet +* kelas mengimplementasikan interface View +* hapus main method (psvm) di dalam GUI +* tambahkan method getter objek untuk mengembalikan setiap objek button
+![14](https://cloud.githubusercontent.com/assets/13241336/26094886/ea47d86e-3a45-11e7-9bd8-0956d54bdb53.PNG)
+* tambahkan method getTweet untuk mengambil String pada text area Tweet
+![15](https://cloud.githubusercontent.com/assets/13241336/26094889/ea607770-3a45-11e7-961a-6b3de6612053.PNG)
+* tambahkan add listener pada setiap tombol dengan memanggil method addActionListener
+![17](https://cloud.githubusercontent.com/assets/13241336/26094893/ea7a94ac-3a45-11e7-8e7b-728e26590de4.PNG)
+ +### 5. FollowUser.java +Buatlah class JFrame FollowUser.java dengan tampilan sebagai berikut
+![19](https://cloud.githubusercontent.com/assets/13241336/26094892/ea7aafdc-3a45-11e7-9d53-8ca2d513a8cd.PNG)
+* terdapat komponen : + * JTextField : txFieldUser + * JButton : btnCancel, btnFollow +* kelas mengimplementasikan interface View +* hapus main method (psvm) di dalam GUI +* tambahkan method getter objek untuk mengembalikan setiap objek button
+![20](https://cloud.githubusercontent.com/assets/13241336/26094894/ea8a6652-3a45-11e7-9486-ddb36ee77d0e.PNG)
+* tambahkan method getUser untuk mengambil String pada text area User
+![21](https://cloud.githubusercontent.com/assets/13241336/26094895/ea9395e2-3a45-11e7-81a1-abcf0d57d234.PNG)
+* tambahkan method setUser untuk mengeset String pada text area User
+![22](https://cloud.githubusercontent.com/assets/13241336/26094897/eaaa2bcc-3a45-11e7-9d59-e3c8bace715b.PNG)
+* tambahkan add listener pada setiap tombol dengan memanggil method addActionListener
+![23](https://cloud.githubusercontent.com/assets/13241336/26094896/eaa76392-3a45-11e7-9b27-2ca67c7a0938.PNG)
+ + +### 6. Controller.java +Buatlah class Controller.java sesuai class diagram berikut
+![24](https://cloud.githubusercontent.com/assets/13241336/26094898/eaac9b46-3a45-11e7-8004-26c5b08f44a7.PNG)
+* kelas Controller implements ActionListener +* implementasikan method actionPerformed(ActionEvent ae) + +#### a. Method goToHomeTimeline() +* method menginstansiasi gui HomeTimeline +* set visible view = true +* set lisener view dengan controller this +* set view = objek gui HomeTimeline
+* method mengeset text area timeline dengan String yang diambil dari getHomeTimeline dari model
+![25](https://cloud.githubusercontent.com/assets/13241336/26094899/eaae39b0-3a45-11e7-8a2a-38d048686cb3.PNG)
+ +#### b. Method goToComposeTweet() +* method menginstansiasi gui ComposeTweet +* set visible view = true +* set lisener view dengan controller this +* set view = objek gui ComposeTweet
+![26](https://cloud.githubusercontent.com/assets/13241336/26094900/eab9f3d6-3a45-11e7-8207-a33e54cd1190.PNG)
+ +#### c. Method goToFollowUser() +* method menginstansiasi gui FollowUser +* set visible view = true +* set lisener view dengan controller this +* set view = objek gui FollowUser
+![27](https://cloud.githubusercontent.com/assets/13241336/26094901/eac1fafe-3a45-11e7-994f-32676433f27e.PNG)
+ +#### d. Constructor Controller() +* Constructor menginstansiasi TwitterModel model +* Constructor memanggil method goToHomeTimeline
+![28](https://cloud.githubusercontent.com/assets/13241336/26094902/eada4ca8-3a45-11e7-9452-725060d191ca.PNG)
+ +#### e. Method actionPerformed(ActionEvent ae) +* get Object source action event
+![29](https://cloud.githubusercontent.com/assets/13241336/26094903/eade6766-3a45-11e7-98f8-c76b3c8a5be9.PNG)
+* cek current view +* jika view merupakan HomeTimeline : + * Downcast view
+![30](https://cloud.githubusercontent.com/assets/13241336/26094907/eafceee8-3a45-11e7-9a86-a4bc330c1503.PNG)
+ * cek source action event + * jika event berasal dari btnCompose : + * panggil method goToComposeTweet() + * dispose view home + * ![31](https://cloud.githubusercontent.com/assets/13241336/26094904/eae01b9c-3a45-11e7-84e3-6f2ca0caa1ba.PNG) + * jika event berasal dari btnFollow : + * panggil method goToFollowUser() + * dispose view home + * ![32](https://cloud.githubusercontent.com/assets/13241336/26094906/eaf04a76-3a45-11e7-816a-eae036f848cf.PNG) + * jika event berasal dari btnRefresh : + * set text area timeline dengan String yang diambil dari getHomeTimeline dari model + * ![33](https://cloud.githubusercontent.com/assets/13241336/26094905/eaf0369e-3a45-11e7-8c70-4767ff8c1788.PNG) + * jika event berasal dari btnExit : + * tampilkan pesan + * hentikan program + * ![34](https://cloud.githubusercontent.com/assets/13241336/26094913/eb3e9f6e-3a45-11e7-9749-ef05b39da0e3.PNG) + +* jika view merupakan ComposeTweet : + * Downcast view
![35](https://cloud.githubusercontent.com/assets/13241336/26094908/eb0d0300-3a45-11e7-8c40-285073974821.PNG)
+ * cek source action event + * jika event berasal dari btnCancel : + * panggil method goToHomeTimeline + * dispose view compose + * ![36](https://cloud.githubusercontent.com/assets/13241336/26094909/eb157ff8-3a45-11e7-94a3-ce4845170b4e.PNG) + + * jika event berasal dari btnTweet : + * ambil String status tweet dari text area tweet + * post status tweet dengan memanggil method tweetStatus dari objek model + * panggil method goToHomeTimeline + * dispose view compose + * ![37](https://cloud.githubusercontent.com/assets/13241336/26094910/eb21b1e2-3a45-11e7-9aac-0d29fb7224d9.PNG) + +* jika view merupakan FollowUser : + * Downcast view
![38](https://cloud.githubusercontent.com/assets/13241336/26094911/eb2484c6-3a45-11e7-93d2-392cab7c7034.PNG)
+ * cek source action event + * jika event berasal dari btnCancel : + * panggil method goToHomeTimeline + * dispose view follow + * ![39](https://cloud.githubusercontent.com/assets/13241336/26094912/eb2e9196-3a45-11e7-801d-b4d14c83e679.PNG) + + * jika event berasal dari btnFollow : + * ambil String user dari text field user + * follow user dengan memanggil method followUser dari objek model + * kosongkan text field user + * ![40](https://cloud.githubusercontent.com/assets/13241336/26094914/eb46ec5a-3a45-11e7-8797-9c26f6465f49.PNG) + +### 7. Driver.java +* Buatlah class Driver.java yang memiliki main method (psvm) +* instansiasi objek Controller() +* cobalah aplikasi Java Twitter yang telah dibuat diff --git a/Task_6-master/asset/01.PNG b/Task_6-master/asset/01.PNG new file mode 100644 index 0000000..1c5722c Binary files /dev/null and b/Task_6-master/asset/01.PNG differ diff --git a/Task_6-master/asset/02.PNG b/Task_6-master/asset/02.PNG new file mode 100644 index 0000000..16aa305 Binary files /dev/null and b/Task_6-master/asset/02.PNG differ diff --git a/Task_6-master/asset/03.PNG b/Task_6-master/asset/03.PNG new file mode 100644 index 0000000..52a2f16 Binary files /dev/null and b/Task_6-master/asset/03.PNG differ diff --git a/Task_6-master/asset/04.PNG b/Task_6-master/asset/04.PNG new file mode 100644 index 0000000..18300d3 Binary files /dev/null and b/Task_6-master/asset/04.PNG differ diff --git a/Task_6-master/asset/05.PNG b/Task_6-master/asset/05.PNG new file mode 100644 index 0000000..a815368 Binary files /dev/null and b/Task_6-master/asset/05.PNG differ diff --git a/Task_6-master/asset/06.PNG b/Task_6-master/asset/06.PNG new file mode 100644 index 0000000..0bace3b Binary files /dev/null and b/Task_6-master/asset/06.PNG differ diff --git a/Task_6-master/asset/07.PNG b/Task_6-master/asset/07.PNG new file mode 100644 index 0000000..e1765cf Binary files /dev/null and b/Task_6-master/asset/07.PNG differ diff --git a/Task_6-master/asset/08.PNG b/Task_6-master/asset/08.PNG new file mode 100644 index 0000000..6904d54 Binary files /dev/null and b/Task_6-master/asset/08.PNG differ diff --git a/Task_6-master/asset/09.PNG b/Task_6-master/asset/09.PNG new file mode 100644 index 0000000..8d4d77d Binary files /dev/null and b/Task_6-master/asset/09.PNG differ diff --git a/Task_6-master/asset/10.PNG b/Task_6-master/asset/10.PNG new file mode 100644 index 0000000..41c5a85 Binary files /dev/null and b/Task_6-master/asset/10.PNG differ diff --git a/Task_6-master/asset/11.PNG b/Task_6-master/asset/11.PNG new file mode 100644 index 0000000..ccfd768 Binary files /dev/null and b/Task_6-master/asset/11.PNG differ diff --git a/Task_6-master/asset/12.PNG b/Task_6-master/asset/12.PNG new file mode 100644 index 0000000..766dd12 Binary files /dev/null and b/Task_6-master/asset/12.PNG differ diff --git a/Task_6-master/asset/13.PNG b/Task_6-master/asset/13.PNG new file mode 100644 index 0000000..c9cd362 Binary files /dev/null and b/Task_6-master/asset/13.PNG differ diff --git a/Task_6-master/asset/14.PNG b/Task_6-master/asset/14.PNG new file mode 100644 index 0000000..710e054 Binary files /dev/null and b/Task_6-master/asset/14.PNG differ diff --git a/Task_6-master/asset/15.PNG b/Task_6-master/asset/15.PNG new file mode 100644 index 0000000..6e3929f Binary files /dev/null and b/Task_6-master/asset/15.PNG differ diff --git a/Task_6-master/asset/16.PNG b/Task_6-master/asset/16.PNG new file mode 100644 index 0000000..f58807d Binary files /dev/null and b/Task_6-master/asset/16.PNG differ diff --git a/Task_6-master/asset/17.PNG b/Task_6-master/asset/17.PNG new file mode 100644 index 0000000..f8274a9 Binary files /dev/null and b/Task_6-master/asset/17.PNG differ diff --git a/Task_6-master/asset/18.PNG b/Task_6-master/asset/18.PNG new file mode 100644 index 0000000..7ca8c29 Binary files /dev/null and b/Task_6-master/asset/18.PNG differ diff --git a/Task_6-master/asset/19.PNG b/Task_6-master/asset/19.PNG new file mode 100644 index 0000000..b4aad34 Binary files /dev/null and b/Task_6-master/asset/19.PNG differ diff --git a/Task_6-master/asset/20.PNG b/Task_6-master/asset/20.PNG new file mode 100644 index 0000000..b09c4ad Binary files /dev/null and b/Task_6-master/asset/20.PNG differ diff --git a/Task_6-master/asset/21.PNG b/Task_6-master/asset/21.PNG new file mode 100644 index 0000000..0120435 Binary files /dev/null and b/Task_6-master/asset/21.PNG differ diff --git a/Task_6-master/asset/22.PNG b/Task_6-master/asset/22.PNG new file mode 100644 index 0000000..452e24e Binary files /dev/null and b/Task_6-master/asset/22.PNG differ diff --git a/Task_6-master/asset/23.PNG b/Task_6-master/asset/23.PNG new file mode 100644 index 0000000..938eb8e Binary files /dev/null and b/Task_6-master/asset/23.PNG differ diff --git a/Task_6-master/asset/24.PNG b/Task_6-master/asset/24.PNG new file mode 100644 index 0000000..c50aab8 Binary files /dev/null and b/Task_6-master/asset/24.PNG differ diff --git a/Task_6-master/asset/25.PNG b/Task_6-master/asset/25.PNG new file mode 100644 index 0000000..0f51fe0 Binary files /dev/null and b/Task_6-master/asset/25.PNG differ diff --git a/Task_6-master/asset/26.PNG b/Task_6-master/asset/26.PNG new file mode 100644 index 0000000..49180be Binary files /dev/null and b/Task_6-master/asset/26.PNG differ diff --git a/Task_6-master/asset/27.PNG b/Task_6-master/asset/27.PNG new file mode 100644 index 0000000..cec513a Binary files /dev/null and b/Task_6-master/asset/27.PNG differ diff --git a/Task_6-master/asset/28.PNG b/Task_6-master/asset/28.PNG new file mode 100644 index 0000000..de9041f Binary files /dev/null and b/Task_6-master/asset/28.PNG differ diff --git a/Task_6-master/asset/29.PNG b/Task_6-master/asset/29.PNG new file mode 100644 index 0000000..c469e70 Binary files /dev/null and b/Task_6-master/asset/29.PNG differ diff --git a/Task_6-master/asset/30.PNG b/Task_6-master/asset/30.PNG new file mode 100644 index 0000000..a5248ae Binary files /dev/null and b/Task_6-master/asset/30.PNG differ diff --git a/Task_6-master/asset/31.PNG b/Task_6-master/asset/31.PNG new file mode 100644 index 0000000..4fa2847 Binary files /dev/null and b/Task_6-master/asset/31.PNG differ diff --git a/Task_6-master/asset/32.PNG b/Task_6-master/asset/32.PNG new file mode 100644 index 0000000..c693506 Binary files /dev/null and b/Task_6-master/asset/32.PNG differ diff --git a/Task_6-master/asset/33.PNG b/Task_6-master/asset/33.PNG new file mode 100644 index 0000000..fb286c9 Binary files /dev/null and b/Task_6-master/asset/33.PNG differ diff --git a/Task_6-master/asset/34.PNG b/Task_6-master/asset/34.PNG new file mode 100644 index 0000000..3f17d0e Binary files /dev/null and b/Task_6-master/asset/34.PNG differ diff --git a/Task_6-master/asset/35.PNG b/Task_6-master/asset/35.PNG new file mode 100644 index 0000000..7b785ce Binary files /dev/null and b/Task_6-master/asset/35.PNG differ diff --git a/Task_6-master/asset/36.PNG b/Task_6-master/asset/36.PNG new file mode 100644 index 0000000..f1f8847 Binary files /dev/null and b/Task_6-master/asset/36.PNG differ diff --git a/Task_6-master/asset/37.PNG b/Task_6-master/asset/37.PNG new file mode 100644 index 0000000..9ba5e80 Binary files /dev/null and b/Task_6-master/asset/37.PNG differ diff --git a/Task_6-master/asset/38.PNG b/Task_6-master/asset/38.PNG new file mode 100644 index 0000000..f714f3d Binary files /dev/null and b/Task_6-master/asset/38.PNG differ diff --git a/Task_6-master/asset/39.PNG b/Task_6-master/asset/39.PNG new file mode 100644 index 0000000..90fa807 Binary files /dev/null and b/Task_6-master/asset/39.PNG differ diff --git a/Task_6-master/asset/40.PNG b/Task_6-master/asset/40.PNG new file mode 100644 index 0000000..ac28aac Binary files /dev/null and b/Task_6-master/asset/40.PNG differ diff --git a/Task_6-master/asset/a01.PNG b/Task_6-master/asset/a01.PNG new file mode 100644 index 0000000..11f0d94 Binary files /dev/null and b/Task_6-master/asset/a01.PNG differ diff --git a/Task_6-master/asset/a02.PNG b/Task_6-master/asset/a02.PNG new file mode 100644 index 0000000..2bf0119 Binary files /dev/null and b/Task_6-master/asset/a02.PNG differ diff --git a/Task_6-master/asset/a03.PNG b/Task_6-master/asset/a03.PNG new file mode 100644 index 0000000..b72d00e Binary files /dev/null and b/Task_6-master/asset/a03.PNG differ diff --git a/Task_6-master/asset/a04.PNG b/Task_6-master/asset/a04.PNG new file mode 100644 index 0000000..a502558 Binary files /dev/null and b/Task_6-master/asset/a04.PNG differ diff --git a/Task_6-master/asset/a05.PNG b/Task_6-master/asset/a05.PNG new file mode 100644 index 0000000..161dbf4 Binary files /dev/null and b/Task_6-master/asset/a05.PNG differ diff --git a/Task_6-master/asset/a06.PNG b/Task_6-master/asset/a06.PNG new file mode 100644 index 0000000..971c344 Binary files /dev/null and b/Task_6-master/asset/a06.PNG differ diff --git a/Task_6-master/asset/a07.PNG b/Task_6-master/asset/a07.PNG new file mode 100644 index 0000000..d8325a3 Binary files /dev/null and b/Task_6-master/asset/a07.PNG differ diff --git a/Task_6-master/asset/a08.PNG b/Task_6-master/asset/a08.PNG new file mode 100644 index 0000000..d1164b6 Binary files /dev/null and b/Task_6-master/asset/a08.PNG differ diff --git a/Task_6-master/build.xml b/Task_6-master/build.xml new file mode 100644 index 0000000..6b2ed11 --- /dev/null +++ b/Task_6-master/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Task6. + + + diff --git a/Task_6-master/build/classes/Controller/Controller.class b/Task_6-master/build/classes/Controller/Controller.class new file mode 100644 index 0000000..624ffbd Binary files /dev/null and b/Task_6-master/build/classes/Controller/Controller.class differ diff --git a/Task_6-master/build/classes/Driver/Driver.class b/Task_6-master/build/classes/Driver/Driver.class new file mode 100644 index 0000000..12de99a Binary files /dev/null and b/Task_6-master/build/classes/Driver/Driver.class differ diff --git a/Task_6-master/build/classes/Gui/ComposeTweet.class b/Task_6-master/build/classes/Gui/ComposeTweet.class new file mode 100644 index 0000000..4309f1a Binary files /dev/null and b/Task_6-master/build/classes/Gui/ComposeTweet.class differ diff --git a/Task_6-master/build/classes/Gui/ComposeTweet.form b/Task_6-master/build/classes/Gui/ComposeTweet.form new file mode 100644 index 0000000..570e2f7 --- /dev/null +++ b/Task_6-master/build/classes/Gui/ComposeTweet.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6-master/build/classes/Gui/FollowUser.class b/Task_6-master/build/classes/Gui/FollowUser.class new file mode 100644 index 0000000..956d2f1 Binary files /dev/null and b/Task_6-master/build/classes/Gui/FollowUser.class differ diff --git a/Task_6-master/build/classes/Gui/FollowUser.form b/Task_6-master/build/classes/Gui/FollowUser.form new file mode 100644 index 0000000..d33c2a8 --- /dev/null +++ b/Task_6-master/build/classes/Gui/FollowUser.form @@ -0,0 +1,82 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6-master/build/classes/Gui/HomeTimeline.class b/Task_6-master/build/classes/Gui/HomeTimeline.class new file mode 100644 index 0000000..3bb5588 Binary files /dev/null and b/Task_6-master/build/classes/Gui/HomeTimeline.class differ diff --git a/Task_6-master/build/classes/Gui/HomeTimeline.form b/Task_6-master/build/classes/Gui/HomeTimeline.form new file mode 100644 index 0000000..6e47fcc --- /dev/null +++ b/Task_6-master/build/classes/Gui/HomeTimeline.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Task_6-master/build/classes/Interface/View.class b/Task_6-master/build/classes/Interface/View.class new file mode 100644 index 0000000..5bdabf8 Binary files /dev/null and b/Task_6-master/build/classes/Interface/View.class differ diff --git a/Task_6-master/build/classes/TwitterModel/TwitterModel.class b/Task_6-master/build/classes/TwitterModel/TwitterModel.class new file mode 100644 index 0000000..61afdc6 Binary files /dev/null and b/Task_6-master/build/classes/TwitterModel/TwitterModel.class differ diff --git a/Task_6-master/manifest.mf b/Task_6-master/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/Task_6-master/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Task_6-master/nbproject/build-impl.xml b/Task_6-master/nbproject/build-impl.xml new file mode 100644 index 0000000..203814f --- /dev/null +++ b/Task_6-master/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6-master/nbproject/genfiles.properties b/Task_6-master/nbproject/genfiles.properties new file mode 100644 index 0000000..03c2102 --- /dev/null +++ b/Task_6-master/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/Task_6-master/nbproject/private/private.properties b/Task_6-master/nbproject/private/private.properties new file mode 100644 index 0000000..0ffdacc --- /dev/null +++ b/Task_6-master/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\ASUS\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/Task_6-master/nbproject/private/private.xml b/Task_6-master/nbproject/private/private.xml new file mode 100644 index 0000000..38fa808 --- /dev/null +++ b/Task_6-master/nbproject/private/private.xml @@ -0,0 +1,15 @@ + + + + + + file:/C:/Users/ASUS/Downloads/Task_6/src/Controller/Controller.java + file:/C:/Users/ASUS/Downloads/Task_6/src/TwitterModel/TwitterModel.java + file:/C:/Users/ASUS/Downloads/Task_6/src/Driver/Driver.java + file:/C:/Users/ASUS/Downloads/Task_6/src/Interface/View.java + file:/C:/Users/ASUS/Downloads/Task_6/src/Gui/ComposeTweet.java + file:/C:/Users/ASUS/Downloads/Task_6/src/Gui/FollowUser.java + file:/C:/Users/ASUS/Downloads/Task_6/src/Gui/HomeTimeline.java + + + diff --git a/Task_6-master/nbproject/project.properties b/Task_6-master/nbproject/project.properties new file mode 100644 index 0000000..874611b --- /dev/null +++ b/Task_6-master/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/Task_6-master/nbproject/project.xml b/Task_6-master/nbproject/project.xml new file mode 100644 index 0000000..9ae4b3f --- /dev/null +++ b/Task_6-master/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Task6 + + + + + + + + + diff --git a/Task_6-master/src/Controller/Controller.java b/Task_6-master/src/Controller/Controller.java new file mode 100644 index 0000000..b9eb750 --- /dev/null +++ b/Task_6-master/src/Controller/Controller.java @@ -0,0 +1,113 @@ +/* + * 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. + */ + + +//Elvaretta Dian_1301154446_IF 3912 + + +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 Elvaretta Dian + */ +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/Task_6-master/src/Driver/Driver.java b/Task_6-master/src/Driver/Driver.java new file mode 100644 index 0000000..2cccbac --- /dev/null +++ b/Task_6-master/src/Driver/Driver.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +//Elvaretta Dian_1301154446_IF 3912 + + +package Driver; + +import Controller.Controller; + +/** + * + * @author Elvaretta Dian + */ +public class Driver { + public static void main (String[] args) { + Controller a = new Controller (); + } +} diff --git a/Task_6-master/src/Gui/ComposeTweet.form b/Task_6-master/src/Gui/ComposeTweet.form new file mode 100644 index 0000000..570e2f7 --- /dev/null +++ b/Task_6-master/src/Gui/ComposeTweet.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6-master/src/Gui/ComposeTweet.java b/Task_6-master/src/Gui/ComposeTweet.java new file mode 100644 index 0000000..1c977e2 --- /dev/null +++ b/Task_6-master/src/Gui/ComposeTweet.java @@ -0,0 +1,131 @@ +/* + * 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. + */ + +//Elvaretta Dian_1301154446_IF 3912 + +package Gui; + +import Interface.View; +import java.awt.event.ActionListener; + +/** + * + * @author Elvaretta Dian + */ +public class ComposeTweet extends javax.swing.JFrame implements View { + + /** + * Creates new form ComposeTweet + */ + public ComposeTweet() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + txAreaTweet = new javax.swing.JTextArea(); + jLabel2 = new javax.swing.JLabel(); + btnCancel = new javax.swing.JButton(); + btnTweet = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel1.setText("Compose new Tweet...."); + + txAreaTweet.setColumns(20); + txAreaTweet.setRows(5); + jScrollPane1.setViewportView(txAreaTweet); + + jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + jLabel2.setText("140"); + + btnCancel.setText("Cancel"); + + btnTweet.setText("Tweet"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1)) + .addGroup(layout.createSequentialGroup() + .addGap(27, 27, 27) + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(21, 21, 21) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 167, Short.MAX_VALUE) + .addComponent(btnCancel) + .addGap(53, 53, 53) + .addComponent(btnTweet))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(26, 26, 26) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnTweet) + .addComponent(btnCancel) + .addComponent(jLabel2))) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancel; + private javax.swing.JButton btnTweet; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTweet; + // End of variables declaration//GEN-END:variables + + public Object getBtnCancel () { + return btnCancel; + } + + public Object getBtnTweet () { + return btnTweet; + } + + public String getTweet () { + return txAreaTweet.getText (); + } + + public void addListener (ActionListener e) { + btnCancel.addActionListener(e); + btnTweet.addActionListener(e); + } + + public Object getBtntweet() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} diff --git a/Task_6-master/src/Gui/FollowUser.form b/Task_6-master/src/Gui/FollowUser.form new file mode 100644 index 0000000..d33c2a8 --- /dev/null +++ b/Task_6-master/src/Gui/FollowUser.form @@ -0,0 +1,82 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task_6-master/src/Gui/FollowUser.java b/Task_6-master/src/Gui/FollowUser.java new file mode 100644 index 0000000..8b8cf10 --- /dev/null +++ b/Task_6-master/src/Gui/FollowUser.java @@ -0,0 +1,115 @@ +/* + * 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. + */ + +//Elvaretta Dian_1301154446_IF 3912 + + +package Gui; + +import Interface.View; +import java.awt.event.ActionListener; + +/** + * + * @author Elvaretta Dian + */ +public class FollowUser extends javax.swing.JFrame implements View { + + /** + * Creates new form FollowUser + */ + public FollowUser() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + txFieldUser = new javax.swing.JTextField(); + btnCancel = new javax.swing.JButton(); + btnFollow = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + jLabel1.setText("Follow User"); + + btnCancel.setText("Cancel"); + + btnFollow.setText("Follow"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(btnCancel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnFollow)) + .addComponent(txFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(25, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCancel) + .addComponent(btnFollow)) + .addContainerGap(172, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCancel; + private javax.swing.JButton btnFollow; + private javax.swing.JLabel jLabel1; + private javax.swing.JTextField txFieldUser; + // End of variables declaration//GEN-END:variables + + public Object getBtnCancel () { + return btnCancel; + } + + public Object getBtnFollow () { + return btnFollow; + } + + public String getUser () { + return txFieldUser.getText (); + } + + public void setUser (String s) { + txFieldUser.setText (s); + } + + public void addListener (ActionListener e) { + btnCancel.addActionListener(e); + btnFollow.addActionListener(e); + } +} diff --git a/Task_6-master/src/Gui/HomeTimeline.form b/Task_6-master/src/Gui/HomeTimeline.form new file mode 100644 index 0000000..6e47fcc --- /dev/null +++ b/Task_6-master/src/Gui/HomeTimeline.form @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Task_6-master/src/Gui/HomeTimeline.java b/Task_6-master/src/Gui/HomeTimeline.java new file mode 100644 index 0000000..190e8fb --- /dev/null +++ b/Task_6-master/src/Gui/HomeTimeline.java @@ -0,0 +1,132 @@ +/* + * 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. + */ + +//Elvaretta Dian_1301154446_IF 3912 + +package Gui; + +import Interface.View; +import java.awt.event.ActionListener; + +/** + * + * @author Elvaretta Dian + */ +public class HomeTimeline extends javax.swing.JFrame implements View { + + /** + * Creates new form HomeTimeline + */ + public HomeTimeline() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + txAreaTimeline = new javax.swing.JTextArea(); + btnCompose = new javax.swing.JButton(); + btnFollow = new javax.swing.JButton(); + btnRefresh = new javax.swing.JButton(); + btnExit = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + txAreaTimeline.setEditable(false); + txAreaTimeline.setColumns(20); + txAreaTimeline.setRows(5); + jScrollPane1.setViewportView(txAreaTimeline); + + btnCompose.setText("Compose"); + + btnFollow.setText("Follow User"); + + btnRefresh.setText("Refresh"); + + btnExit.setText("Exit"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(btnCompose) + .addGap(31, 31, 31) + .addComponent(btnFollow) + .addGap(27, 27, 27) + .addComponent(btnRefresh) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE) + .addComponent(btnExit)) + .addComponent(jScrollPane1)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(26, 26, 26) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCompose) + .addComponent(btnFollow) + .addComponent(btnRefresh) + .addComponent(btnExit)) + .addGap(51, 51, 51)) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCompose; + private javax.swing.JButton btnExit; + private javax.swing.JButton btnFollow; + private javax.swing.JButton btnRefresh; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea txAreaTimeline; + // End of variables declaration//GEN-END:variables + + public Object getBtnCompose () { + return btnCompose; + } + + public Object getBtnExit () { + return btnExit; + } + + public Object getBtnFollow () { + return btnFollow; + } + + public Object getBtnRefresh () { + return btnRefresh; + } + + public void setTimeline (String s) { + txAreaTimeline.setText(s); + } + + public void addListener (ActionListener e) { + btnCompose.addActionListener(e); + btnExit.addActionListener(e); + btnFollow.addActionListener(e); + btnRefresh.addActionListener(e); + } +} diff --git a/Task_6-master/src/Interface/View.java b/Task_6-master/src/Interface/View.java new file mode 100644 index 0000000..b8fa852 --- /dev/null +++ b/Task_6-master/src/Interface/View.java @@ -0,0 +1,19 @@ +/* + * 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. + */ + +//Elvaretta Dian_1301154446_IF 3912 + +package Interface; + +import java.awt.event.ActionListener; + +/** + * + * @author Elvaretta Dian + */ +public interface View { + public void addListener (ActionListener e); +} diff --git a/Task_6-master/src/TwitterModel/TwitterModel.java b/Task_6-master/src/TwitterModel/TwitterModel.java new file mode 100644 index 0000000..96b0efc --- /dev/null +++ b/Task_6-master/src/TwitterModel/TwitterModel.java @@ -0,0 +1,57 @@ +/* + * 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. + */ + +//Elvaretta Dian_1301154446_IF 3912 + +package TwitterModel; + +import twitter4j.*; +import java.util.List; +import javax.swing.JOptionPane; + +/** + * + * @author Elvaretta Dian + */ +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/Task_6-master/twitter4j-core-4.0.4.jar b/Task_6-master/twitter4j-core-4.0.4.jar new file mode 100644 index 0000000..029abce Binary files /dev/null and b/Task_6-master/twitter4j-core-4.0.4.jar differ diff --git a/Task_6-master/twitter4j.properties.txt b/Task_6-master/twitter4j.properties.txt new file mode 100644 index 0000000..8283134 --- /dev/null +++ b/Task_6-master/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