Advertisement
Guest User

Main.class

a guest
Mar 7th, 2014
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.90 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.font.TextAttribute;
  6. import java.io.BufferedReader;
  7. import java.io.File;
  8. import java.io.FileReader;
  9. import java.io.IOException;
  10. import java.util.ArrayList;
  11. import java.util.Arrays;
  12. import java.util.HashMap;
  13. import java.util.List;
  14.  
  15. import javax.swing.*;
  16.  
  17. public class Main extends JFrame {
  18. public static File showsDirectory;
  19.  
  20. public ArrayList<Show> getShows(){
  21.     ArrayList<Show> shows = new ArrayList<Show>();
  22.     for(File f:showsDirectory.listFiles()){
  23.         if(f.isDirectory()){
  24.             shows.add(new Show(f));
  25.         }
  26.     }
  27.     return null;
  28. }
  29. public static void main(String[]args) throws IOException{
  30.     String filesource = "C:"+File.separator+"Users"+File.separator+System.getProperty("user.name")+File.separator+"Desktop";
  31.     String filename = "streamersource.txt";
  32.     if(!(new File(filesource,filename).exists())){
  33.         showMsg("There is no streamersource.txt on the desktop.");
  34.     }else{
  35.         String line;
  36.         File f = new File(filesource,filename);
  37.         BufferedReader in = new BufferedReader(new FileReader(f));
  38.         line=in.readLine();
  39.         if(line==null||line==""){
  40.             showMsg("There is nothing in the txt file...");
  41.         }
  42.         else if(new File(line)==null){
  43.             showMsg(line+" is not a file!");
  44.         }else{
  45.         File directory = new File(line);
  46.         if(!directory.exists()){
  47.             showMsg(directory.getName()+" does not exist!");
  48.         }
  49.         else if(!directory.isDirectory()){
  50.             showMsg(directory.getName()+" is not a folder.");
  51.         }else{
  52.             log("streamersource.txt found.");
  53.             showsDirectory = directory;
  54.             Main m = new Main();
  55.         }
  56.         }
  57.     }
  58. }
  59. private static void showMsg(String s){
  60.     JOptionPane.showMessageDialog(null,s);
  61. }
  62. private static void log(String s){
  63.     System.out.println(s);
  64. }
  65. JPanel panel = new JPanel();
  66. JComboBox shows;
  67. public void setupShowsBox(){
  68.     String[] showsString;
  69.     ArrayList<String> showsStringList = new ArrayList<String>();
  70.     for(Show s : getShows()){
  71.         showsStringList.add(s.getName());
  72.     }
  73.     showsString = showsStringList.toArray(new String[showsStringList.size()]);
  74.     shows = new JComboBox(showsString);
  75.     shows.setBounds(0,20,500,20);
  76.     panel.add(shows);
  77. }
  78. JLabel title;
  79. public void setupTitle(){
  80.     title = new JLabel("Ahuvia Streamer 1.0");
  81.     HashMap<TextAttribute, Integer> map = new HashMap<TextAttribute, Integer>();
  82.     map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
  83.     Font f = new Font("Broadway", Font.BOLD, 24).deriveFont(map);
  84.     title.setForeground(new Color(330066));
  85.     title.setBounds(0,0,500,23);
  86.     title.setHorizontalAlignment(JLabel.CENTER);
  87.     title.setFont(f);
  88.     panel.add(title);
  89. }
  90. Main(){
  91.     super("Ahuvia Streamer 1.0");
  92.     setSize(500,500);
  93.     setLocation(500,280);
  94.     panel.setLayout(null); 
  95.     setupTitle();
  96.     setupShowsBox();
  97.     setResizable(false);
  98.     getContentPane().add(panel);
  99.     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  100.     setVisible(true);
  101.    
  102.     }
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement