Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.font.TextAttribute;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import javax.swing.*;
- public class Main extends JFrame {
- public static File showsDirectory;
- public ArrayList<Show> getShows(){
- ArrayList<Show> shows = new ArrayList<Show>();
- for(File f:showsDirectory.listFiles()){
- if(f.isDirectory()){
- shows.add(new Show(f));
- }
- }
- return null;
- }
- public static void main(String[]args) throws IOException{
- String filesource = "C:"+File.separator+"Users"+File.separator+System.getProperty("user.name")+File.separator+"Desktop";
- String filename = "streamersource.txt";
- if(!(new File(filesource,filename).exists())){
- showMsg("There is no streamersource.txt on the desktop.");
- }else{
- String line;
- File f = new File(filesource,filename);
- BufferedReader in = new BufferedReader(new FileReader(f));
- line=in.readLine();
- if(line==null||line==""){
- showMsg("There is nothing in the txt file...");
- }
- else if(new File(line)==null){
- showMsg(line+" is not a file!");
- }else{
- File directory = new File(line);
- if(!directory.exists()){
- showMsg(directory.getName()+" does not exist!");
- }
- else if(!directory.isDirectory()){
- showMsg(directory.getName()+" is not a folder.");
- }else{
- log("streamersource.txt found.");
- showsDirectory = directory;
- Main m = new Main();
- }
- }
- }
- }
- private static void showMsg(String s){
- JOptionPane.showMessageDialog(null,s);
- }
- private static void log(String s){
- System.out.println(s);
- }
- JPanel panel = new JPanel();
- JComboBox shows;
- public void setupShowsBox(){
- String[] showsString;
- ArrayList<String> showsStringList = new ArrayList<String>();
- for(Show s : getShows()){
- showsStringList.add(s.getName());
- }
- showsString = showsStringList.toArray(new String[showsStringList.size()]);
- shows = new JComboBox(showsString);
- shows.setBounds(0,20,500,20);
- panel.add(shows);
- }
- JLabel title;
- public void setupTitle(){
- title = new JLabel("Ahuvia Streamer 1.0");
- HashMap<TextAttribute, Integer> map = new HashMap<TextAttribute, Integer>();
- map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
- Font f = new Font("Broadway", Font.BOLD, 24).deriveFont(map);
- title.setForeground(new Color(330066));
- title.setBounds(0,0,500,23);
- title.setHorizontalAlignment(JLabel.CENTER);
- title.setFont(f);
- panel.add(title);
- }
- Main(){
- super("Ahuvia Streamer 1.0");
- setSize(500,500);
- setLocation(500,280);
- panel.setLayout(null);
- setupTitle();
- setupShowsBox();
- setResizable(false);
- getContentPane().add(panel);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement