Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 KB | None | 0 0
  1.  
  2. import java.io.BufferedWriter;
  3. import java.io.FileWriter;
  4. import java.io.IOException;
  5. import java.util.Scanner;
  6. import javax.swing.JOptionPane;
  7. import javax.swing.JPasswordField;
  8. import javax.swing.JTextField;
  9.  
  10.  
  11. public class Menu {
  12. static Scanner teclado = new Scanner(System.in);
  13.  
  14. public static void main(String[] args) {
  15. login_user();
  16. }
  17.  
  18. public static void login_user() {
  19. JTextField user = new JTextField();
  20. JTextField pass = new JPasswordField();
  21. Object[] message = {
  22. "Username:", user,
  23. "Password:", pass
  24. };
  25.  
  26. int option = JOptionPane.showConfirmDialog(null, message, "Welcome to EpiTrack", JOptionPane.OK_CANCEL_OPTION);
  27. if (option == JOptionPane.OK_OPTION) {
  28. if (user.getText().equals("") && pass.getText().equals("")) {
  29. JOptionPane.showMessageDialog(null, "<html>Login Sucessful <br> Press 'Ok' to proceed.");
  30. menu();
  31. } else {
  32. JOptionPane.showMessageDialog(null, "<html>Login Failed <br> Press 'Ok' to retry");
  33. login_user();
  34. }
  35. } else {
  36. JOptionPane.showMessageDialog(null, "<html>Login Cancelled <br> Press 'Ok' to close.");
  37. }
  38.  
  39. }
  40.  
  41. public static void menu(){
  42. Object[] possibleValues = { "Series", "Movies"};
  43. Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
  44.  
  45.  
  46. if (selectedValue.equals("Series")){
  47. menu_series();
  48.  
  49. }else{if (selectedValue.equals("Movies")){
  50. menu_filmes();
  51.  
  52. }else{System.out.println("stuff");
  53.  
  54. }
  55. }
  56. }
  57.  
  58. public static void menu_series(){
  59. Object[] possibleValues = { "Add to List", "Update List", "Open List" };
  60. Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
  61.  
  62.  
  63. if (selectedValue.equals("Add to List")){
  64. add_to_list_series();
  65.  
  66. }else{if (selectedValue.equals("Open List")){
  67. open_list_series();
  68.  
  69. }else{
  70. menu();
  71. }
  72. }
  73. }
  74.  
  75. public static void menu_filmes(){
  76. Object[] possibleValues = { "Add to List", "Update List", "Open List" };
  77. Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
  78.  
  79.  
  80. if (selectedValue.equals("Add to List")){
  81. add_to_list_filmes();
  82.  
  83. }else{if (selectedValue.equals("Open List")){
  84. open_list_filmes();
  85.  
  86. }else{
  87. menu();
  88. }
  89. }
  90. }
  91.  
  92. public static void teste_multiplo_input(){
  93. //teste de multiplo input
  94.  
  95. JTextField name = new JTextField();
  96. JTextField season = new JTextField();
  97. JTextField episode = new JTextField();
  98. Object[] message = {
  99. "Name:", name,
  100. "Season:", season,
  101. "Episode:", episode
  102. };
  103.  
  104.  
  105. int option = JOptionPane.showConfirmDialog(null, message, "Create List", JOptionPane.OK_CANCEL_OPTION);
  106. if (option == JOptionPane.OK_OPTION) {
  107.  
  108. String teste;
  109. teste = teclado.nextLine();
  110. name.getText();
  111.  
  112.  
  113. System.out.println(teste);
  114.  
  115. }
  116. }
  117.  
  118. public static void add_to_list_series(){
  119. String name = JOptionPane.showInputDialog("Name");
  120. String season = JOptionPane.showInputDialog("Season");
  121. String episode = JOptionPane.showInputDialog("Episode");
  122.  
  123. String serie = name + " " + "Season" + " " + season + " " + "Episode"+ " " + episode;
  124.  
  125. FileWriter texto = null;
  126. BufferedWriter escrivao = null;
  127.  
  128. try {
  129.  
  130. texto = new FileWriter("testeseries.txt", true);
  131. escrivao = new BufferedWriter(texto);
  132. escrivao.write(serie);
  133. // writer.write(nome_projecto);
  134. escrivao.newLine(); // descomentar para por em linha !
  135. escrivao.close();
  136.  
  137. } catch (Exception e) {
  138. System.out.println("Erro!");
  139. }
  140.  
  141. menu_series();
  142. }
  143.  
  144. public static void add_to_list_filmes(){
  145. String name = JOptionPane.showInputDialog("Name");
  146. String data = JOptionPane.showInputDialog("Date");
  147.  
  148. String filmes = name + " " + data;
  149.  
  150. FileWriter texto = null;
  151. BufferedWriter escrivao = null;
  152.  
  153. try {
  154.  
  155. texto = new FileWriter("testefilmes.txt", true);
  156. escrivao = new BufferedWriter(texto);
  157. escrivao.write(filmes);
  158. // writer.write(nome_projecto);
  159. escrivao.newLine(); // descomentar para por em linha !
  160. escrivao.close();
  161.  
  162. } catch (Exception e) {
  163. System.out.println("Erro!");
  164. }
  165.  
  166. menu_filmes();
  167. }
  168.  
  169. public static void open_list_series(){
  170. ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "testeseries.txt");
  171. try {
  172. pb.start();
  173. } catch (IOException e) {
  174. JOptionPane.showMessageDialog(null, "<html>There's an error<br> Press 'Ok' to go back");
  175. menu_series();
  176. }
  177.  
  178.  
  179. }
  180.  
  181. public static void open_list_filmes(){
  182. ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "testefilmes.txt");
  183. try {
  184. pb.start();
  185. } catch (IOException e) {
  186. JOptionPane.showMessageDialog(null, "<html>There's an error<br> Press 'Ok' to go back");
  187. menu_filmes();
  188. }
  189. }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement