Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- import javax.swing.JPasswordField;
- import javax.swing.JTextField;
- public class Menu {
- static Scanner teclado = new Scanner(System.in);
- public static void main(String[] args) {
- login_user();
- }
- public static void login_user() {
- JTextField user = new JTextField();
- JTextField pass = new JPasswordField();
- Object[] message = {
- "Username:", user,
- "Password:", pass
- };
- int option = JOptionPane.showConfirmDialog(null, message, "Welcome to EpiTrack", JOptionPane.OK_CANCEL_OPTION);
- if (option == JOptionPane.OK_OPTION) {
- if (user.getText().equals("") && pass.getText().equals("")) {
- JOptionPane.showMessageDialog(null, "<html>Login Sucessful <br> Press 'Ok' to proceed.");
- menu();
- } else {
- JOptionPane.showMessageDialog(null, "<html>Login Failed <br> Press 'Ok' to retry");
- login_user();
- }
- } else {
- JOptionPane.showMessageDialog(null, "<html>Login Cancelled <br> Press 'Ok' to close.");
- }
- }
- public static void menu(){
- Object[] possibleValues = { "Series", "Movies"};
- Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
- if (selectedValue.equals("Series")){
- menu_series();
- }else{if (selectedValue.equals("Movies")){
- menu_filmes();
- }else{System.out.println("stuff");
- }
- }
- }
- public static void menu_series(){
- Object[] possibleValues = { "Add to List", "Update List", "Open List" };
- Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
- if (selectedValue.equals("Add to List")){
- add_to_list_series();
- }else{if (selectedValue.equals("Open List")){
- open_list_series();
- }else{
- menu();
- }
- }
- }
- public static void menu_filmes(){
- Object[] possibleValues = { "Add to List", "Update List", "Open List" };
- Object selectedValue = JOptionPane.showInputDialog(null, "Choose: ", "EpiTrack" , JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]);
- if (selectedValue.equals("Add to List")){
- add_to_list_filmes();
- }else{if (selectedValue.equals("Open List")){
- open_list_filmes();
- }else{
- menu();
- }
- }
- }
- public static void teste_multiplo_input(){
- //teste de multiplo input
- JTextField name = new JTextField();
- JTextField season = new JTextField();
- JTextField episode = new JTextField();
- Object[] message = {
- "Name:", name,
- "Season:", season,
- "Episode:", episode
- };
- int option = JOptionPane.showConfirmDialog(null, message, "Create List", JOptionPane.OK_CANCEL_OPTION);
- if (option == JOptionPane.OK_OPTION) {
- String teste;
- teste = teclado.nextLine();
- name.getText();
- System.out.println(teste);
- }
- }
- public static void add_to_list_series(){
- String name = JOptionPane.showInputDialog("Name");
- String season = JOptionPane.showInputDialog("Season");
- String episode = JOptionPane.showInputDialog("Episode");
- String serie = name + " " + "Season" + " " + season + " " + "Episode"+ " " + episode;
- FileWriter texto = null;
- BufferedWriter escrivao = null;
- try {
- texto = new FileWriter("testeseries.txt", true);
- escrivao = new BufferedWriter(texto);
- escrivao.write(serie);
- // writer.write(nome_projecto);
- escrivao.newLine(); // descomentar para por em linha !
- escrivao.close();
- } catch (Exception e) {
- System.out.println("Erro!");
- }
- menu_series();
- }
- public static void add_to_list_filmes(){
- String name = JOptionPane.showInputDialog("Name");
- String data = JOptionPane.showInputDialog("Date");
- String filmes = name + " " + data;
- FileWriter texto = null;
- BufferedWriter escrivao = null;
- try {
- texto = new FileWriter("testefilmes.txt", true);
- escrivao = new BufferedWriter(texto);
- escrivao.write(filmes);
- // writer.write(nome_projecto);
- escrivao.newLine(); // descomentar para por em linha !
- escrivao.close();
- } catch (Exception e) {
- System.out.println("Erro!");
- }
- menu_filmes();
- }
- public static void open_list_series(){
- ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "testeseries.txt");
- try {
- pb.start();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null, "<html>There's an error<br> Press 'Ok' to go back");
- menu_series();
- }
- }
- public static void open_list_filmes(){
- ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "testefilmes.txt");
- try {
- pb.start();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null, "<html>There's an error<br> Press 'Ok' to go back");
- menu_filmes();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement