Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 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. primeiro_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 primeiro_menu(){
  42. Object[] possibleValues = { "Add to List", "Update List", "Open List" };
  43. Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
  44.  
  45.  
  46. if (selectedValue.equals("Add to List")){
  47. add_to_list();
  48.  
  49. }else{if (selectedValue.equals("Open List")){
  50. open_list();
  51.  
  52. }else{System.out.println("stuff");
  53.  
  54. }
  55. }
  56. }
  57.  
  58. public static void teste_multiplo_input(){
  59. //teste de multiplo input
  60.  
  61. JTextField name = new JTextField();
  62. JTextField season = new JTextField();
  63. JTextField episode = new JTextField();
  64. Object[] message = {
  65. "Name:", name,
  66. "Season:", season,
  67. "Episode:", episode
  68. };
  69.  
  70.  
  71. int option = JOptionPane.showConfirmDialog(null, message, "Create List", JOptionPane.OK_CANCEL_OPTION);
  72. if (option == JOptionPane.OK_OPTION) {
  73.  
  74. String teste;
  75. teste = teclado.nextLine();
  76. name.getText();
  77.  
  78.  
  79. System.out.println(teste);
  80.  
  81. }
  82. }
  83.  
  84. public static void add_to_list(){
  85. String name = JOptionPane.showInputDialog("Name");
  86. String season = JOptionPane.showInputDialog("Season");
  87. String episode = JOptionPane.showInputDialog("Episode");
  88.  
  89. String serie = name + " " + "Season" + " " + season + " " + "Episode"+ " " + episode;
  90.  
  91. FileWriter texto = null;
  92. BufferedWriter escrivao = null;
  93.  
  94. try {
  95.  
  96. texto = new FileWriter("testeseries.txt", true);
  97. escrivao = new BufferedWriter(texto);
  98. escrivao.write(serie);
  99. // writer.write(nome_projecto);
  100. escrivao.newLine(); // descomentar para por em linha !
  101. escrivao.close();
  102.  
  103. } catch (Exception e) {
  104. System.out.println("Erro!");
  105. }
  106.  
  107. primeiro_menu();
  108. }
  109.  
  110. public static void open_list(){
  111. ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "testeseries.txt");
  112. try {
  113. pb.start();
  114. } catch (IOException e) {
  115. JOptionPane.showMessageDialog(null, "<html>There's an error<br> Press 'Ok' to go back");
  116. primeiro_menu();
  117. }
  118.  
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement