From 76362b2cce2426178d0503803791a2def31af4c6 Mon Sep 17 00:00:00 2001 From: Donald Shan Date: Sun, 21 Aug 2022 23:41:25 -0700 Subject: Better Error Handling for when no file is selected --- src/main/java/Main.java | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/main') diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 46723d3..05edb94 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -61,23 +61,28 @@ public class Main extends JFrame { panel.add(Box.createVerticalStrut(5)); panel.add(editButton); this.setSize(550,450); - this.setTitle("amazing program to download and tag all mp3 files"); + this.setTitle("YTMP3Tagger"); } private void initializeActionsListeners(){//Add all actionlisteners for buttons startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if(textPath.equals("")||readyState==false){ + if(readyState==false){ outputArea.setText(outputArea.getText()+"\n"+"txt path has not been set. Launching chooserPane"); System.out.println(".txt path has not been set. Launching chooserPane"); textPath = fileUtil.showTextFileChooser(); - if(!textPath.equals("")){ - showWarning("File has been set.\nMake sure you add a new line for each URL.\nOr else say bye bye to your system32"); - readyState = true; - startButton.setText("Start Download"); - outputArea.setText(outputArea.getText()+"\n"+"Ready to begin downloading. Press the button"); - System.out.println("Ready to begin downloading. Press the button"); + try { + if (!textPath.equals("")) { + showWarning("File has been set.\nMake sure you add a new line for each URL"); + readyState = true; + startButton.setText("Start Download"); + outputArea.setText(outputArea.getText() + "\n" + "Ready to begin downloading. Press the button"); + System.out.println("Ready to begin downloading. Press the button"); + } + } + catch(Exception ex){ + } } else{ @@ -173,4 +178,4 @@ public class Main extends JFrame { -} +} \ No newline at end of file -- cgit v1.2.3