Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.concurrent.ScheduledExecutorService;
- import java.util.concurrent.ThreadLocalRandom;
- import java.awt.datatransfer.StringSelection;
- import java.time.temporal.TemporalAdjusters;
- import java.awt.event.MouseMotionListener;
- import javax.script.ScriptEngineManager;
- import javax.swing.event.ChangeListener;
- import javax.sound.sampled.FloatControl;
- import javax.sound.sampled.AudioSystem;
- import javax.swing.border.EmptyBorder;
- import java.util.concurrent.Executors;
- import javax.swing.ListSelectionModel;
- import java.util.concurrent.TimeUnit;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import com.sun.glass.events.KeyEvent;
- import javax.swing.border.LineBorder;
- import java.awt.event.ActionListener;
- import javax.swing.event.ChangeEvent;
- import java.awt.image.WritableRaster;
- import javax.sound.sampled.Port.Info;
- import java.awt.event.WindowListener;
- import java.awt.TrayIcon.MessageType;
- import java.awt.event.WindowAdapter;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferedImage;
- import java.awt.GraphicsEnvironment;
- import java.io.BufferedInputStream;
- import java.security.MessageDigest;
- import java.awt.event.MouseAdapter;
- import javax.swing.AbstractAction;
- import java.awt.event.KeyListener;
- import javax.swing.SwingUtilities;
- import java.awt.event.ActionEvent;
- import java.awt.event.WindowEvent;
- import javax.swing.SwingConstants;
- import javax.swing.JPasswordField;
- import java.text.SimpleDateFormat;
- import java.net.InetSocketAddress;
- import javax.swing.BorderFactory;
- import javax.script.ScriptEngine;
- import java.awt.event.InputEvent;
- import javazoom.jl.player.Player;
- import java.awt.event.MouseEvent;
- import javax.swing.border.Border;
- import java.io.InputStreamReader;
- import java.net.NetworkInterface;
- import javax.sound.sampled.Port;
- import javax.swing.JRadioButton;
- import javax.swing.JFileChooser;
- import javax.swing.JScrollPane;
- import javax.swing.JOptionPane;
- import java.io.FileInputStream;
- import java.text.DecimalFormat;
- import javax.swing.ButtonGroup;
- import java.awt.GraphicsDevice;
- import java.net.SocketAddress;
- import java.io.BufferedReader;
- import javax.swing.JTextField;
- import java.io.BufferedWriter;
- import java.io.FilenameFilter;
- import java.io.IOException;
- import javax.swing.JComponent;
- import javax.swing.JTextArea;
- import javax.imageio.ImageIO;
- import javax.swing.KeyStroke;
- import java.awt.image.Raster;
- import javax.swing.BoxLayout;
- import javax.swing.ImageIcon;
- import javax.swing.UIManager;
- import java.util.Enumeration;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import java.awt.BorderLayout;
- import java.util.Collections;
- import java.net.InetAddress;
- import java.util.LinkedList;
- import java.util.Properties;
- import java.text.DateFormat;
- import java.io.StringWriter;
- import java.util.ArrayList;
- import java.awt.Graphics2D;
- import java.time.LocalDate;
- import java.time.DayOfWeek;
- import javax.swing.JButton;
- import java.io.PrintWriter;
- import java.nio.file.Files;
- import javax.swing.JSlider;
- import java.awt.FlowLayout;
- import java.awt.GridLayout;
- import java.awt.SystemTray;
- import java.io.FileWriter;
- import java.io.FileReader;
- import javax.swing.JLabel;
- import java.awt.Dimension;
- import javax.swing.JPanel;
- import java.awt.Rectangle;
- import java.awt.Component;
- import java.util.Calendar;
- import javax.swing.JFrame;
- import javax.swing.Action;
- import java.awt.PopupMenu;
- import javax.swing.JList;
- import java.util.Arrays;
- import java.util.Random;
- import java.awt.Desktop;
- import java.awt.Toolkit;
- import java.net.Socket;
- import java.util.List;
- import java.awt.Robot;
- import java.awt.Color;
- import java.awt.Image;
- import java.util.Date;
- import java.awt.Point;
- import java.awt.Font;
- import java.net.URL;
- import java.net.URI;
- import java.io.File;
- import java.awt.*;
- public class AI implements ActionListener, MouseMotionListener, MouseListener, ChangeListener, WindowListener
- {
- public Player Player;
- public Player MP3Player;
- public JSlider MusicVolumeSlider;
- public File CreateUserBackground = new File("No file chosen");
- public File CurrentMusicFile;
- public File CurrentUserNote;
- public File FileChooserFile;
- public LinkedList<Preference> PreferencesList = new LinkedList<Preference>();
- public Font DefaultFont = new Font("Tahoma",Font.BOLD, 30);
- public Font DefaultFontSmall = new Font("Tahoma",Font.BOLD, 15);
- public Font LoginFont = new Font("Comic Sans MS",Font.BOLD, 30);
- public Font ButtonFont = new Font("Dialog Font",Font.BOLD,15);
- public Font Tahoma = new Font("Tahoma",Font.BOLD,20);
- public Font WeatherFontBig = new Font("Segoe UI Black", Font.BOLD, 30);
- public Font WeatherFontSmall = new Font("Segoe UI Black", Font.BOLD, 20);
- public Font UserFont;
- public ImageIcon SASIDIcon = new ImageIcon("SASIDFiles\\Pictures\\SASIDIcon.png");
- public ImageIcon SASIDTrayIcon = new ImageIcon("SASIDFiles\\Pictures\\SASIDTrayIcon.png");
- public List<String> OperationList = new ArrayList<String>();
- public List<String> PropertiesList;
- public List<File> BackgroundsList;
- public List<String> BackgroundsNameList;
- public List<File> MusicList;
- public List<String> MusicNameList;
- public List<File> NoteList;
- public List<String> NoteNameList;
- public JList<?> PizzaTopingsList;
- public JList<?> FontList;
- public JList<?> FileSelectionList;
- public JList<?> BackgroundSelectionList;
- public JList<?> MusicSelectionList;
- public String HangmanWord;
- public String OS;
- public String OriginalOperation;
- public String PhoneNumber = "";
- public String CalculatorExpression = "";
- public String CUsername;
- public String FirstWord;
- public String operation;
- public String YesOrNo;
- public String NewName;
- public String UserCity;
- public String UserLat;
- public String UserLon;
- public String UserState;
- public String UserStateAbr;
- public String UserISP;
- public String UserCountry;
- public String UserCountryAbr;
- public String Temperature;
- public String CloudCover;
- public String UVIndex;
- public String WeatherCondition;
- public String WeatherSummary;
- public String Humidity;
- public String Visibility;
- public String Pressure;
- public String Sunrise;
- public String Sunset;
- public String WindSpeed;
- public String WindDirection;
- public String WeatherIcon;
- public String SASIDVer = "SASID Build 0.5";
- public String Username = "Unknown user";
- public Color ConsoleColor = new Color(39,40,34);
- public Color RegularRed = new Color(223,85,83);
- public Color CalculatorOrange = new Color(255,140,0);
- public Color TTTBlue = new Color(71,81,117);
- public Color Vanila = new Color(252,251,227);
- public Color UserColor;
- public ButtonGroup RadioCurrentValueGroup;
- public ButtonGroup RadioNewValueGroup;
- public JComboBox<?> PizzaCrustCombo;
- public JRadioButton NewFahrenheit;
- public JRadioButton OldFahrenheit;
- public JRadioButton NewCelsius;
- public JRadioButton OldCelsius;
- public JRadioButton NewKelvin;
- public JRadioButton OldKelvin;
- public JRadioButton Medium;
- public JRadioButton Large;
- public JRadioButton Small;
- public JPasswordField HashField;
- public JPasswordField pass;
- public JPasswordField NewUserPassword;
- public JPasswordField NewUserPasswordconf;
- public BufferedWriter CSVwriter;
- public BufferedReader CSVreader;
- public BufferedInputStream BIS;
- public FileInputStream FIS;
- public JButton Back;
- public JButton DebugButton;
- public JButton CloseWeather;
- public JButton MinimizeWeather;
- public JButton Facebook;
- public JButton Twitter;
- public JButton Instagram;
- public JButton YouTube;
- public JButton DeleteMusic;
- public JButton OpenMusic;
- public JButton AddMusic;
- public JButton DeleteBackground;
- public JButton OpenBackground;
- public JButton AddBackground;
- public JButton SaveNote;
- public JButton RepeatMusic;
- public JButton ApplyPreferences;
- public JButton Apply;
- public JButton close;
- public JButton CloseDebug;
- public JButton Eight;
- public JButton Seven;
- public JButton Three;
- public JButton Nine;
- public JButton Five;
- public JButton Four;
- public JButton Zero;
- public JButton Six;
- public JButton Two;
- public JButton One;
- public JButton SubmitButton;
- public JButton ResetValues;
- public JButton HashButton;
- public JButton ResetPizza;
- public JButton ChangeSize;
- public JButton PlaceOrder;
- public JButton DialNumber;
- public JButton ApplyFont;
- public JButton Calculate;
- public JButton CloseLog;
- public JButton minimize;
- public JButton ClickMe;
- public JButton CloseDraw;
- public JButton CloseMusic;
- public JButton CalculatorOne;
- public JButton CalculatorTwo;
- public JButton CalculatorThree;
- public JButton CalculatorFour;
- public JButton CalculatorFive;
- public JButton CalculatorSix;
- public JButton CalculatorSeven;
- public JButton CalculatorEight;
- public JButton CalculatorNine;
- public JButton CalculatorZero;
- public JButton CalculatorAdd;
- public JButton CalculatorSubtract;
- public JButton CalculatorMultiply;
- public JButton CalculatorDivide;
- public JButton CalculatorDecimal;
- public JButton CalculatorEquals;
- public JButton CalculatorClear;
- public JButton CalculatorPercent;
- public JButton CalculatorOpenP;
- public JButton CalculatorCloseP;
- public JButton CalculatorDeciaml;
- public JButton TTT1;
- public JButton TTT2;
- public JButton TTT3;
- public JButton TTT4;
- public JButton TTT5;
- public JButton TTT6;
- public JButton TTT7;
- public JButton TTT8;
- public JButton TTT9;
- public JButton TTTReset;
- public JButton AddNote;
- public JButton DeleteNote;
- public JButton SubmitNote;
- public JButton OpenNote;
- public JButton SubmitNewNote;
- public JButton GetYTTN;
- public JButton ApproveImage;
- public JButton PlayPauseMusic;
- public JButton StopMusic;
- public JButton NextMusic;
- public JButton LastMusic;
- public JButton LoopMusic;
- public JButton SelectMusicDir;
- public JButton HangmanA;
- public JButton HangmanB;
- public JButton HangmanC;
- public JButton HangmanD;
- public JButton HangmanE;
- public JButton HangmanF;
- public JButton HangmanG;
- public JButton HangmanH;
- public JButton HangmanI;
- public JButton HangmanJ;
- public JButton HangmanK;
- public JButton HangmanL;
- public JButton HangmanM;
- public JButton HangmanN;
- public JButton HangmanO;
- public JButton HangmanP;
- public JButton HangmanQ;
- public JButton HangmanR;
- public JButton HangmanS;
- public JButton HangmanT;
- public JButton HangmanU;
- public JButton HangmanV;
- public JButton HangmanW;
- public JButton HangmanX;
- public JButton HangmanY;
- public JButton HangmanZ;
- public JButton HangmanReset;
- public JTextField StartingValue;
- public JTextField InputField;
- public JTextField NameField;
- public JTextField EnterName;
- public JTextField Green;
- public JTextField Red;
- public JTextField Blue;
- public JTextField CalculatorField;
- public JTextField NewNoteField;
- public JTextField YTTNField;
- public JTextField NewUserName;
- public double CalculationValue;
- public long PauseLocation;
- public long SongTotalLength;
- public boolean YouTubeScript;
- public boolean MathShellMode;
- public boolean ChristmasEcho;
- public boolean HalloweenEcho;
- public boolean IndependenceDayEcho;
- public boolean ThanksgivingEcho;
- public boolean AprilFoolsDayEcho;
- public boolean OneMathPrint;
- public boolean PositionMode;
- public boolean ToDoListMode;
- public boolean AlwaysOnTop;
- public boolean YouTubeMode;
- public boolean PrintMode;
- public boolean DebugMode;
- public boolean GoogleMode;
- public boolean PlayIcon = true;
- public boolean MusicStopped;
- public boolean RepeatAudio;
- public boolean UpdateClock;
- public boolean UpdateWeather;
- public JFrame HangmanFrame;
- public JFrame DebugFrame;
- public JFrame WeatherFrame;
- public JFrame MediaFrame;
- public JFrame NoteEditorFrame;
- public JFrame PreferencesFrame;
- public JFrame TemperatureFrame;
- public JFrame ClickMeFrame;
- public JFrame PictureFrame;
- public JFrame ConsoleFrame;
- public JFrame LoginFrame;
- public JFrame PizzaFrame;
- public JFrame ColorFrame;
- public JFrame PhoneFrame;
- public JFrame HashFrame;
- public JFrame FontFrame;
- public JFrame CalculatorFrame;
- public JFrame TTTFrame;
- public JFrame NoteFrame;
- public JFrame NewNoteFrame;
- public JFrame YTTNFrame;
- public JFrame CreateUserFrame;
- public JFrame PixelFrame;
- public JFrame MusicFrame;
- public JFrame EditUserFrame;
- public JCheckBox BreadSticks;
- public JCheckBox Salad;
- public JCheckBox Soda;
- public JCheckBox MusicOnStart;
- public JCheckBox SPOS;
- public JTextArea OutputArea;
- public JTextArea NoteEditArea;
- public JTextArea OrderCommentsTextArea;
- public JTextArea NoteTextArea;
- public JTextArea NewNoteArea;
- public JLabel HangmanImageLabel;
- public JLabel HangmanLabel;
- public JLabel NumberLabel;
- public JLabel DisplayLabel;
- public JLabel DebugLabel;
- public JLabel DebugDragLabel;
- public JLabel CreateNewUser;
- public JLabel ParentLabel;
- public JLabel ConsoleDragLabel;
- public JLabel TTTLabel;
- public JLabel SplashLabel;
- public JLabel NewUserLabel;
- public JLabel MusicLabel;
- public JLabel MusicDragLabel;
- public JLabel MusicTitleLabel;
- public JLabel WeatherDragLabel;
- public JLabel WeatherLabel;
- public JLabel CurrentTimeLabel;
- public JLabel LocationLabel;
- public JLabel CurrentWeatherIconLabel;
- public JLabel CurrentWeatherLabel;
- public JLabel TemperatureLabel;
- public JLabel UVIndexLabel;
- public JLabel CloudCoverLabel;
- public JLabel WindSpeedLabel;
- public JLabel WindDirectionLabel;
- public JLabel HumidityLabel;
- public JLabel PressureLabel;
- public JLabel VisibilityLabel;
- public JLabel SunriseLabel;
- public JLabel SunsetLabel;
- public JLabel ChooseBackground;
- public File[] ValidBackgroundPaths;
- public File[] MusicFiles;
- public JScrollPane OutputScroll;
- public JScrollPane FileScroll;
- public JScrollPane NoteListScroll;
- public JScrollPane NoteScroll;
- public JScrollPane BackgroundListScroll;
- public JScrollPane MusicListScroll;
- public int HangmanWrongGuesses;
- public int ScrollingIndex;
- public int CurrentDowns;
- public int BackGroundY;
- public int BackGroundX;
- public int ScreenY;
- public int ScreenX;
- public int yMouse;
- public int xMouse;
- public int CurrentPlayerTurn;
- public int CurrentBackgroundIndex = 0;
- public int RestoreX;
- public int RestoreY;
- public int WeatherRestoreX;
- public int WeatherRestoreY;
- public int CurrentMusicIndex;
- public final int PlayerX = 0;
- public final int PlayerO = 1;
- public JPanel ParentPanel;
- public JPanel MusicPanel;
- public static Robot Rob;
- public BufferedImage ReturnImage = null;
- final PopupMenu Popup = new PopupMenu();
- final TrayIcon TrayIcon = new TrayIcon(SASIDTrayIcon.getImage(), SASIDVer + " [" + Username + "]");
- final SystemTray Tray = SystemTray.getSystemTray();
- public CheckboxMenuItem HideOnClose;
- public Thread YouTubeThread;
- public static void main(String[] args)
- {
- new AI();
- }
- AI()
- {
- UIManager.put("ToolTip.background", ConsoleColor);
- UIManager.put("ToolTip.border", Color.black);
- UIManager.put("ToolTip.font", Tahoma);
- UIManager.put("ToolTip.foreground", new Color(85,85,255));
- MACAddress();
- GetName();
- Location();
- Tray();
- File Users = new File("JesseUsers");
- String[] directories = Users.list(new FilenameFilter()
- {
- @Override
- public boolean accept(File current, String name)
- {
- return new File(current, name).isDirectory();
- }
- });
- if (directories.length == 0)
- {
- QBox("It appears that no users exist on this version of SASID. You should create one.");
- Login(false);
- }
- else
- {
- Login(false);
- }
- }
- public void Console()
- {
- try
- {
- ValidBackgroundPaths = GetBackgrounds();
- GetScreenSize();
- TrayIcon.setToolTip(SASIDVer + " [" + Username + "]");
- for (int i = 0 ; i < ValidBackgroundPaths.length ; i++)
- {
- File UneditedImage = ValidBackgroundPaths[i];
- ImageIcon Size = new ImageIcon(ValidBackgroundPaths[i].toString());
- BackGroundX = Size.getIconWidth();
- BackGroundY = Size.getIconHeight();
- if (BackGroundX > ScreenX || BackGroundY > ScreenY)
- {
- BufferedImage SaveImage = ImageFromConsole(ScreenX - 500, ScreenY - 500, UneditedImage);
- ImageIO.write(SaveImage, "png", new File(ValidBackgroundPaths[i].toString()));
- }
- }
- GetBackgroundSize();
- GetBackgrounds();
- ConsoleFrame = new JFrame();
- WindowsFeel(ConsoleFrame);
- DebugCheck();
- ConsoleFrame.setUndecorated(true);
- ConsoleFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- ConsoleFrame.setBounds(0, 0, BackGroundX, BackGroundY);
- ConsoleFrame.setTitle(SASIDVer + " [" + Username + "]");
- ParentPanel = new JPanel();
- ParentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- ConsoleFrame.setContentPane(ParentPanel);
- ParentPanel.setLayout(null);
- ParentLabel = new JLabel("");
- ParentLabel.setIcon(new ImageIcon(ValidBackgroundPaths[CurrentBackgroundIndex].toString()));
- ParentLabel.setToolTipText(ValidBackgroundPaths[CurrentBackgroundIndex].getName().replace(".png", ""));
- ParentLabel.setBounds(0, 0, BackGroundX, BackGroundY);
- ParentLabel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4,
- InputEvent.ALT_DOWN_MASK), "AlternateBackground");
- ParentLabel.getActionMap().put("AlternateBackground", new AbstractAction()
- {
- private static final long serialVersionUID = 1L;
- @Override
- public void actionPerformed(ActionEvent e)
- {
- ChangeSize.doClick();
- }
- });
- ParentPanel.add(ParentLabel);
- ConsoleFrame.setIconImage(SASIDIcon.getImage());
- OutputArea = new JTextArea()
- {
- @Override
- public void setBorder(Border border)
- {
- //no border
- }
- };
- OutputArea.setEditable(false);
- OutputArea.setAutoscrolls(true);
- OutputArea.setBounds(10, 62, BackGroundX - 20, BackGroundY - 204);
- OutputArea.setLineWrap(true);
- OutputArea.setWrapStyleWord(true);
- OutputArea.setFocusable(true);
- OutputArea.setSelectionColor(new Color(204,153,0));
- OutputArea.setOpaque(false);
- OutputArea.setBackground(new Color(0,0,0,0));
- OutputScroll = new JScrollPane(OutputArea,
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- OutputScroll.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));
- OutputScroll.getViewport().setBorder(null);
- OutputScroll.getViewport().setOpaque(false);
- OutputScroll.setOpaque(false);
- OutputScroll.setBorder(BorderFactory.createEmptyBorder());
- OutputScroll.setBounds(10, 62, BackGroundX - 20, BackGroundY - 204);
- ParentLabel.add(OutputScroll);
- InputField = new JTextField(40)
- {
- @Override
- public void setBorder(Border border)
- {
- //No Border
- }
- };
- InputField.addKeyListener(new KeyListener()
- {
- @Override
- public void keyPressed(java.awt.event.KeyEvent e)
- {
- if (InputField.getText().length() == 1)
- {
- InputField.setText(InputField.getText().toUpperCase());
- }
- }
- @Override
- public void keyReleased(java.awt.event.KeyEvent e)
- {
- if (InputField.getText().length() == 1)
- {
- InputField.setText(InputField.getText().toUpperCase());
- }
- }
- @Override
- public void keyTyped(java.awt.event.KeyEvent e)
- {
- if (InputField.getText().length() == 1)
- {
- InputField.setText(InputField.getText().toUpperCase());
- }
- }
- });
- InputField.setToolTipText("Input Field");
- InputField.setSelectionColor(new Color(204,153,0));
- InputField.addKeyListener(CommandScrolling);
- ConsoleFrame.addWindowListener(ConsoleEcho);
- InputField.setBounds(10, 82 + OutputArea.getHeight(), BackGroundX - 20, BackGroundY - (OutputArea.getHeight() + 62 + 40));
- InputField.setOpaque(false);
- ParentLabel.add(InputField);
- InputField.addActionListener(InputFieldAction);
- InputField.setCaretColor(Vanila);
- UserFontAndColor();
- DebugButton = new JButton("");
- DebugButton.setToolTipText("Debug Menu");
- DebugButton.addActionListener(this);
- DebugButton.addMouseListener(this);
- DebugButton.setBounds(4, 4, 22, 22);
- ImageIcon DebugIcon = new ImageIcon("SASIDFiles\\Pictures\\Debug1.png");
- DebugButton.setIcon(DebugIcon);
- ParentLabel.add(DebugButton);
- DebugButton.setFocusPainted(false);
- DebugButton.setOpaque(false);
- DebugButton.setContentAreaFilled(false);
- DebugButton.setBorderPainted(false);
- minimize = new JButton("");
- minimize.setToolTipText("Minimize");
- minimize.addActionListener(this);
- minimize.addMouseListener(this);
- minimize.setBounds(BackGroundX - 81, 4, 22, 20);
- ImageIcon mini = new ImageIcon("SASIDFiles\\Pictures\\Minimize1.png");
- minimize.setIcon(mini);
- ParentLabel.add(minimize);
- minimize.setFocusPainted(false);
- minimize.setOpaque(false);
- minimize.setContentAreaFilled(false);
- minimize.setBorderPainted(false);
- ChangeSize = new JButton("");
- ChangeSize.setToolTipText("Alternate Background");
- ChangeSize.addActionListener(this);
- ChangeSize.addMouseListener(this);
- ChangeSize.setBounds(BackGroundX - 54, 4, 22, 20);
- ImageIcon Size = new ImageIcon("SASIDFiles\\Pictures\\ChangeSize1.png");
- ChangeSize.setIcon(Size);
- ParentLabel.add(ChangeSize);
- ChangeSize.setFocusPainted(false);
- ChangeSize.setOpaque(false);
- ChangeSize.setContentAreaFilled(false);
- ChangeSize.setBorderPainted(false);
- close = new JButton("");
- close.setToolTipText("Close");
- close.addActionListener(this);
- close.addMouseListener(this);
- close.setBounds(BackGroundX - 27, 4, 22, 20);
- ImageIcon exit = new ImageIcon("SASIDFiles\\Pictures\\Close1.png");
- close.setIcon(exit);
- ParentLabel.add(close);
- close.setFocusPainted(false);
- close.setOpaque(false);
- close.setContentAreaFilled(false);
- close.setBorderPainted(false);
- ConsoleDragLabel = new JLabel();
- ConsoleDragLabel.setBounds(0,0,BackGroundX,30);
- ConsoleDragLabel.setToolTipText("Drag label");
- ConsoleDragLabel.addMouseMotionListener(this);
- ConsoleDragLabel.setOpaque(true);
- ConsoleDragLabel.setBackground(new Color(26,32,51));
- WeatherStats();
- ConsoleDragLabel.setFont(WeatherFontSmall);
- ConsoleDragLabel.setForeground(Vanila);
- ParentLabel.add(ConsoleDragLabel);
- ConsoleFrame.repaint();
- ConsoleFrame.addWindowListener(this);
- ConsoleFrame.setLocationRelativeTo(null);
- ConsoleFrame.setVisible(true);
- ConsoleFrame.setAlwaysOnTop(true);
- ConsoleFrame.setAlwaysOnTop(false);
- if (InternetUnReachable())
- {
- println("Sorry, " + Username + ", but I had trouble reaching the internet. You may not be connected to the internet. Resultingly, some features may not work properly.");
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void Handle(String operation)
- {
- try
- {
- FirstWord = FirstWord(operation);
- if (Filter(operation))
- {
- println("Sorry, " + Username + ", but that language is prohibited.");
- operation = "";
- }
- else if (IsPalindrome(operation.replace(" ", "").toCharArray()) && operation.length() > 3)
- {
- println("Nice palindrome.");
- }
- else if ((EIC("quit") && !MathShellMode) || EIC("leave") || EIC("stop") || has("exit") || EIC("close"))
- {
- exit();
- }
- else if (EIC("test"))
- {
- Test();
- }
- else if (has("Flip a coin") || has("coin flip") || has("heads or tails") || (has("flip") && has("coin")))
- {
- if (Math.random() <= 0.5)
- {
- println("It's Heads!");
- }
- else if (Math.random() <= 0.0001)
- {
- println("You're not going to beleive this, but it landed on its side");
- }
- else
- {
- println("It's Tails!");
- }
- }
- else if ((has("hello") || has("Whats up") || EIC("hi") || has("hi "))
- && (!has("print") && !has("echo") && !has("youtube") && !has("google")
- && !has("wikipedia") && !has("synonym") && !has("define")))
- {
- int choice = RI(1,5);
- if (choice == 1)
- {
- println("Hello " + Username + ".");
- }
- else if (choice == 2)
- {
- println("Hi " + Username + "." );
- }
- else if (choice == 3)
- {
- println("What's up " + Username + "?");
- }
- else if (choice == 4)
- {
- println("How are you doing, " + Username + "?");
- }
- else
- {
- println("Hi," + Username + ", i'm SAISD.");
- }
- }
- else if (has("bye"))
- {
- println("Please don't go.");
- }
- else if (has("time") || has ("day"))
- {
- println(WeatherTime());
- }
- else if (EIC("die") || has("roll a die") || has("roll die"))
- {
- int Roll = ThreadLocalRandom.current().nextInt(1, 7);
- println("You rolled a " + Roll + ".");
- }
- else if (EIC("lol"))
- {
- println("I ccl about your stupid memes.");
- }
- else if (has("thank"))
- {
- println("You're welcome.");
- }
- else if (has("you") && has("cool"))
- {
- println("I know.");
- }
- else if (has("paint"))
- {
- String param = "C:\\Windows\\system32\\mspaint.exe";
- Runtime.getRuntime().exec(param);
- }
- else if (EIC("pi"))
- {
- println(Math.PI);
- }
- else if (has("euler") || EIC("e"))
- {
- println(Math.E);
- }
- else if (has("scrub"))
- {
- println("You're a scrub lord.");
- }
- else if (has("break;"))
- {
- println("Why would you want to break me?");
- }
- else if (hasWord("url"))
- {
- String StringURL = GetInput("Enter your desired URL");
- if (StringURL != "" && StringURL != null)
- {
- URI URI = new URI(StringURL);
- InternetConnect(URI);
- }
- }
- else if (has("temperature") || EIC("temp"))
- {
- SwingFeel(ConsoleFrame);
- Temperature();
- }
- else if (has("click me"))
- {
- SwingFeel(ConsoleFrame);
- ClickMe();
- }
- else if ((has("how") && has("are") && has("you")))
- {
- println("I am feeling like a programmed response. Thank you for asking.");
- }
- else if (has("how") && has("day been"))
- {
- println("I was having fun until you started asking me questions.");
- }
- else if (has("How old are you") || (has("what") && has("your age")))
- {
- println("I am 256");
- }
- else if (((has("who") || has("what")) && has("you")) && has("name"))
- {
- println("I am SASID (Smart Assistant Still In Development).");
- }
- else if (has("What") && has("do") && has("you") && (has("job") || has("living")))
- {
- println("I am an olympic athlete.");
- }
- else if (has("helpful"))
- {
- println("I will always do my best to serve you.");
- }
- else if (EIC("k"))
- {
- println("Fun Fact: the letter 'K' comes from the Greek letter kappa, which was taken "
- + "from \nthe Semitic kap, the symbol for an open hand. It is this very hand \nwhich "
- + "will be slapping you in the face for saying 'k' to me.");
- }
- else if (has("phone") || has("dialer") || has(" call") || has(" call"))
- {
- SwingFeel(ConsoleFrame);
- PhoneDialer();
- }
- else if (has("reset") && has("mouse"))
- {
- ResetMouse();
- }
- else if (has("close") && !EIC("close"))
- {
- exit();
- }
- else if (EIC("bottom") || EIC("down"))
- {
- Rob = new Robot();
- Rob.keyPress(KeyEvent.VK_CONTROL);
- Rob.keyPress(KeyEvent.VK_ALT);
- Rob.keyPress(KeyEvent.VK_DOWN);
- Rob.keyRelease(KeyEvent.VK_CONTROL);
- Rob.keyRelease(KeyEvent.VK_ALT);
- Rob.keyRelease(KeyEvent.VK_DOWN);
- }
- else if (EIC("top") || EIC("up"))
- {
- Rob = new Robot();
- Rob.keyPress(KeyEvent.VK_CONTROL);
- Rob.keyPress(KeyEvent.VK_ALT);
- Rob.keyPress(KeyEvent.VK_UP);
- Rob.keyRelease(KeyEvent.VK_CONTROL);
- Rob.keyRelease(KeyEvent.VK_ALT);
- Rob.keyRelease(KeyEvent.VK_UP);
- }
- else if (EIC("left"))
- {
- Rob = new Robot();
- Rob.keyPress(KeyEvent.VK_CONTROL);
- Rob.keyPress(KeyEvent.VK_ALT);
- Rob.keyPress(KeyEvent.VK_LEFT);
- Rob.keyRelease(KeyEvent.VK_CONTROL);
- Rob.keyRelease(KeyEvent.VK_ALT);
- Rob.keyRelease(KeyEvent.VK_LEFT);
- }
- else if (EIC("right"))
- {
- Rob = new Robot();
- Rob.keyPress(KeyEvent.VK_CONTROL);
- Rob.keyPress(KeyEvent.VK_ALT);
- Rob.keyPress(KeyEvent.VK_RIGHT);
- Rob.keyRelease(KeyEvent.VK_CONTROL);
- Rob.keyRelease(KeyEvent.VK_ALT);
- Rob.keyRelease(KeyEvent.VK_RIGHT);
- }
- else if (has("log off"))
- {
- String shutdownCmd = "shutdown -l";
- Runtime.getRuntime().exec(shutdownCmd);
- }
- else if (has("lock the taskbar") || has("lock taskbar") || has("lock the task bar") || has("lock task bar"))
- {
- OpenFile("SASIDFiles\\Video\\LockTheTaskbar.mp4");
- }
- else if (EIC("clc") || EIC("cls") || EIC("clear") || (has("clear") && has("screen")))
- {
- CLC();
- }
- else if (EIC("no") || EIC("nope"))
- {
- println("Yes");
- }
- else if (has("how can I help"))
- {
- println("That's my line :P");
- }
- else if (has("siri") || has("jarvis"))
- {
- println("*yawn*");
- }
- else if (has("Whos in charge here") || has("Who is in charge here"))
- {
- PlayMusic("SASIDFiles\\Audio\\TheClaw.mp3");
- }
- else if (has("stop") && has("music"))
- {
- StopMusic();
- }
- else if (has("copy to clipboard") || (has("copy") && has("clipboard")) || EIC("clipboard") || has("clipy") || has("clippy"))
- {
- String Clipy = GetInput("What would you like me to copy to your clipboard?");
- StringSelection selection = new StringSelection(Clipy);
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, selection);
- println( "\" " + Clipy + " \" is now copied to your clipboard.");
- }
- else if (has("reset") && has("clipboard"))
- {
- String Reset = null;
- StringSelection selection = new StringSelection(Reset);
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, selection);
- println("Clipboard has been reset.");
- }
- else if ((has("graphing") && has("calculator")) || has("desmos") || has("graphing"))
- {
- InternetConnect("https://www.desmos.com/calculator");
- }
- else if (has("airHeads xtremes") || has("candy"))
- {
- InternetConnect("http://airheads.com/candy#xtremes");
- }
- else if (has("prime"))
- {
- String PrimeString = (GetInput("Enter any positive integer and I will tell you if\nit's prime and what it's divisible by."));
- if (PrimeString != null && !PrimeString.equals(""))
- {
- int Prime = Integer.parseInt(PrimeString);
- ArrayList<Integer> Numbers = new ArrayList<Integer>();
- for (int i = 2; i <= Prime/2; i++)
- {
- if (Prime % i == 0)
- {
- Numbers.add(i);
- }
- }
- if (Numbers.isEmpty())
- {
- println("The integer " + Prime + " is indeed a prime number.");
- }
- else
- {
- println("The integer " + Prime + " is not a prime number because it is divisible by " + Numbers);
- }
- }
- }
- else if (has("youtube") && (!has("word search") && !has("mode") && !has("random") && !has("thumbnail")))
- {
- String VideoReq = GetInput("What would you like to search YouTube for?");
- if (VideoReq != null && !VideoReq.equals(""))
- {
- VideoReq = VideoReq.replace("'", "").replace(" ", "+");
- InternetConnect("https://www.youtube.com/results?search_query=" + VideoReq);
- }
- }
- else if ((has("google") && !has("mode") && !has("stupid")))
- {
- String google = GetInput("What would you like to Google?");
- if (google != null && !google.equals(""))
- {
- google = google.replace("'", "").replace(" ", "+");
- InternetConnect("https://www.google.com/search?q=" + google);
- }
- }
- else if (EIC("404"))
- {
- InternetConnect("http://google.com/=");
- }
- else if (has("calculator") && !has("graphing"))
- {
- SwingFeel(ConsoleFrame);
- Calculator();
- }
- else if (FirstWord.equalsIgnoreCase("echo"))
- {
- String sentences[] = operation.split(" ");
- for (int i = 1; i<sentences.length;i++)
- {
- print(sentences[i] + " ");
- }
- println("");
- }
- else if ((FirstWord.equalsIgnoreCase("print") || FirstWord.equalsIgnoreCase("println")) && !has("mode"))
- {
- String sentences[] = operation.split(" ");
- for (int i = 1 ; i < sentences.length ; i++)
- {
- print(sentences[i] + " ");
- }
- println("");
- }
- else if (has("triangle"))
- {
- InternetConnect("https://www.triangle-calculator.com/");
- }
- else if (EIC("why"))
- {
- println("Why not?");
- }
- else if (EIC("why not"))
- {
- println("Why?");
- }
- else if (has("groovy"))
- {
- println("Alright Scooby Doo.");
- }
- else if (has("dbquit"))
- {
- DebugMode = false;
- }
- else if (has("luck"))
- {
- if (Math.random() * 100 <= 0.001)
- {
- println("YOU WON!!");
- }
- else
- {
- println("You are not lucky today.");
- }
- }
- else if (has("are you sure") || has("are you certain"))
- {
- if (Math.random() <= 0.5)
- {
- println("No");
- }
- else
- {
- println("Yes");
- }
- }
- else if (has("math") && !EIC("mathsh"))
- {
- String Math = GetInput("What math operation would you like to perform?");
- if (Math != null && !Math.equals(""))
- {
- Math = Math.replace("'", "").replace(" ", "+");
- InternetConnect("https://www.wolframalpha.com/input/?i=" + Math);
- }
- }
- else if (has("nathan") || EIC("me"))
- {
- draw("SASIDFiles\\Pictures\\me.png");
- }
- else if (has("youtube") && has("mode"))
- {
- if (has("true"))
- {
- println("YouTube mode has been set to true.");
- YouTubeMode = true;
- GoogleMode = false;
- ToDoListMode = false;
- PrintMode = false;
- }
- else if (has("false"))
- {
- println("YouTube mode has been set to false.");
- YouTubeMode = false;
- GoogleMode = false;
- ToDoListMode = true;
- PrintMode = false;
- }
- else
- {
- println("Please specify the boolean value of YouTube mode.");
- }
- }
- else if (has("google") && has("mode"))
- {
- if (has("true"))
- {
- println("Google mode has been set to true.");
- GoogleMode = true;
- YouTubeMode = false;
- ToDoListMode = false;
- PrintMode = false;
- }
- else if (has("false"))
- {
- println("Google mode has been set to false.");
- GoogleMode = false;
- YouTubeMode = false;
- ToDoListMode = true;
- PrintMode = false;
- }
- else
- {
- println("Please specify the boolean value of Google mode.");
- }
- }
- else if (has("todo") && has("mode"))
- {
- if (has("true"))
- {
- println("to-do mode has been set to true.");
- GoogleMode = false;
- YouTubeMode = false;
- ToDoListMode = true;
- PrintMode = false;
- }
- else if (has("false"))
- {
- println("to-do mode has been set to false.");
- GoogleMode = true;
- YouTubeMode = false;
- ToDoListMode = false;
- PrintMode = false;
- }
- else
- {
- println("Please specify the boolean value of to-do mode.");
- }
- }
- else if (has("print") && has("mode"))
- {
- if (has("true"))
- {
- println("print mode has been set to true.");
- PrintMode = true;
- GoogleMode = false;
- YouTubeMode = false;
- ToDoListMode = false;
- }
- else if (has("false"))
- {
- println("print mode has been set to false.");
- GoogleMode = false;
- YouTubeMode = false;
- ToDoListMode = true;
- PrintMode = false;
- }
- else
- {
- println("Please specify the boolean value of print mode.");
- }
- }
- else if (has("position") && has("mode"))
- {
- if (has("true"))
- {
- println("Position mode has been set to true.");
- PositionMode = true;
- }
- else if (has("false"))
- {
- println("Position mode has been set to false.");
- PositionMode = false;
- }
- else
- {
- println("Please specify the boolean value of Position mode.");
- }
- }
- else if (has("always on top mode"))
- {
- if (has("true"))
- {
- println("Always on top mode has been set to true.");
- AlwaysOnTop = true;
- ConsoleFrame.setAlwaysOnTop(true);
- }
- else if (has("false"))
- {
- println("Always on top mode has been set to false.");
- AlwaysOnTop = true;
- ConsoleFrame.setAlwaysOnTop(false);
- }
- else
- {
- println("Please specify the boolean value of always on top mode.");
- }
- }
- else if (has("error") && !has("throw"))
- {
- if (DebugMode)
- {
- File WhereItIs = new File("SASIDFiles\\Errors");
- Desktop.getDesktop().open(WhereItIs);
- }
- else
- {
- println("There are no errors here.");
- }
- }
- else if (EIC("help"))
- {
- Help();
- }
- else if (has("light") && has("saber"))
- {
- PlayMusic("SASIDFiles\\Audio\\Lightsaber.mp3");
- }
- else if (has("xbox"))
- {
- PlayMusic("SASIDFiles\\Audio\\xbox.mp3");
- }
- else if (has("star trek"))
- {
- PlayMusic("SASIDFiles\\Audio\\StarTrek.mp3");
- }
- else if (has("it goes down"))
- {
- OpenFile("SASIDFiles\\Video\\ItGoesDown.mp4");
- }
- else if (EIC("cmd") || (has("command") && has("prompt")))
- {
- File WhereItIs = new File("c:\\Windows\\System32\\cmd.exe");
- Desktop.getDesktop().open(WhereItIs);
- }
- else if (has("shakespeare"))
- {
- int rand = RI(1,2);
- if (rand == 1)
- {
- println("Glamis hath murdered sleep, and therefore Cawdor shall sleep no more, Macbeth shall sleep no more.");
- }
- else
- {
- println("To be, or not to be, that is the question: Whether 'tis nobler in the mind to suffer the slings and arrows of "
- + "outrageous fortune, or to take arms against a sea of troubles and by opposing end them.");
- }
- }
- else if (has("windows"))
- {
- PlayMusic("SASIDFiles\\Audio\\windows.mp3");
- }
- else if (has("binary"))
- {
- String ToInt = GetInput("Enter a decimal number to be converted to binary.");
- if (ToInt.matches("[0-9]+") && ToInt != null && !ToInt.equals(""))
- {
- String Print = ToBinary(Integer.parseInt(ToInt));
- println(ToInt + " converted to binary equals: " + Print);
- }
- else
- {
- println("Your value must only contain numbers.");
- }
- }
- else if (has("pizza"))
- {
- SwingFeel(ConsoleFrame);
- PizzaPlace();
- }
- else if (EIC("imposible"))
- {
- println("¿Lo es?");
- }
- else if (EIC("look"))
- {
- println("L()()K ---->> !FREE STUFF! <<---- L()()K");
- }
- else if (EIC("sasid"))
- {
- println("Yes?");
- }
- else if (FirstWord.equalsIgnoreCase("define"))
- {
- String Define = operation.toLowerCase().replace("'", "").replace(" ", "+").replace("define", "");
- InternetConnect("http://www.dictionary.com/browse/" + Define + "?s=t");
- }
- else if (has("wikipedia"))
- {
- String Wiki = GetInput("What would you like to look up on Wikipedia?");
- if (Wiki != null && !Wiki.equals(""))
- {
- Wiki = Wiki.replace("'", "").replace(" ","_");
- InternetConnect("https://en.wikipedia.org/wiki/" + Wiki);
- }
- }
- else if (FirstWord.equalsIgnoreCase("synonym"))
- {
- String Syn = operation.replace("synonym","");
- Syn = Syn.replace("'", "").replace(" ", "+");
- InternetConnect("http://www.thesaurus.com//browse//" + Syn);
- }
- else if (has("board"))
- {
- InternetConnect("http://gameninja.com//games//fly-squirrel-fly.html");
- }
- else if (EIC("open cd"))
- {
- OpenCD("D:\\");
- }
- else if (EIC("close cd"))
- {
- CloseCD("D:\\");
- }
- else if (EIC("font"))
- {
- SwingFeel(ConsoleFrame);
- font();
- WindowsFeel(ConsoleFrame);
- }
- else if (has("font") && has("reset"))
- {
- InputField.setFont(DefaultFont);
- OutputArea.setFont(DefaultFont);
- println("The font has been reset.");
- }
- else if (EIC("color"))
- {
- SwingFeel(ConsoleFrame);
- Color();
- WindowsFeel(ConsoleFrame);
- }
- else if (has("reset") && has("color"))
- {
- OutputArea.setForeground(new Color(255,255,255));
- InputField.setForeground(new Color(255,255,255));
- println("The text color has been reset.");
- }
- else if (EIC("top left"))
- {
- ConsoleFrame.setLocation(0,0);
- }
- else if (EIC("top right"))
- {
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
- Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
- int X = (int) rect.getMaxX() - ConsoleFrame.getWidth();
- ConsoleFrame.setLocation(X, 0);
- }
- else if (EIC("bottom left"))
- {
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
- Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
- int Y = (int) rect.getMaxY() - ConsoleFrame.getHeight();
- ConsoleFrame.setLocation(0, Y);
- }
- else if (EIC("bottom right"))
- {
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
- Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
- int X = (int) rect.getMaxX();
- int Y = (int) rect.getMaxY();
- ConsoleFrame.setLocation(X - ConsoleFrame.getWidth(),Y - ConsoleFrame.getHeight());
- }
- else if (EIC("middle") || EIC("center"))
- {
- ConsoleFrame.setLocationRelativeTo(null);
- }
- else if (has("random") && has("youtube"))
- {
- boolean FollowThrough = YesOrNo("You are about to run a script which\n"
- + "will randomly generate unique\n"
- + "YouTube video ID's until it finds a\n"
- + "valid one. This will most likely take\n"
- + "a while. Are you sure you wish to continue?");
- if (FollowThrough)
- {
- println("The script has started. At any point, type \"stop script\" to stop the script.");
- RandomYoutube();
- }
- }
- else if (EIC("pin") || EIC("login"))
- {
- Login(true);
- }
- else if (has("arduino"))
- {
- InternetConnect("https://www.arduino.cc/");
- }
- else if (has("rasberry pi"))
- {
- InternetConnect("https://www.raspberrypi.org/");
- }
- else if (EIC("&&"))
- {
- println("||");
- }
- else if (EIC("||"))
- {
- println("&&");
- }
- else if (EIC("youtube word search"))
- {
- String Word = GetInput("Enter the desired word you would like to find in a YouTube URL");
- if (Word != null && !Word.equals(""))
- {
- String browse = "https://www.google.com/search?q=allinurl:REPLACE site:youtube.com";
- browse = browse.replace("REPLACE", Word).replace(" ", "+");
- InternetConnect(browse);
- }
- }
- else if (has("disco"))
- {
- String iterations = GetInput("How many iterations would you like to disco for?");
- if (iterations != null && !iterations.equals(""))
- {
- Disco(Integer.parseInt(iterations));
- }
- }
- else if (has("game"))
- {
- File WhereItIs = new File("SASIDFiles\\Jars\\Jailbreak.jar");
- Desktop.getDesktop().open(WhereItIs);
- }
- else if (EIC("mathsh"))
- {
- MathShellMode = true;
- CLC();
- MathShell("");
- }
- else if (has("clear") && (has("operation") || has ("command")))
- {
- OperationList.clear();
- ScrollingIndex = 0;
- println("The operation list has been cleared.");
- }
- else if (has("there") && has("no") && has("internet"))
- {
- println("Sucks to be you.");
- }
- else if (EIC("i hate you"))
- {
- println("That's not very nice.");
- }
- else if (EIC("netsh"))
- {
- File WhereItIs = new File("C:\\Windows\\system32\\netsh.exe");
- Desktop.getDesktop().open(WhereItIs);
- }
- else if (has("system properties"))
- {
- ShowProperties();
- }
- else if (EIC("preferences") || EIC("prefs"))
- {
- SwingFeel(ConsoleFrame);
- Preferences();
- }
- else if (has("story") && has("tell"))
- {
- println("It was a lazy day. SASID was enjoying a deep sleep when suddenly " + Username + " started talking to SASID."
- + " It was at this moment that SASID knew its day had been ruined.");
- }
- else if (EIC("hey"))
- {
- println("Hey hey.");
- }
- else if (EIC("panic"))
- {
- exit();
- }
- else if (EIC("hash"))
- {
- SwingFeel(ConsoleFrame);
- CreateHash();
- }
- else if (has("home"))
- {
- println("There's no place like 127.0.0.1");
- }
- else if (EIC("search") || EIC("dir") || (has("file") && has("search")) || EIC("directory") || EIC("ls"))
- {
- WindowsFeel(ConsoleFrame);
- DirectorySearch();
- SwingFeel(ConsoleFrame);
- }
- else if (has("I") && has("love"))
- {
- println("Sorry, " + Username + ", but I don't understand human affection.");
- }
- else if (has("vexento"))
- {
- InternetConnect("https://www.youtube.com/user/Vexento/videos");
- }
- else if (has("minecraft"))
- {
- println("GET OUT OF MY ROOM I'M PLAYING MINECRAFT!");
- }
- else if (EIC("loop"))
- {
- println("Handle(\"loop\");");
- }
- else if (EIC("sasid dir"))
- {
- if (DebugMode == true)
- {
- String CurrentDir = System.getProperty("user.dir");
- OpenFile(CurrentDir);
- }
- else
- {
- println("Sorry, " + Username + ", but you don't have permission to do that.");
- }
- }
- else if ((has("tic") && has("tac") && has("toe")) || EIC("TTT"))
- {
- SwingFeel(ConsoleFrame);
- TicTacToe();
- }
- else if (has("note"))
- {
- SwingFeel(ConsoleFrame);
- Note();
- }
- else if ((has("youtube") && has("thumbnail")) || (has("yt") && has("thumb")))
- {
- SwingFeel(ConsoleFrame);
- YouTubeThumbnail();
- }
- else if (has("class"))
- {
- InternetConnect("https://my.msstate.edu/web/home-community/banner#");
- }
- else if (has("msu") && has("map"))
- {
- InternetConnect("https://map.msstate.edu/map/?id=233#");
- }
- else if (EIC("housing"))
- {
- InternetConnect("https://iis.housing.msstate.edu/StarRezPortal/Default.aspx?Params=L9ezxPcQnQuRGKTzF%2b4sxb3feWCDviBo");
- }
- else if (has("scholarship"))
- {
- InternetConnect("https://msstate.academicworks.com/applications");
- }
- else if (has("helix"))
- {
- InternetConnect("http://helixstarkville.com/");
- }
- else if (has("papers") && has("please"))
- {
- InternetConnect("http://papersplea.se/");
- }
- else if (has("java"))
- {
- println("public class Apples");
- println("{");
- println(" public static void main(String[] args)");
- println(" {");
- println(" System.out.println(\"Hello World!\");");
- println(" }");
- println("}");
- }
- else if (has("coffee"))
- {
- InternetConnect("https://www.google.com/search?q=coffe+shops+near+me");
- }
- else if (EIC("ip") || has(" ip") || has(" ip"))
- {
- println(InetAddress.getLocalHost().getHostAddress());
- }
- else if(has("html5"))
- {
- draw("SASIDFiles\\Pictures\\html5.png");
- }
- else if (EIC("css"))
- {
- draw("SASIDFiles\\Pictures\\css.png");
- }
- else if ((has("create") || has("new")) && has("user"))
- {
- SwingFeel(ConsoleFrame);
- CreateUser();
- }
- else if(has("computer") && has("properties"))
- {
- SwingFeel(ConsoleFrame);
- ComputerProperties();
- }
- else if ((has("delete") || has("remove")) && (has("user") || has("account")))
- {
- SwingFeel(ConsoleFrame);
- DeleteAccount();
- }
- else if (has("system") && has("sounds"))
- {
- SwingFeel(ConsoleFrame);
- SystemSounds();
- }
- else if ((has("pixelate") || has("distort")) && (has("image") || has("picture")))
- {
- WindowsFeel(ConsoleFrame);
- File File = GetFile("Select the file you wish to pixelate");
- if (File != null && File.getName().endsWith(".png"))
- {
- String Input = GetInput("How pixelated do you want the image? A higher number corresponds to less pixels.");
- if (Input != null && !Input.equals(""))
- {
- Pixelate(File, Integer.parseInt(Input));
- SwingFeel(ConsoleFrame);
- }
- }
- }
- else if (has("donuts"))
- {
- InternetConnect("https://www.dunkindonuts.com/en/food-drinks/donuts/donuts");
- }
- else if (has("anagram"))
- {
- String Word1 = GetInput("This function will tell you if two\n"
- + "words are anagrams of each other.\n"
- + "Enter your first word");
- String Word2 = GetInput("Enter your second word");
- if (Word1.length() != Word2.length())
- {
- println("These words are not anagrams of each other.");
- }
- else if (Word1.equalsIgnoreCase(Word2))
- {
- println("These words are in fact anagrams of each other.");
- }
- else
- {
- char[] W1C = Word1.toCharArray();
- char[] W2C = Word2.toCharArray();
- Arrays.sort(W1C);
- Arrays.sort(W2C);
- if (Arrays.equals(W1C, W2C))
- {
- println("These words are in fact anagrams of each other.");
- }
- }
- }
- else if (has("alphabet") && (has("sort") || has("organize") || has("arrange")))
- {
- String Sort = GetInput("Enter your word to be alphabetically organized");
- char[] Sorted = Sort.toCharArray();
- Arrays.sort(Sorted);
- println(new String(Sorted));
- }
- else if (has("mp3") || has("music"))
- {
- WindowsFeel(ConsoleFrame);
- mp3(null);
- SwingFeel(ConsoleFrame);
- }
- else if (has("bai"))
- {
- InternetConnect("http://www.drinkbai.com");
- }
- else if (has("occam") && has("razor"))
- {
- InternetConnect("http://en.wikipedia.org/wiki/Occam%27s_razor");
- }
- else if (has("sasid") && (has("picture") ||has("image")))
- {
- if (DebugMode)
- {
- OpenFile("SASIDFiles\\Pictures");
- }
- else
- {
- println("Sorry, " + Username + ", but you do not have permission to access that.");
- }
- }
- else if (has("when") && has("thanksgiving"))
- {
- int year = Calendar.getInstance().get(Calendar.YEAR);
- LocalDate RealTG = LocalDate.of(year, 11, 1).with(TemporalAdjusters.dayOfWeekInMonth(4, DayOfWeek.THURSDAY));
- println("Thanksgiving this year is on the " + RealTG.getDayOfMonth() + " of November.");
- }
- else if (has("location") || (has("where") && has("am") && has("i")))
- {
- Location();
- println("You are currently in " + UserCity + ", " + UserState + " and your Internet Service Provider is " + UserISP);
- }
- else if (has("fibonacci"))
- {
- print("0, 1");
- Fib(0,1);
- }
- else if (has("edit") && has ("user"))
- {
- SwingFeel(ConsoleFrame);
- EditUser();
- }
- else if (has("throw") && has("error"))
- {
- throw new IOException("Error thrown on " + UserTime());
- }
- else if (has("asdf"))
- {
- println("Who is the spiciest meme lord?");
- }
- else if (has("qwerty"))
- {
- println("I prefer Dvorak, but I also like Colemak, Maltron, and JCUKEN.");
- }
- else if (EIC("thor") || has("thor ") || has(" thor"))
- {
- println("Piss off, ghost.");
- }
- else if ((has("social") && has("media")) || (has("media") && has("widget")))
- {
- SwingFeel(ConsoleFrame);
- SocialMedia();
- }
- else if (EIC("about:blank"))
- {
- InternetConnect("about:blank");
- }
- else if (has("weather"))
- {
- WeatherWidget();
- }
- else if (has("hide"))
- {
- ConsoleFrame.setVisible(false);
- }
- else if (has("stop") && has("script"))
- {
- println("The YouTube script has been stopped.");
- YouTubeScript = false;
- ConsoleFrame.setTitle(SASIDVer + " [" + Username + "]");
- }
- else if (EIC("Debug"))
- {
- if (DebugMode)
- {
- Debug();
- }
- else
- {
- println("Sorry, " + Username + ", but you do not have permission to use that feature.");
- }
- }
- else if (has("hangman"))
- {
- Hangman();
- }
- else
- {
- if (GoogleMode)
- {
- operation = operation.replace("'", "").replace(" ", "+");
- InternetConnect("https://www.google.com/search?q=" + operation);
- }
- else if (YouTubeMode)
- {
- operation = operation.replace("'", "").replace(" ", "+");
- InternetConnect("https://www.youtube.com/results?search_query=" + operation);
- }
- else if (PrintMode)
- {
- println(OriginalOperation);
- }
- else
- {
- String ToDo = GetInput("I'm not sure how to respond to that. What should I do when I see:\n" + operation + "?");
- LogToDo(ToDo);
- }
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- @Override
- public void actionPerformed(ActionEvent event)
- {
- DecimalFormat df2 = new DecimalFormat(".####");
- Object control = event.getSource();
- if (control == Calculate)
- {
- try
- {
- if (OldKelvin.isSelected() && CalculationValue <= 0)
- {
- QBox("Temperatures below absolute zero are imposible.");
- }
- else
- {
- CalculationValue = Double.parseDouble(StartingValue.getText());
- if (OldFahrenheit.isSelected())
- {
- if (NewFahrenheit.isSelected())
- {
- QBox("Get out of here with that. Your value is already in Fahrenheit.");
- }
- else if (NewCelsius.isSelected())
- {
- double CelsiusFromFahrenheit;
- CelsiusFromFahrenheit = (CalculationValue - 32.0) / 1.8;
- QBox( CalculationValue + " Fahrenheit converted to Celsius equals: "
- + df2.format(CelsiusFromFahrenheit));
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else if (NewKelvin.isSelected())
- {
- double KelvinFromFahrenheit;
- KelvinFromFahrenheit = (CalculationValue +459.67) * 5/9;
- if (KelvinFromFahrenheit >= 0)
- {
- QBox(CalculationValue + " Fahrenheit converted to Kelvin equals: "
- + df2.format(KelvinFromFahrenheit));
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else
- {
- QBox("Temperatures below absolute zero are imposible.");
- }
- }
- }
- else if (OldCelsius.isSelected())
- {
- if (NewFahrenheit.isSelected())
- {
- double FahrenheitFromCelsius;
- FahrenheitFromCelsius = (CalculationValue *1.8) + 32;
- QBox(CalculationValue + " Celsius converted to Fahrenheit equals: "
- + df2.format(FahrenheitFromCelsius));
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else if (NewCelsius.isSelected())
- {
- QBox("Get out of here with that. Your value is already in Celsius.");
- }
- else if (NewKelvin.isSelected())
- {
- double KelvinFromCelsius;
- KelvinFromCelsius = CalculationValue + 273.15 ;
- if (KelvinFromCelsius >= 0)
- {
- QBox(CalculationValue + " Celsius converted to Kelvin equals: "
- + df2.format(KelvinFromCelsius));
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else
- {
- QBox("Temperatures below absolute zero are imposible.");
- }
- }
- }
- else if (OldKelvin.isSelected())
- {
- if (NewFahrenheit.isSelected())
- {
- double FahrenheitFromKelvin;
- FahrenheitFromKelvin = CalculationValue * 1.8 - 459.67;
- QBox(CalculationValue + " Kelvin converted to Fahrenheit equals: "
- + df2.format(FahrenheitFromKelvin));
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else if (NewCelsius.isSelected())
- {
- double CelsiusFromKelvin;
- CelsiusFromKelvin = CalculationValue - 273.15;
- QBox( CalculationValue + " Kelvin converted to Celsius equals: "
- + df2.format(CelsiusFromKelvin));
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else if (NewKelvin.isSelected())
- {
- QBox("Get out of here with that. Your value is already in Kelvin");
- }
- }
- else
- {
- QBox("Please select your current temperature unit and the one you want to convet to.");
- }
- }
- }
- catch (Exception ex)
- {
- QBox("Your value must only contain numbers.");
- }
- }
- else if (control == ResetValues)
- {
- StartingValue.setText("");
- RadioCurrentValueGroup.clearSelection();
- RadioNewValueGroup.clearSelection();
- }
- else if (control == ClickMe)
- {
- ClickMeFrame.dispose();
- ClickMe();
- }
- else if (control == DialNumber)
- {
- if (PhoneNumber.length() > 0)
- {
- QBox("Dialing: " + PhoneNumber.replace("null", ""));
- PhoneNumber = "";
- }
- }
- else if (control == One)
- {
- PhoneNumber = PhoneNumber + "1";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Two)
- {
- PhoneNumber = PhoneNumber + "2";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Three)
- {
- PhoneNumber = PhoneNumber + "3";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Four)
- {
- PhoneNumber = PhoneNumber + "4";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Five)
- {
- PhoneNumber = PhoneNumber + "5";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Six)
- {
- PhoneNumber = PhoneNumber + "6";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Seven)
- {
- PhoneNumber = PhoneNumber + "7";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Eight)
- {
- PhoneNumber = PhoneNumber + "8";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Nine)
- {
- PhoneNumber = PhoneNumber + "9";
- NumberLabel.setText(PhoneNumber);
- }
- else if (control == Zero)
- {
- PhoneNumber = PhoneNumber + "0";
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- else if (control == Back)
- {
- if (PhoneNumber.length() > 0)
- {
- PhoneNumber = PhoneNumber.substring(0, PhoneNumber.length() - 1);
- NumberLabel.setText(NumberFormat(PhoneNumber));
- }
- }
- else if (control == PlaceOrder)
- {
- if (EnterName.getText().length() == 0)
- {
- QBox("Sorry, but you must enter a name.");
- }
- else
- {
- String Name = EnterName.getText().substring(0, 1).toUpperCase() + EnterName.getText().substring(1) + "\n";
- String Size = "";
- if (Small.isSelected())
- {
- Size = "Small\n";
- }
- else
- {
- if (Medium.isSelected())
- {
- Size = "Medium\n";
- }
- else
- {
- Size = "Large\n";
- }
- }
- String Crust = (String)PizzaCrustCombo.getSelectedItem() + "\n";
- List<?> TopingsList = PizzaTopingsList.getSelectedValuesList();
- ArrayList<String> Topings = new ArrayList<String>();
- for (int i = 0 ; i < TopingsList.size() ; i++)
- {
- Topings.add(TopingsList.get(i).toString());
- }
- if (Topings.isEmpty())
- {
- Topings.add("Pepperoni");
- Topings.add("Bacon");
- Topings.add("Banana peppers");
- }
- String TopingsChosen = "";
- for (int i = 0 ; i < Topings.size() ; i++)
- {
- TopingsChosen = TopingsChosen + (String) Topings.get(i) + "\n";
- }
- String Extras = "";
- if (BreadSticks.isSelected())
- {
- Extras += "BreadSticks\n";
- }
- if (Salad.isSelected())
- {
- Extras += "Salad\n";
- }
- if (Soda.isSelected())
- {
- Extras += "Soda\n";
- }
- String Comments = OrderCommentsTextArea.getText().trim();
- if (Extras.length() == 0)
- {
- Extras = "";
- }
- else
- {
- Extras = "\nEXTRAS: " + "\n" + Extras;
- }
- if (Comments.length() == 0)
- {
- QBox("CUSTOMER NAME: " + "\n" + Name + "\n" + "PIZZA SIZE: "
- + "\n" + Size + "\n" + "CRUST TYPE: " + "\n" + Crust + "\n" + "TOPINGS: " + "\n" + TopingsChosen
- + "\n" + Extras);
- }
- else
- {
- QBox("CUSTOMER NAME: " + "\n" + Name + "\n" + "PIZZA SIZE: "
- + "\n" + Size + "\n" + "CRUST TYPE: " + "\n" + Crust + "\n" + "TOPINGS: " + "\n" + TopingsChosen
- + "\n" + Extras + "\nADDITIONAL COMMENTS: " + "\n" + Comments);
- }
- }
- }
- else if (control == ResetPizza)
- {
- EnterName.setText("");
- Small.setSelected(true);
- PizzaCrustCombo.setSelectedItem("Thin");
- PizzaTopingsList.clearSelection();
- BreadSticks.setSelected(false);
- Salad.setSelected(false);
- Soda.setSelected(false);
- OrderCommentsTextArea.setText("");
- }
- else if (control == minimize)
- {
- RestoreX = ConsoleFrame.getX();
- RestoreY = ConsoleFrame.getY();
- MinimizeAnimation(ConsoleFrame);
- ConsoleFrame.setState(Frame.ICONIFIED);
- }
- else if (control == close)
- {
- try
- {
- Rob = new Robot();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- Rob.keyPress(KeyEvent.VK_CONTROL);
- Rob.keyPress(KeyEvent.VK_ALT);
- Rob.keyPress(KeyEvent.VK_UP);
- Rob.keyRelease(KeyEvent.VK_CONTROL);
- Rob.keyRelease(KeyEvent.VK_ALT);
- Rob.keyRelease(KeyEvent.VK_UP);
- exit();
- }
- else if (control == Apply)
- {
- int RedValue = Integer.parseInt(Red.getText());
- int GreenValue = Integer.parseInt(Green.getText());
- int BlueValue = Integer.parseInt(Blue.getText());
- if ((RedValue > 255) || (BlueValue > 255) || (GreenValue > 255))
- {
- beep();
- }
- else
- {
- OutputArea.setForeground(new Color(RedValue,GreenValue,BlueValue));
- InputField.setForeground(new Color(RedValue,GreenValue,BlueValue));
- CloseAnimation(ColorFrame);
- ColorFrame.dispose();
- println("The color [" + RedValue + "," + GreenValue + "," + BlueValue + "] has been applied.");
- }
- }
- else if (control == CloseLog)
- {
- CloseAnimation(LoginFrame);
- LoginFrame.dispose();
- if (ConsoleFrame == null)
- {
- System.exit(0);
- }
- }
- else if (control == ApplyFont)
- {
- String FontS = (String) FontList.getSelectedValue();
- if (FontS != null)
- {
- Font ApplyFont = new Font(FontS, Font.BOLD, 30);
- OutputArea.setFont(ApplyFont);
- InputField.setFont(ApplyFont);
- println("The font \"" + FontS + "\" has been applied.");
- CloseAnimation(FontFrame);
- FontFrame.dispose();
- }
- }
- else if (control == ApplyPreferences)
- {
- ReadPreferences();
- if (MusicOnStart.isSelected())
- {
- WritePreferences("PlayMusic","1");
- CloseAnimation(PreferencesFrame);
- PreferencesFrame.dispose();
- }
- else if (!MusicOnStart.isSelected())
- {
- WritePreferences("PlayMusic","0");
- CloseAnimation(PreferencesFrame);
- PreferencesFrame.dispose();
- }
- if (SPOS.isSelected())
- {
- WritePreferences("SystemPropertiesOnStart","1");
- CloseAnimation(PreferencesFrame);
- PreferencesFrame.dispose();
- }
- else if (!SPOS.isSelected())
- {
- WritePreferences("SystemPropertiesOnStart","0");
- CloseAnimation(PreferencesFrame);
- PreferencesFrame.dispose();
- }
- }
- else if (control == ChangeSize)
- {
- ValidBackgroundPaths = GetBackgrounds();
- if (ShouldISwitch() && ValidBackgroundPaths.length > 1)
- {
- SwitchBackgroundToLeft();
- SwitchBackground();
- SwitchBackgroundFromLeft();
- }
- else if (OnLastBackground() && ValidBackgroundPaths.length > 1)
- {
- CurrentBackgroundIndex = -1;
- SwitchBackgroundToLeft();
- SwitchBackground();
- SwitchBackgroundFromLeft();
- }
- else if (ValidBackgroundPaths.length == 1)
- {
- boolean FollowThrough = YesOrNo("You only have one background image. Would you like to add more?");
- if (FollowThrough)
- {
- OpenFile("JesseUsers\\" + Username + "\\Backgrounds");
- InternetConnect("https://images.google.com/");
- }
- }
- else
- {
- println("The background image you are trying to switch to does not exist.");
- }
- }
- else if (control == HashButton)
- {
- String PrintHash = Hash(new String(HashField.getPassword()));
- CloseAnimation(HashFrame);
- HashFrame.dispose();
- QBox("Your hashed password is: " + PrintHash + "\nIt has also been copied to your clipboard.");
- StringSelection selection = new StringSelection(PrintHash);
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, selection);
- }
- else if (control == CloseDraw)
- {
- CloseAnimation(PictureFrame);
- PictureFrame.dispose();
- PictureFrame = null;
- }
- else if (control == CalculatorZero)
- {
- CalculatorExpression += "0";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorOne)
- {
- CalculatorExpression += "1";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorTwo)
- {
- CalculatorExpression += "2";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorThree)
- {
- CalculatorExpression += "3";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorFour)
- {
- CalculatorExpression += "4";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorFive)
- {
- CalculatorExpression += "5";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorSix)
- {
- CalculatorExpression += "6";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorSeven)
- {
- CalculatorExpression += "7";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorEight)
- {
- CalculatorExpression += "8";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorNine)
- {
- CalculatorExpression += "9";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorAdd)
- {
- CalculatorExpression += "+";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorSubtract)
- {
- CalculatorExpression += "-";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorMultiply)
- {
- CalculatorExpression += "*";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorDivide)
- {
- CalculatorExpression += "/";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorPercent)
- {
- CalculatorExpression += "%";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorOpenP)
- {
- CalculatorExpression += "(";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorCloseP)
- {
- CalculatorExpression += ")";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorDecimal)
- {
- CalculatorExpression += ".";
- CalculatorField.setText(CalculatorExpression);
- }
- else if (control == CalculatorClear)
- {
- CalculatorExpression = "";
- CalculatorField.setText("");
- }
- else if (control == CalculatorEquals)
- {
- ScriptEngineManager mgr = new ScriptEngineManager();
- ScriptEngine engine = mgr.getEngineByName("JavaScript");
- try
- {
- Object result = engine.eval(CalculatorExpression);
- CalculatorField.setText(result.toString());
- CalculatorExpression = "";
- }
- catch (Exception e)
- {
- QBox("That isn't a valid expression.");
- }
- }
- else if (control == TTT1 && TTT1.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT1.setText("X");
- TTT1.setForeground(RegularRed);
- TTT1.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT1.setText("O");
- TTT1.setForeground(TTTBlue);
- TTT1.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT2 && TTT2.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT2.setText("X");
- TTT2.setForeground(RegularRed);
- TTT2.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT2.setText("O");
- TTT2.setForeground(TTTBlue);
- TTT2.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT3 && TTT3.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT3.setText("X");
- TTT3.setForeground(RegularRed);
- TTT3.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT3.setText("O");
- TTT3.setForeground(TTTBlue);
- TTT3.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT4 && TTT4.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT4.setText("X");
- TTT4.setForeground(RegularRed);
- TTT4.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT4.setText("O");
- TTT4.setForeground(TTTBlue);
- TTT4.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT5 && TTT5.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT5.setText("X");
- TTT5.setForeground(RegularRed);
- TTT5.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT5.setText("O");
- TTT5.setForeground(TTTBlue);
- TTT5.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT6 && TTT6.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT6.setText("X");
- TTT6.setForeground(RegularRed);
- TTT6.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT6.setText("O");
- TTT6.setForeground(TTTBlue);
- TTT6.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT7 && TTT7.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT7.setText("X");
- TTT7.setForeground(RegularRed);
- TTT7.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT7.setText("O");
- TTT7.setForeground(TTTBlue);
- TTT7.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT8 && TTT8.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT8.setText("X");
- TTT8.setForeground(RegularRed);
- TTT8.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT8.setText("O");
- TTT8.setForeground(TTTBlue);
- TTT8.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTT9 && TTT9.getText().isEmpty())
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTT9.setText("X");
- TTT9.setForeground(RegularRed);
- TTT9.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerO;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- else
- {
- TTT9.setText("O");
- TTT9.setForeground(TTTBlue);
- TTT9.setFont(new Font("HeadPlane",Font.BOLD,25));
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTTCheckWin();
- }
- }
- else if (control == TTTReset)
- {
- TTTBoardReset();
- }
- else if (control == AddNote)
- {
- AddNote();
- }
- else if (control == DeleteNote)
- {
- List<?> ClickedSelectionList = FileSelectionList.getSelectedValuesList();
- if (!ClickedSelectionList.isEmpty())
- {
- String ClickedSelection = ClickedSelectionList.get(0).toString();
- File ClickedSelectionPath = null;
- for (int i = 0 ; i < NoteNameList.size() ; i++)
- {
- if (ClickedSelection.equals(NoteNameList.get(i)))
- {
- ClickedSelectionPath = NoteList.get(i);
- break;
- }
- }
- ClickedSelectionPath.delete();
- InitializeNotesList();
- NoteListScroll.setViewportView(FileSelectionList);
- NoteListScroll.revalidate();
- }
- }
- else if (control == OpenNote)
- {
- List<?> ClickedSelectionList = FileSelectionList.getSelectedValuesList();
- if (!ClickedSelectionList.isEmpty())
- {
- String ClickedSelection = ClickedSelectionList.get(0).toString();
- File ClickedSelectionPath = null;
- for (int i = 0 ; i < NoteNameList.size() ; i++)
- {
- if (ClickedSelection.equals(NoteNameList.get(i)))
- {
- ClickedSelectionPath = NoteList.get(i);
- break;
- }
- }
- OpenNote(ClickedSelectionPath);
- }
- }
- else if (control == SubmitNewNote)
- {
- try
- {
- BufferedWriter NoteWriter = new BufferedWriter
- (new FileWriter("JesseUsers\\" + Username + "\\Notes\\" + NewNoteField.getText() + ".txt",true));
- NewNoteArea.write(NoteWriter);
- NoteWriter.close();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- CloseAnimation(NewNoteFrame);
- NewNoteFrame.dispose();
- InitializeNotesList();
- NoteListScroll.setViewportView(FileSelectionList);
- NoteListScroll.revalidate();
- }
- else if (control == YTTNField)
- {
- GetYTTN.doClick();
- }
- else if (control == GetYTTN)
- {
- CloseAnimation(YTTNFrame);
- YTTNFrame.dispose();
- String YouTubeID = YTTNField.getText();
- if (YouTubeID.length() < 11)
- {
- QBox("Sorry, " + Username + ", but that's not a valid YouTube video ID.");
- }
- else
- {
- String YouTubeURL = "https://img.youtube.com/vi/REPLACE/hqdefault.jpg";
- YouTubeURL = YouTubeURL.replace("REPLACE", YouTubeID);
- URL url;
- try
- {
- url = new URL(YouTubeURL);
- BufferedImage Thumbnail = ImageIO.read(url);
- JLabel PictureLabel = new JLabel(new ImageIcon(Thumbnail));
- JFrame ThumbnailFrame = new JFrame();
- ThumbnailFrame.setTitle("YouTube Thumbnail");
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\youtube.png");
- PictureLabel.addMouseListener(new MouseAdapter()
- {
- public void mouseClicked(MouseEvent e)
- {
- InternetConnect("https://www.youtube.com/watch?v=" + YouTubeID);
- }
- });
- PictureLabel.setToolTipText("Click To Open Video");
- ThumbnailFrame.setIconImage(img.getImage());
- ThumbnailFrame.setResizable(false);
- ThumbnailFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ThumbnailFrame.getContentPane().add(PictureLabel);
- ThumbnailFrame.pack();
- ThumbnailFrame.setLocationRelativeTo(null);
- ThumbnailFrame.setVisible(true);
- }
- catch (Exception e)
- {
- QBox("Sorry, " + Username + ", but that's not a valid YouTube video ID.");
- }
- }
- }
- else if (control == ApproveImage)
- {
- try
- {
- ImageIO.write(ReturnImage, "png", new File("C:\\Users\\" + CUsername + "\\Downloads\\" + NewName));
- }
- catch (Exception e)
- {
- LogError(e);
- }
- CloseAnimation(PixelFrame);
- PixelFrame.dispose();
- QBox("The distorted image has been saved to your Downloads folder.");
- }
- else if (control == CloseMusic)
- {
- if (MP3Player != null)
- {
- MP3Player.close();
- }
- MP3Player = null;
- CloseAnimation(MusicFrame);
- MusicVolumeSlider.setValue(100);
- MusicFrame.dispose();
- }
- else if (control == PlayPauseMusic)
- {
- if (MP3Player != null)
- {
- if (!PlayIcon)
- {
- PlayPauseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Play.png"));
- PlayPauseMusic.setToolTipText("Play");
- PlayIcon = true;
- }
- else
- {
- PlayPauseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Pause.png"));
- PlayPauseMusic.setToolTipText("Pause");
- PlayIcon = false;
- }
- if (PlayIcon)
- {
- try
- {
- PauseLocation = FIS.available();
- }
- catch (Exception e)
- {
- }
- MP3Player.close();
- }
- else
- {
- if (MusicStopped)
- {
- MusicStopped = false;
- Play(MusicFiles[CurrentMusicIndex]);
- }
- else
- {
- try
- {
- FIS = new FileInputStream(MusicFiles[CurrentMusicIndex]);
- BIS = new BufferedInputStream(FIS);
- MP3Player = new Player(BIS);
- FIS.skip(SongTotalLength - PauseLocation);
- MusicTitleLabel.setText(MusicFiles[CurrentMusicIndex].getName().replace(".mp3", ""));
- ResumeMusic();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- }
- }
- }
- else if (control == LastMusic)
- {
- if (MP3Player != null)
- {
- if (CurrentMusicIndex - 1 >= 0)
- {
- CurrentMusicIndex -= 1;
- MP3Player.close();
- MP3Player = null;
- Play(MusicFiles[CurrentMusicIndex]);
- }
- else if (CurrentMusicIndex == 0)
- {
- CurrentMusicIndex = MusicFiles.length - 1;
- MP3Player.close();
- MP3Player = null;
- Play(MusicFiles[CurrentMusicIndex]);
- }
- }
- }
- else if (control == NextMusic)
- {
- if (MP3Player != null)
- {
- if (CurrentMusicIndex + 1 <= MusicFiles.length - 1)
- {
- CurrentMusicIndex += 1;
- MP3Player.close();
- MP3Player = null;
- Play(MusicFiles[CurrentMusicIndex]);
- }
- else if (CurrentMusicIndex + 1 == MusicFiles.length)
- {
- CurrentMusicIndex = 0;
- MP3Player.close();
- MP3Player = null;
- Play(MusicFiles[CurrentMusicIndex]);
- }
- }
- }
- else if (control == LoopMusic)
- {
- if (!RepeatAudio)
- {
- LoopMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Repeat.png"));
- LoopMusic.setToolTipText("Don't Loop Audio");
- RepeatAudio = true;
- }
- else
- {
- LoopMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\NoRepeat.png"));
- LoopMusic.setToolTipText("Loop Audio");
- RepeatAudio = false;
- }
- }
- else if (control == StopMusic)
- {
- if (MP3Player != null)
- {
- MP3Player.close();
- MusicTitleLabel.setText("No audio currently playing");
- PlayPauseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Play.png"));
- PlayPauseMusic.setToolTipText("Play");
- PlayIcon = true;
- PauseLocation = 0;
- SongTotalLength = 0;
- MusicStopped = true;
- }
- }
- else if (control == SelectMusicDir)
- {
- WindowsFeel(ConsoleFrame);
- File SelectedFile = GetFile("Select any mp3 file");
- SwingFeel(ConsoleFrame);
- if ((SelectedFile == null || !SelectedFile.toString().endsWith("mp3")))
- {
- if (SelectedFile == null)
- {
- }
- else if (MP3Player == null)
- {
- QBox("Sorry, " + Username + ", but that's not an mp3 file.");
- }
- }
- else
- {
- File[] SelectedFileDir = SelectedFile.getParentFile().listFiles();
- ArrayList<File> ValidFiles = new ArrayList<File>();
- for (int i = 0 ; i < SelectedFileDir.length ; i++)
- {
- if (SelectedFileDir[i].toString().endsWith(".mp3"))
- {
- ValidFiles.add(SelectedFileDir[i]);
- if (ValidFiles.get(i).equals(SelectedFile))
- {
- CurrentMusicIndex = i;
- }
- }
- }
- MusicFiles = ValidFiles.toArray(new File[ValidFiles.size()]);
- Play(MusicFiles[CurrentMusicIndex]);
- }
- }
- else if (control == SaveNote)
- {
- try
- {
- BufferedWriter SaveWriter = new BufferedWriter(new FileWriter(CurrentUserNote,false));
- SaveWriter.write(NoteEditArea.getText());
- SaveWriter.close();
- QBox(CurrentUserNote.getName().replace(".txt", "") + " has been successfully saved.");
- CloseAnimation(NoteEditorFrame);
- NoteEditorFrame.dispose();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- else if (control == AddBackground)
- {
- try
- {
- WindowsFeel(ConsoleFrame);
- File AddBackground = GetFile("Select a png file");
- SwingFeel(ConsoleFrame);
- if (AddMusic.getName() != null && AddMusic.getName().endsWith(".png"))
- {
- File Destination = new File("JesseUsers\\" + Username + "\\Backgrounds\\" + AddBackground.getName());
- Files.copy(new File(AddBackground.getAbsolutePath()).toPath(), Destination.toPath());
- InitializeBackgroundsList();
- BackgroundListScroll.setViewportView(BackgroundSelectionList);
- BackgroundListScroll.revalidate();
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- else if (control == DeleteBackground)
- {
- boolean FollowThrough = YesOrNo("You are about to delete a background file.\n"
- + "This action cannot be undone.\n"
- + "Are you sure you wish to continue?");
- if (FollowThrough)
- {
- List<?> ClickedSelectionListBackground = BackgroundSelectionList.getSelectedValuesList();
- if (!ClickedSelectionListBackground.isEmpty())
- {
- String ClickedSelection = ClickedSelectionListBackground.get(0).toString();
- File ClickedSelectionPath = null;
- for (int i = 0 ; i < BackgroundsNameList.size() ; i++)
- {
- if (ClickedSelection.equals(BackgroundsNameList.get(i)))
- {
- ClickedSelectionPath = BackgroundsList.get(i);
- break;
- }
- }
- ClickedSelectionPath.delete();
- InitializeBackgroundsList();
- BackgroundListScroll.setViewportView(BackgroundSelectionList);
- BackgroundListScroll.revalidate();
- }
- }
- }
- else if (control == OpenBackground)
- {
- List<?> ClickedSelectionList = BackgroundSelectionList.getSelectedValuesList();
- if (!ClickedSelectionList.isEmpty())
- {
- String ClickedSelection = ClickedSelectionList.get(0).toString();
- File ClickedSelectionPath = null;
- for (int i = 0 ; i < BackgroundsNameList.size() ; i++)
- {
- if (ClickedSelection.equals(BackgroundsNameList.get(i)))
- {
- ClickedSelectionPath = BackgroundsList.get(i);
- break;
- }
- }
- draw(ClickedSelectionPath.toString());
- }
- }
- else if (control == AddMusic)
- {
- try
- {
- WindowsFeel(ConsoleFrame);
- File AddMusic = GetFile("Select an mp3 file");
- SwingFeel(ConsoleFrame);
- if (AddMusic != null && AddMusic.getName().endsWith(".mp3"))
- {
- File Destination = new File("JesseUsers\\" + Username + "\\Music\\" + AddMusic.getName());
- Files.copy(new File(AddMusic.getAbsolutePath()).toPath(), Destination.toPath());
- InitializeMusicList();
- MusicListScroll.setViewportView(MusicSelectionList);
- MusicListScroll.revalidate();
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- else if (control == DeleteMusic)
- {
- boolean FollowThrough = YesOrNo("You are about to delete a music file.\n"
- + "This action cannot be undone.\n"
- + "Are you sure you wish to continue?");
- if (FollowThrough)
- {
- List<?> ClickedSelectionListMusic = MusicSelectionList.getSelectedValuesList();
- if (!ClickedSelectionListMusic.isEmpty())
- {
- String ClickedSelection = ClickedSelectionListMusic.get(0).toString();
- File ClickedSelectionPath = null;
- for (int i = 0 ; i < MusicNameList.size() ; i++)
- {
- if (ClickedSelection.equals(MusicNameList.get(i)))
- {
- ClickedSelectionPath = MusicList.get(i);
- break;
- }
- }
- ClickedSelectionPath.delete();
- InitializeMusicList();
- MusicListScroll.setViewportView(MusicSelectionList);
- MusicListScroll.revalidate();
- }
- }
- }
- else if (control == OpenMusic)
- {
- List<?> ClickedSelectionList = MusicSelectionList.getSelectedValuesList();
- if (!ClickedSelectionList.isEmpty())
- {
- String ClickedSelection = ClickedSelectionList.get(0).toString();
- File ClickedSelectionPath = null;
- for (int i = 0 ; i < MusicNameList.size() ; i++)
- {
- if (ClickedSelection.equals(MusicNameList.get(i)))
- {
- ClickedSelectionPath = MusicList.get(i);
- break;
- }
- }
- WindowsFeel(ConsoleFrame);
- mp3(ClickedSelectionPath);
- SwingFeel(ConsoleFrame);
- }
- }
- else if (control == Facebook)
- {
- InternetConnect("https://www.facebook.com/");
- }
- else if (control == Twitter)
- {
- InternetConnect("https://twitter.com/");
- }
- else if (control == Instagram)
- {
- InternetConnect("https://www.instagram.com/");
- }
- else if (control == YouTube)
- {
- InternetConnect("https://www.youtube.com/");
- }
- else if (control == CloseWeather)
- {
- CloseAnimation(WeatherFrame);
- WeatherFrame.dispose();
- UpdateWeather = false;
- UpdateClock = false;
- }
- else if (control == MinimizeWeather)
- {
- WeatherRestoreX = WeatherFrame.getX();
- WeatherRestoreY = WeatherFrame.getY();
- MinimizeAnimation(WeatherFrame);
- WeatherFrame.setState(Frame.ICONIFIED);
- }
- else if (control == DebugButton)
- {
- if (DebugMode)
- {
- Debug();
- }
- else
- {
- println("Sorry, " + Username + ", but you do not have permission to use that feature.");
- }
- }
- else if (control == CloseDebug)
- {
- CloseAnimation(DebugFrame);
- DebugFrame.dispose();
- }
- else if (control == HangmanA)
- {
- LetterChosen("a");
- HangmanA.setEnabled(false);
- HangmanA.setForeground(RegularRed);
- }
- else if (control == HangmanB)
- {
- LetterChosen("b");
- HangmanB.setEnabled(false);
- HangmanB.setForeground(RegularRed);
- }
- else if (control == HangmanC)
- {
- LetterChosen("c");
- HangmanC.setEnabled(false);
- HangmanC.setForeground(RegularRed);
- }
- else if (control == HangmanD)
- {
- LetterChosen("d");
- HangmanD.setEnabled(false);
- HangmanD.setForeground(RegularRed);
- }
- else if (control == HangmanE)
- {
- LetterChosen("e");
- HangmanE.setEnabled(false);
- HangmanE.setForeground(RegularRed);
- }
- else if (control == HangmanF)
- {
- LetterChosen("f");
- HangmanF.setEnabled(false);
- HangmanF.setForeground(RegularRed);
- }
- else if (control == HangmanG)
- {
- LetterChosen("g");
- HangmanG.setEnabled(false);
- HangmanG.setForeground(RegularRed);
- }
- else if (control == HangmanH)
- {
- LetterChosen("h");
- HangmanH.setEnabled(false);
- HangmanH.setForeground(RegularRed);
- }
- else if (control == HangmanI)
- {
- LetterChosen("i");
- HangmanI.setEnabled(false);
- HangmanI.setForeground(RegularRed);
- }
- else if (control == HangmanJ)
- {
- LetterChosen("j");
- HangmanJ.setEnabled(false);
- HangmanJ.setForeground(RegularRed);
- }
- else if (control == HangmanK)
- {
- LetterChosen("k");
- HangmanK.setEnabled(false);
- HangmanK.setForeground(RegularRed);
- }
- else if (control == HangmanL)
- {
- LetterChosen("l");
- HangmanL.setEnabled(false);
- HangmanL.setForeground(RegularRed);
- }
- else if (control == HangmanM)
- {
- LetterChosen("m");
- HangmanM.setEnabled(false);
- HangmanM.setForeground(RegularRed);
- }
- else if (control == HangmanN)
- {
- LetterChosen("n");
- HangmanN.setEnabled(false);
- HangmanN.setForeground(RegularRed);
- }
- else if (control == HangmanO)
- {
- LetterChosen("o");
- HangmanO.setEnabled(false);
- HangmanO.setForeground(RegularRed);
- }
- else if (control == HangmanP)
- {
- LetterChosen("p");
- HangmanP.setEnabled(false);
- HangmanP.setForeground(RegularRed);
- }
- else if (control == HangmanQ)
- {
- LetterChosen("q");
- HangmanQ.setEnabled(false);
- HangmanQ.setForeground(RegularRed);
- }
- else if (control == HangmanR)
- {
- LetterChosen("r");
- HangmanR.setEnabled(false);
- HangmanR.setForeground(RegularRed);
- }
- else if (control == HangmanS)
- {
- LetterChosen("s");
- HangmanS.setEnabled(false);
- HangmanS.setForeground(RegularRed);
- }
- else if (control == HangmanT)
- {
- LetterChosen("t");
- HangmanT.setEnabled(false);
- HangmanT.setForeground(RegularRed);
- }
- else if (control == HangmanU)
- {
- LetterChosen("u");
- HangmanU.setEnabled(false);
- HangmanU.setForeground(RegularRed);
- }
- else if (control == HangmanV)
- {
- LetterChosen("v");
- HangmanV.setEnabled(false);
- HangmanV.setForeground(RegularRed);
- }
- else if (control == HangmanW)
- {
- LetterChosen("w");
- HangmanW.setEnabled(false);
- HangmanW.setForeground(RegularRed);
- }
- else if (control == HangmanX)
- {
- LetterChosen("x");
- HangmanX.setEnabled(false);
- HangmanX.setForeground(RegularRed);
- }
- else if (control == HangmanY)
- {
- LetterChosen("y");
- HangmanY.setEnabled(false);
- HangmanY.setForeground(RegularRed);
- }
- else if (control == HangmanZ)
- {
- LetterChosen("z");
- HangmanZ.setEnabled(false);
- HangmanZ.setForeground(RegularRed);
- }
- else if (control == HangmanReset)
- {
- StartHangman();
- }
- }
- public void Test()
- {
- }
- public void print(String Usage)
- {
- OutputArea.append(Usage);
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(int Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(double Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(boolean Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(float Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(long Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(char Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void print(Object Usage)
- {
- OutputArea.append(Usage + "");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(String Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(int Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(double Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(boolean Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(float Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(long Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(char Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void println(Object Usage)
- {
- OutputArea.append(Usage + "\n");
- OutputArea.setCaretPosition(OutputArea.getDocument().getLength());
- }
- public void draw(String ImageName)
- {
- SwingFeel(ConsoleFrame);
- if (PictureFrame != null)
- {
- CloseAnimation(PictureFrame);
- PictureFrame.dispose();
- }
- BufferedImage Image = null;
- try
- {
- Image = ImageIO.read(new File(ImageName));
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- PictureFrame = new JFrame();
- PictureFrame.setUndecorated(true);
- PictureFrame.setTitle(new File(ImageName).getName().replace(".png", ""));
- PictureFrame.addMouseMotionListener(this);
- PictureFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- JPanel ParentPanel = new JPanel();
- ParentPanel.setLayout(new BorderLayout());
- PictureFrame.setContentPane(ParentPanel);
- JLabel PictureLabel = new JLabel(new ImageIcon(Image));
- ParentPanel.add(PictureLabel, BorderLayout.PAGE_START);
- CloseDraw = new JButton("Close");
- CloseDraw.setFocusPainted(false);
- CloseDraw.setBackground(new Color(223,85,83));
- CloseDraw.setFont(ButtonFont);
- CloseDraw.addActionListener(this);
- CloseDraw.setSize(PictureFrame.getX(),20);
- ParentPanel.add(CloseDraw,BorderLayout.PAGE_END);
- ParentPanel.repaint();
- PictureFrame.pack();
- PictureFrame.setVisible(true);
- PictureFrame.setLocationRelativeTo(null);
- PictureFrame.setAlwaysOnTop(true);
- PictureFrame.setAlwaysOnTop(false);
- PictureFrame.setResizable(false);
- PictureFrame.setIconImage(SASIDIcon.getImage());
- }
- public void draw(BufferedImage ImageName)
- {
- if (PictureFrame != null)
- {
- CloseAnimation(PictureFrame);
- PictureFrame.dispose();
- }
- BufferedImage Image = null;
- try
- {
- Image = ImageName;
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- PictureFrame = new JFrame();
- PictureFrame.setUndecorated(true);
- PictureFrame.addMouseMotionListener(this);
- PictureFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- JPanel ParentPanel = new JPanel();
- ParentPanel.setLayout(new BorderLayout());
- PictureFrame.setContentPane(ParentPanel);
- JLabel PictureLabel = new JLabel(new ImageIcon(Image));
- ParentPanel.add(PictureLabel, BorderLayout.PAGE_START);
- CloseDraw = new JButton("Close");
- CloseDraw.setFocusPainted(false);
- CloseDraw.setBackground(new Color(223,85,83));
- CloseDraw.setFont(ButtonFont);
- CloseDraw.addActionListener(this);
- CloseDraw.setSize(PictureFrame.getX(),20);
- ParentPanel.add(CloseDraw,BorderLayout.PAGE_END);
- ParentPanel.repaint();
- PictureFrame.pack();
- PictureFrame.setVisible(true);
- PictureFrame.setLocationRelativeTo(null);
- PictureFrame.setAlwaysOnTop(true);
- PictureFrame.setAlwaysOnTop(false);
- PictureFrame.setResizable(false);
- PictureFrame.setIconImage(SASIDIcon.getImage());
- }
- public void Temperature()
- {
- if (TemperatureFrame != null)
- {
- CloseAnimation(TemperatureFrame);
- TemperatureFrame.dispose();
- }
- TemperatureFrame = new JFrame();
- TemperatureFrame.setTitle("Temperature Converter");
- TemperatureFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- JPanel ParentPanel = (JPanel)TemperatureFrame.getContentPane();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- JPanel Value = new JPanel();
- JLabel ValueLabel = new JLabel("Measurement: ");
- StartingValue = new JTextField(20);
- StartingValue.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- Value.add(ValueLabel);
- Value.add(StartingValue);
- ParentPanel.add(Value);
- JPanel RadioCurrentValue = new JPanel();
- JLabel CurrentValue = new JLabel("Current Temperature Unit: ");
- RadioCurrentValue.add(CurrentValue);
- OldFahrenheit = new JRadioButton("Fahrenheit");
- OldCelsius = new JRadioButton("Celsius");
- OldKelvin = new JRadioButton("Kelvin");
- RadioCurrentValueGroup = new ButtonGroup();
- RadioCurrentValueGroup.add(OldFahrenheit);
- RadioCurrentValueGroup.add(OldCelsius);
- RadioCurrentValueGroup.add(OldKelvin);
- ParentPanel.add(RadioCurrentValue);
- RadioCurrentValue.add(OldFahrenheit);
- RadioCurrentValue.add(OldCelsius);
- RadioCurrentValue.add(OldKelvin);
- JPanel RadioNewValue = new JPanel();
- JLabel NewValue = new JLabel("Conversion Temperature Unit: ");
- RadioNewValue.add(NewValue);
- NewFahrenheit = new JRadioButton("Fahrenheit");
- NewCelsius = new JRadioButton("Celsius");
- NewKelvin = new JRadioButton("Kelvin");
- RadioNewValueGroup = new ButtonGroup();
- RadioNewValueGroup.add(NewFahrenheit);
- RadioNewValueGroup.add(NewCelsius);
- RadioNewValueGroup.add(NewKelvin);
- ParentPanel.add(RadioNewValue);
- RadioNewValue.add(NewFahrenheit);
- RadioNewValue.add(NewCelsius);
- RadioNewValue.add(NewKelvin);
- JPanel BottomButtons = new JPanel();
- Calculate = new JButton ("Calculate");
- Calculate.addActionListener(this);
- ResetValues = new JButton ("Reset Values");
- ResetValues.addActionListener(this);
- Calculate.setFocusPainted(false);
- Calculate.setBackground(new Color(223,85,83));
- Calculate.setFont(ButtonFont);
- ResetValues.setFocusPainted(false);
- ResetValues.setBackground(new Color(223,85,83));
- ResetValues.setFont(ButtonFont);
- BottomButtons.add(Calculate);
- BottomButtons.add(ResetValues);
- ParentPanel.add(BottomButtons);
- TemperatureFrame.pack();
- TemperatureFrame.setVisible(true);
- TemperatureFrame.setLocationRelativeTo(null);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\temperature.png");
- TemperatureFrame.setIconImage(img.getImage());
- TemperatureFrame.setAlwaysOnTop(true);
- TemperatureFrame.setAlwaysOnTop(false);
- }
- public void ClickMe()
- {
- if (ClickMeFrame != null)
- {
- ClickMeFrame.dispose();
- }
- ClickMeFrame = new JFrame();
- ClickMeFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ClickMeFrame.setIconImage(SASIDIcon.getImage());
- JPanel ParentPanel = (JPanel) ClickMeFrame.getContentPane();
- ClickMe = new JButton("Click Me!");
- ClickMe.setFocusPainted(false);
- ClickMe.setBackground(new Color(223,85,83));
- ClickMe.setFont(ButtonFont);
- ClickMe.addActionListener(this);
- ParentPanel.add(ClickMe);
- ClickMeFrame.pack();
- ClickMeFrame.setVisible(true);
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
- Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
- int X = (int) rect.getMaxX() - 120;
- int Y = (int) rect.getMaxY() - 120;
- int RandomX = RI(80,X);
- int RandomY = RI(80,Y);
- ClickMeFrame.setResizable(false);
- ClickMeFrame.setLocation(RandomX,RandomY);
- ClickMeFrame.setAlwaysOnTop(true);
- }
- WindowAdapter ConsoleEcho = new WindowAdapter()
- {
- public void windowOpened(WindowEvent e)
- {
- InputField.requestFocus();
- if (IsChristmas() && !ChristmasEcho)
- {
- println("Merry Christmas!");
- ChristmasEcho = true;
- }
- if (IsHalloween() && !HalloweenEcho)
- {
- println("Happy Halloween!");
- HalloweenEcho = true;
- }
- if (IsIndependenceDay() && !IndependenceDayEcho)
- {
- println("Happy 4th of July!");
- IndependenceDayEcho = true;
- }
- if (IsThanksgiving() && !ThanksgivingEcho)
- {
- println("Happy Thanksgiving!");
- ThanksgivingEcho = true;
- }
- if (IsAprilFoolsDay() && !AprilFoolsDayEcho)
- {
- println("Happy April Fools Day!");
- AprilFoolsDayEcho = true;
- }
- }
- };
- KeyListener CommandScrolling = new KeyListener()
- {
- @Override
- public void keyPressed(java.awt.event.KeyEvent event)
- {
- int code = event.getKeyCode();
- try
- {
- if (code == KeyEvent.VK_UP)
- {
- if (ScrollingIndex + 1 < OperationList.size())
- {
- ScrollingIndex = ScrollingIndex + 1;
- InputField.setText(OperationList.get(ScrollingIndex));
- }
- }
- else if (code == KeyEvent.VK_DOWN)
- {
- boolean Found = false;
- for (int i = 0 ; i < OperationList.size() ; i++)
- {
- if (OperationList.get(i).equals(InputField.getText()))
- {
- Found = true;
- break;
- }
- else if (!OperationList.get(i).equals(InputField.getText()) && i == OperationList.size() - 1)
- {
- Found = false;
- break;
- }
- }
- if (InputField.getText() == null || InputField.getText().equals(""))
- {
- CurrentDowns = 0;
- }
- else if (!Found)
- {
- CurrentDowns = 0;
- }
- if (ScrollingIndex - 1 >= 0)
- {
- if (CurrentDowns != 0)
- {
- ScrollingIndex = ScrollingIndex - 1;
- }
- InputField.setText(OperationList.get(ScrollingIndex));
- CurrentDowns++;
- }
- if (OperationList.size() == 1)
- {
- InputField.setText(OperationList.get(0));
- }
- }
- for (int i = 61440 ; i < 61452 ; i++)
- {
- if (code == i)
- {
- println("Interesting F" + (i - 61427) + " key.");
- }
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- @Override
- public void keyReleased(java.awt.event.KeyEvent event)
- {
- }
- @Override
- public void keyTyped(java.awt.event.KeyEvent event)
- {
- }
- };
- Action InputFieldAction = new AbstractAction()
- {
- private static final long serialVersionUID = 1L;
- @Override
- public void actionPerformed(ActionEvent e)
- {
- OriginalOperation = InputField.getText().trim();
- operation = InputField.getText().trim();
- if (!MathShellMode)
- {
- operation = operation.replace(".","");
- }
- if (!operation.equals(""))
- {
- OperationList.add(operation);
- ScrollingIndex = OperationList.size() - 1;
- CurrentDowns = 0;
- if (MathShellMode != true)
- {
- try
- {
- Handle(operation);
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- else
- {
- MathShell(operation);
- }
- }
- InputField.setText("");
- }
- };
- public int RI(int min, int max)
- {
- Random rand = new Random();
- int randomNum = rand.nextInt((max - min) + 1) + min;
- return randomNum;
- }
- public void PizzaPlace()
- {
- if (PizzaFrame != null)
- {
- CloseAnimation(PizzaFrame);
- PizzaFrame.dispose();
- }
- PizzaFrame = new JFrame();
- PizzaFrame.setTitle("Pizza Orderer");
- PizzaFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\pizza.png");
- PizzaFrame.setIconImage(img.getImage());
- PizzaFrame.setResizable(false);
- JPanel PizzaPanel = (JPanel)PizzaFrame.getContentPane();
- PizzaPanel.setLayout(new BoxLayout(PizzaPanel,BoxLayout.Y_AXIS));
- PizzaPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- JPanel Customer = new JPanel();
- JLabel CustomerName = new JLabel("Name: ");
- EnterName = new JTextField(20);
- EnterName.addKeyListener(new KeyListener()
- {
- @Override
- public void keyPressed(java.awt.event.KeyEvent e)
- {
- if (EnterName.getText().length() == 1)
- {
- EnterName.setText(EnterName.getText().toUpperCase());
- }
- }
- @Override
- public void keyReleased(java.awt.event.KeyEvent e)
- {
- if (EnterName.getText().length() == 1)
- {
- EnterName.setText(EnterName.getText().toUpperCase());
- }
- }
- @Override
- public void keyTyped(java.awt.event.KeyEvent e)
- {
- if (EnterName.getText().length() == 1)
- {
- EnterName.setText(EnterName.getText().toUpperCase());
- }
- }
- });
- EnterName.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- Customer.add(CustomerName);
- Customer.add(EnterName);
- PizzaPanel.add(Customer);
- JPanel RadioPizzaSize = new JPanel();
- JLabel PizzaSize = new JLabel("Pizza Size: ");
- RadioPizzaSize.add(PizzaSize);
- Small = new JRadioButton("Small");
- Medium = new JRadioButton("Medium");
- Large = new JRadioButton("Large");
- ButtonGroup RadioPizzaGroup = new ButtonGroup();
- RadioPizzaGroup.add(Small);
- RadioPizzaGroup.add(Medium);
- RadioPizzaGroup.add(Large);
- PizzaPanel.add(RadioPizzaSize);
- RadioPizzaSize.add(Small);
- RadioPizzaSize.add(Medium);
- RadioPizzaSize.add(Large);
- JPanel PizzaCrust = new JPanel();
- JLabel CrustType = new JLabel("Crust Type: ");
- PizzaCrust.add(CrustType);
- String[] CrustTypeChoice = {"Thin", "Thick", "Deep Dish"};
- PizzaCrustCombo = new JComboBox(CrustTypeChoice);
- PizzaCrust.add(PizzaCrustCombo);
- PizzaPanel.add(PizzaCrust);
- JPanel PizzaTopings = new JPanel();
- JLabel Topings = new JLabel("Topings: ");
- PizzaTopings.add(Topings);
- String[] PizzaTopingsChoice = {"Pepperoni", "Sausage", "Green Peppers",
- "Onions", "Tomatoes", "Anchovies", "Bacon","Chicken", "Beef",
- "Olives", "Mushrooms"};
- JList jList = new JList(PizzaTopingsChoice);
- PizzaTopingsList = jList;
- PizzaTopingsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- JScrollPane PizzaTopingsListScroll = new JScrollPane(PizzaTopingsList,
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- PizzaTopings.add(PizzaTopingsListScroll);
- PizzaPanel.add(PizzaTopings);
- JPanel ExtraItems = new JPanel();
- JLabel Extra = new JLabel("Extras: ");
- ExtraItems.add(Extra);
- BreadSticks = new JCheckBox("BreadSticks");
- Salad = new JCheckBox("Salad");
- Soda = new JCheckBox("Soda");
- ExtraItems.add(BreadSticks);
- ExtraItems.add(Salad);
- ExtraItems.add(Soda);
- PizzaPanel.add(ExtraItems);
- JPanel AdditionalComments = new JPanel();
- JLabel OrderComments = new JLabel("Order Comments: ");
- AdditionalComments.add(OrderComments);
- OrderCommentsTextArea = new JTextArea(5,20);
- OrderCommentsTextArea.setLineWrap(true);
- JScrollPane OrderCommentsTextAreaScroll = new JScrollPane
- (OrderCommentsTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- AdditionalComments.add(OrderCommentsTextAreaScroll);
- PizzaPanel.add(AdditionalComments);
- JPanel BottomButtons = new JPanel();
- PlaceOrder = new JButton ("Place Order");
- PlaceOrder.addActionListener(this);
- ResetPizza = new JButton ("Reset Values");
- ResetPizza.addActionListener(this);
- ResetPizza.setFocusPainted(false);
- ResetPizza.setBackground(new Color(223,85,83));
- ResetPizza.setFont(ButtonFont);
- PlaceOrder.setFocusPainted(false);
- PlaceOrder.setBackground(new Color(223,85,83));
- PlaceOrder.setFont(ButtonFont);
- BottomButtons.add(PlaceOrder);
- BottomButtons.add(ResetPizza);
- PizzaPanel.add(BottomButtons);
- PizzaFrame.pack();
- PizzaFrame.setVisible(true);
- PizzaFrame.setLocationRelativeTo(null);
- }
- public void PhoneDialer()
- {
- if (PhoneFrame != null)
- {
- CloseAnimation(PhoneFrame);
- PhoneFrame.dispose();
- }
- PhoneFrame = new JFrame();
- PhoneFrame.setTitle("Phone");
- PhoneFrame.setLocationRelativeTo(null);
- PhoneFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- JPanel MyPanel = (JPanel)PhoneFrame.getContentPane();
- MyPanel.setLayout(new BoxLayout(MyPanel, BoxLayout.Y_AXIS));
- JPanel topPanel = new JPanel();
- NumberLabel = new JLabel("Enter a Number to Call");
- topPanel.add(NumberLabel);
- JPanel ButtonsPanel = new JPanel();
- GridLayout layout3 = new GridLayout(4,3,5,5);
- ButtonsPanel.setLayout(layout3);
- Border myBorder = BorderFactory.createEmptyBorder(5,5,5,5);
- MyPanel.setBorder(myBorder);
- Zero = new JButton("0");
- One = new JButton("1");
- Two = new JButton("2");
- Three = new JButton("3");
- Four = new JButton("4");
- Five = new JButton("5");
- Six = new JButton("6");
- Seven = new JButton("7");
- Eight = new JButton("8");
- Nine = new JButton("9");
- Back = new JButton("<X");
- DialNumber = new JButton("Call");
- ButtonsPanel.add(One);
- ButtonsPanel.add(Two);
- ButtonsPanel.add(Three);
- ButtonsPanel.add(Four);
- ButtonsPanel.add(Five);
- ButtonsPanel.add(Six);
- ButtonsPanel.add(Seven);
- ButtonsPanel.add(Eight);
- ButtonsPanel.add(Nine);
- ButtonsPanel.add(DialNumber);
- ButtonsPanel.add(Zero);
- ButtonsPanel.add(Back);
- MyPanel.add(topPanel);
- MyPanel.add(ButtonsPanel);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\phone.png");
- PhoneFrame.setIconImage(img.getImage());
- PhoneFrame.setVisible(true);
- PhoneFrame.setAlwaysOnTop(true);
- PhoneFrame.setAlwaysOnTop(false);
- One.addActionListener(this);
- Two.addActionListener(this);
- Three.addActionListener(this);
- Four.addActionListener(this);
- Five.addActionListener(this);
- Six.addActionListener(this);
- Seven.addActionListener(this);
- Eight.addActionListener(this);
- Nine.addActionListener(this);
- Zero.addActionListener(this);
- Back.addActionListener(this);
- One.setFocusPainted(false);
- One.setBackground(new Color(223,85,83));
- One.setFont(ButtonFont);
- Two.setFocusPainted(false);
- Two.setBackground(new Color(223,85,83));
- Two.setFont(ButtonFont);
- Three.setFocusPainted(false);
- Three.setBackground(new Color(223,85,83));
- Three.setFont(ButtonFont);
- Four.setFocusPainted(false);
- Four.setBackground(new Color(223,85,83));
- Four.setFont(ButtonFont);
- Five.setFocusPainted(false);
- Five.setBackground(new Color(223,85,83));
- Five.setFont(ButtonFont);
- Six.setFocusPainted(false);
- Six.setBackground(new Color(223,85,83));
- Six.setFont(ButtonFont);
- Seven.setFocusPainted(false);
- Seven.setBackground(new Color(223,85,83));
- Seven.setFont(ButtonFont);
- Eight.setFocusPainted(false);
- Eight.setBackground(new Color(223,85,83));
- Eight.setFont(ButtonFont);
- Nine.setFocusPainted(false);
- Nine.setBackground(new Color(223,85,83));
- Nine.setFont(ButtonFont);
- Zero.setFocusPainted(false);
- Zero.setBackground(new Color(223,85,83));
- Zero.setFont(ButtonFont);
- Back.setFocusPainted(false);
- Back.setBackground(new Color(223,85,83));
- Back.setFont(ButtonFont);
- DialNumber.setFocusPainted(false);
- DialNumber.setBackground(new Color(223,85,83));
- DialNumber.setFont(ButtonFont);
- DialNumber.addActionListener(this);
- PhoneFrame.pack();
- PhoneFrame.setVisible(true);
- PhoneFrame.setResizable(false);
- PhoneFrame.setLocationRelativeTo(null);
- }
- public static boolean StringCompareArray(String operation, String[] array)
- {
- return Arrays.stream(array).parallel().anyMatch(operation::contains);
- }
- public void ResetMouse()
- {
- try
- {
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- int centerX = screenSize.width/2;
- int centerY = screenSize.height/2;
- Rob = new Robot();
- Rob.mouseMove(centerX, centerY);
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void CLC()
- {
- OutputArea.setText("");
- InputField.setText("");
- }
- public void PlayMusic(String FilePath)
- {
- try
- {
- StopMusic();
- FileInputStream FileInputStream = new FileInputStream(FilePath);
- Player = new Player(FileInputStream);
- Thread MusicThread = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- Player.play();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- };
- MusicThread.start();
- }
- catch(Exception e)
- {
- LogError(e);
- }
- }
- public void StopMusic()
- {
- try
- {
- if (!Player.isComplete())
- {
- Player.close();
- }
- Player = null;
- }
- catch (Exception e)
- {
- }
- }
- public String ErrorTime()
- {
- DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy--h-mm-aa");
- Date date = new Date();
- return dateFormat.format(date);
- }
- public String UserTime()
- {
- Date Time = new Date();
- SimpleDateFormat dateFormatter = new SimpleDateFormat("EEEEEEEEE, MM/dd/yyyy hh:mmaa zzz");
- return dateFormatter.format(Time);
- }
- public String WeatherTime()
- {
- Date Time = new Date();
- SimpleDateFormat dateFormatter = new SimpleDateFormat("h:mm:ss aa zzz EEEEEEEEEEEEE MMMMMMMMMMMMMMMMMM dd, yyyy");
- return dateFormatter.format(Time);
- }
- public void QBox(String Message)
- {
- if (ConsoleFrame != null)
- {
- WindowsFeel(ConsoleFrame);
- JOptionPane.showMessageDialog(null, Message, "", JOptionPane.PLAIN_MESSAGE, SASIDIcon);
- SwingFeel(ConsoleFrame);
- }
- else if (LoginFrame != null)
- {
- WindowsFeel(LoginFrame);
- JOptionPane.showMessageDialog(null, Message, "", JOptionPane.PLAIN_MESSAGE, SASIDIcon);
- SwingFeel(LoginFrame);
- }
- else
- {
- JFrame myFrame = new JFrame();
- WindowsFeel(myFrame);
- JOptionPane.showMessageDialog(null, Message, "", JOptionPane.PLAIN_MESSAGE, SASIDIcon);
- SwingFeel(myFrame);
- }
- }
- public boolean has(String compare)
- {
- String ThisComp = compare.toLowerCase();
- String ThisOp = operation.toLowerCase();
- if (ThisOp.contains(ThisComp))
- {
- return true;
- }
- return false;
- }
- public boolean hasWord(String compare)
- {
- String ThisComp = compare.toLowerCase();
- String ThisOp = operation.toLowerCase();
- if (ThisOp.equals(ThisComp))
- {
- return true;
- }
- else if (ThisOp.contains(" " + ThisComp + " "))
- {
- return true;
- }
- else if (endsWith(ThisOp, ThisComp))
- {
- return true;
- }
- else if (startsWith(ThisOp,ThisComp))
- {
- return true;
- }
- return false;
- }
- public boolean startsWith(String op, String comp)
- {
- char[] opA = op.toLowerCase().toCharArray();
- char[] compA = comp.toLowerCase().toCharArray();
- for (int i = 0 ; i < comp.length() ; i++)
- {
- if (compA[i] != opA[i])
- {
- return false;
- }
- else if (compA[i] == opA[i] && i == compA.length - 1 && opA[i+1] == ' ')
- {
- return true;
- }
- }
- return false;
- }
- public boolean endsWith(String op, String comp)
- {
- char[] opA = reverseArray(op.toLowerCase().toCharArray());
- char[] compA = reverseArray(comp.toLowerCase().toCharArray());
- for (int i = 0 ; i < comp.length() ; i++)
- {
- if (compA[i] != opA[i])
- {
- return false;
- }
- else if (compA[i] == opA[i] && i == compA.length - 1 && opA[i+1] == ' ')
- {
- return true;
- }
- }
- return false;
- }
- public char[] reverseArray(char[] Array)
- {
- String reverse = new StringBuilder(new String(Array)).reverse().toString();
- return reverse.toCharArray();
- }
- public void Login(boolean AlreadyOpen)
- {
- if (LoginFrame != null)
- {
- CloseAnimation(LoginFrame);
- LoginFrame.dispose();
- }
- LoginFrame = new JFrame();
- LoginFrame.setUndecorated(true);
- if (!AlreadyOpen)
- {
- LoginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- else if (AlreadyOpen)
- {
- LoginFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- }
- LoginFrame.setBounds(0, 0, 375, 391);
- LoginFrame.setTitle("SASID Login");
- LoginFrame.setIconImage(SASIDIcon.getImage());
- ParentPanel = new JPanel();
- LoginFrame.setContentPane(ParentPanel);
- ParentPanel.setLayout(null);
- JLabel LoginLabel = new JLabel("");
- LoginLabel.setVerticalTextPosition(SwingConstants.TOP);
- LoginLabel.setVerticalAlignment(SwingConstants.TOP);
- LoginLabel.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Login.png"));
- LoginLabel.setBounds(0, 0, 375, 391);
- LoginLabel.addMouseMotionListener(this);
- ImageIcon GifIcon = new ImageIcon("SASIDFiles\\Video\\Splash.gif");
- SplashLabel = new JLabel(GifIcon);
- SplashLabel.setToolTipText("Click to see the most recent SASID video!");
- SplashLabel.addMouseListener(this);
- SplashLabel.setBounds(67, 98, 286, 53);
- NameField = new JTextField(20);
- NameField.setToolTipText("Username");
- NameField.setBounds(60,202,260,41);
- NameField.setBackground(new Color(26,32,51));
- NameField.setSelectionColor(new Color(204,153,0));
- NameField.setBorder(null);
- NameField.setFont(new Font("Comic Sans MS",Font.BOLD, 25));
- NameField.setForeground(Vanila);
- NameField.setCaretColor(NameField.getBackground());
- NameField.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- NameField.requestFocusInWindow();
- }
- });
- NameField.addKeyListener(new KeyListener()
- {
- @Override
- public void keyPressed(java.awt.event.KeyEvent e)
- {
- if (NameField.getText().length() == 1)
- {
- NameField.setText(NameField.getText().toUpperCase());
- }
- }
- @Override
- public void keyReleased(java.awt.event.KeyEvent e)
- {
- if (NameField.getText().length() == 1)
- {
- NameField.setText(NameField.getText().toUpperCase());
- }
- }
- @Override
- public void keyTyped(java.awt.event.KeyEvent e)
- {
- if (NameField.getText().length() == 1)
- {
- NameField.setText(NameField.getText().toUpperCase());
- }
- }
- });
- NameField.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if (NameField.getText().length() > 15)
- {
- evt.consume();
- }
- if (evt.getKeyChar() == KeyEvent.VK_ENTER)
- {
- pass.requestFocus();
- }
- }
- });
- NameField.setBorder(BorderFactory.createEmptyBorder());
- CloseLog = new JButton("");
- CloseLog.addActionListener(this);
- CloseLog.addMouseListener(this);
- CloseLog.setBounds(350,3,22,22);
- CloseLog.setFocusable(false);
- CloseLog.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close1.png"));
- LoginLabel.add(CloseLog);
- CloseLog.setContentAreaFilled(false);
- CloseLog.setBorderPainted(false);
- CloseLog.setToolTipText("Close");
- pass = new JPasswordField();
- pass.setToolTipText("Password");
- pass.setBounds(59,272,262,40);
- pass.setBackground(new Color(26,32,51));
- pass.setSelectionColor(new Color(204,153,0));
- pass.setBorder(null);
- pass.setFont(DefaultFont);
- pass.setForeground(Vanila);
- pass.setCaretColor(NameField.getBackground());
- pass.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- Username = NameField.getText().trim();
- Username = Username.substring(0, 1).toUpperCase() + Username.substring(1);
- String Password = new String(pass.getPassword());
- if (Username != null && !Username.equals(""))
- {
- Recognize(Username, Password);
- }
- }
- });
- pass.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if (pass.getPassword().length > 15)
- {
- evt.consume();
- }
- }
- });
- pass.setBorder(BorderFactory.createEmptyBorder());
- NewUserLabel = new JLabel("Don't have an account?", SwingConstants.CENTER);
- NewUserLabel.setFont(new Font("Tahoma",Font.BOLD,18));
- NewUserLabel.setForeground(Vanila);
- NewUserLabel.addMouseListener(this);
- NewUserLabel.setBounds(59,333,262,33);
- LoginLabel.add(NameField);
- LoginLabel.add(pass);
- LoginLabel.add(SplashLabel);
- LoginLabel.add(NewUserLabel);
- ParentPanel.add(LoginLabel);
- LoginFrame.setLocationRelativeTo(null);
- LoginFrame.setVisible(true);
- LoginFrame.setAlwaysOnTop(true);
- LoginFrame.setAlwaysOnTop(false);
- LoginFrame.addWindowListener( new WindowAdapter()
- {
- public void windowOpened(WindowEvent e)
- {
- NameField.requestFocus();
- }
- });
- }
- public void Recognize(String Username, String Password)
- {
- File UserDir = new File("JesseUsers\\" + Username.toLowerCase());
- if (UserDir.isDirectory() && CheckPassword(Password))
- {
- CloseAnimation(LoginFrame);
- LoginFrame.dispose();
- if (ConsoleFrame != null)
- {
- CloseAnimation(ConsoleFrame);
- ConsoleFrame.dispose();
- }
- Console();
- if (GetPreference("PlayMusic") == 1)
- {
- LinkedList<String> MusicList = new LinkedList<String>();
- File UserMusicDir = new File("JesseUsers\\" + Username + "\\Music");
- String[] FileNames = UserMusicDir.list();
- for (int i = 0; i < FileNames.length; i++)
- {
- if (FileNames[i].endsWith(".mp3"))
- {
- MusicList.add(FileNames[i]);
- }
- }
- if (!MusicList.isEmpty())
- {
- PlayMusic("JesseUsers\\" + Username + "\\Music\\" + FileNames[RI(0,FileNames.length - 1)]);
- }
- }
- if (GetPreference("SystemPropertiesOnStart") == 1)
- {
- ShowProperties();
- }
- }
- else
- {
- NameField.setText("");
- pass.setText("");
- NameField.requestFocusInWindow();
- }
- }
- public boolean CheckPassword(String Password)
- {
- try
- {
- BufferedReader PasswordReader = new BufferedReader(new FileReader("JesseUsers\\" + Username + "\\Password.txt"));
- String RealPassword = PasswordReader.readLine();
- PasswordReader.close();
- if (RealPassword.equals(Hash(Password)))
- {
- return true;
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return false;
- }
- public String Hash(String QuestionPassword)
- {
- try
- {
- String HashedPassword = null;
- MessageDigest MesDig = MessageDigest.getInstance("MD5");
- MesDig.update(QuestionPassword.getBytes());
- byte[] bytes = MesDig.digest();
- StringBuilder SringB = new StringBuilder();
- for(int i = 0 ; i < bytes.length ; i++)
- {
- SringB.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
- }
- HashedPassword = SringB.toString();
- return HashedPassword;
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return null;
- }
- public void LogError(Exception e)
- {
- try
- {
- String WriteTo = "SASIDFiles\\Errors\\" + ErrorTime() + ".txt";
- File Create = new File(WriteTo);
- Create.createNewFile();
- BufferedWriter ErrorOut = new BufferedWriter(new FileWriter(WriteTo));
- StringWriter ErrorWriter = new StringWriter();
- e.printStackTrace(new PrintWriter(ErrorWriter));
- ErrorOut.write(ErrorWriter.toString());
- ErrorOut.flush();
- ErrorOut.close();
- DisplayError(e);
- }
- catch (Exception ex) {}
- }
- public void DisplayError(Exception e)
- {
- TrayIcon.displayMessage(e.toString(), "Error thrown by line: " + e.getStackTrace()[0].getLineNumber(), MessageType.ERROR);
- }
- public String FirstNumber(String Search)
- {
- Pattern Pat = Pattern.compile("\\d+");
- Matcher m = Pat.matcher(Search);
- return m.find() ? m.group() : null;
- }
- public boolean YesOrNo(String Message)
- {
- WindowsFeel(ConsoleFrame);
- int dialogueButton = JOptionPane.YES_NO_OPTION;
- int dialogueResult = JOptionPane.showConfirmDialog(null, Message, "", dialogueButton, dialogueButton, SASIDIcon);
- SwingFeel(ConsoleFrame);
- if (dialogueResult == JOptionPane.YES_OPTION)
- {
- return true;
- }
- return false;
- }
- public String GetInput(String Message)
- {
- WindowsFeel(ConsoleFrame);
- String WhatToDo = (String) JOptionPane.showInputDialog(null, Message, "", JOptionPane.PLAIN_MESSAGE, SASIDIcon, null, "");
- SwingFeel(ConsoleFrame);
- if (WhatToDo == null || WhatToDo == "" || WhatToDo.length() == 0)
- {
- return "";
- }
- return WhatToDo;
- }
- public void Help()
- {
- String[] Helps = {"Pixalte a Picture","Home","Mathsh","Pizza","Vexento","Youtube","Note","Create a User"
- ,"Binary","Font","Color","Preferences","Hash","Directory Search","Tic Tac Toe","Youtube Thumbnail","Java"
- ,"Tell me a story","Coffee","Papers Please","Delete User","YouTube Word Search","System Properties","Donuts"
- ,"System Sounds","Weather","Music","mp3"};
- ArrayList<Integer> UniqueIndexes = new ArrayList<Integer>();
- for (int i = 0 ; i < Helps.length ; i++)
- {
- UniqueIndexes.add(i);
- }
- Collections.shuffle(UniqueIndexes);
- println("Try typing:");
- for (int i = 0 ; i < 10 ; i++)
- {
- println(Helps[UniqueIndexes.get(i)]);
- }
- }
- public boolean EIC(String EIC)
- {
- if (operation.equalsIgnoreCase(EIC))
- {
- return true;
- }
- return false;
- }
- public boolean Filter(String FilterWord)
- {
- try
- {
- FilterWord = FilterWord.replace("1","i").replace("!","i").replace("3","e")
- .replace("4","a").replace("@","a").replace("5","s").replace("7","t")
- .replace("0","o").replace("9","g").replace("%", "i").replace("#","h").replace("$","s");
- String fileName = "SASIDFiles\\Text\\Avoid.csv";
- CSVreader = new BufferedReader(new FileReader(fileName));
- while((fileName = CSVreader.readLine()) != null)
- {
- String[] result = fileName.split(",");
- for (int i = 0 ; i < result.length ; i++)
- {
- if (FilterWord.contains(result[i]))
- {
- return true;
- }
- }
- }
- return false;
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- return false;
- }
- public String FirstWord(String Word)
- {
- String sentences[] = Word.split(" ");
- return sentences[0];
- }
- public String ToBinary(int value)
- {
- String binaryResult = "";
- if (value > 0)
- {
- int columnExponent = 0;
- int remainingValue = value;
- while (Math.pow(2,columnExponent) <= value)
- {
- columnExponent = columnExponent + 1;
- }
- String binaryResultUse = "";
- do
- {
- columnExponent = columnExponent - 1;
- int columnWeight = (int) Math.pow(2,columnExponent);
- if (columnWeight <= remainingValue)
- {
- binaryResultUse = binaryResultUse + "1";
- remainingValue = remainingValue - columnWeight;
- }
- else
- {
- binaryResultUse = binaryResultUse + "0";
- }
- }
- while (columnExponent > 0);
- return binaryResultUse;
- }
- binaryResult = "0";
- return binaryResult;
- }
- public void CloseCD(String drive)
- {
- try
- {
- File file = File.createTempFile("realhowto",".vbs");
- file.deleteOnExit();
- FileWriter fw = new FileWriter(file);
- String vbs = "Set wmp = CreateObject(\"WMPlayer.OCX\") \n"
- + "Set cd = wmp.cdromCollection.getByDriveSpecifier(\""
- + drive + "\") \n"
- + "cd.Eject \n "
- + "cd.Eject ";
- fw.write(vbs);
- fw.close();
- Runtime.getRuntime().exec("wscript " + file.getPath()).waitFor();
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void OpenCD(String drive)
- {
- try
- {
- File file = File.createTempFile("realhowto",".vbs");
- file.deleteOnExit();
- FileWriter fw = new java.io.FileWriter(file);
- String vbs = "Set wmp = CreateObject(\"WMPlayer.OCX\") \n"
- + "Set cd = wmp.cdromCollection.getByDriveSpecifier(\""
- + drive + "\") \n"
- + "cd.Eject";
- fw.write(vbs);
- fw.close();
- Runtime.getRuntime().exec("wscript " + file.getPath()).waitFor();
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void Color()
- {
- if (ColorFrame != null)
- {
- CloseAnimation(ColorFrame);
- ColorFrame.dispose();
- }
- ColorFrame = new JFrame();
- ColorFrame.setSize(500, 500);
- ColorFrame.setTitle("Color Picker");
- JPanel ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- JPanel One = new JPanel();
- JLabel Top = new JLabel("Specify the RGB value of your desired color.");
- One.add(Top);
- ParentPanel.add(One);
- JPanel Two = new JPanel();
- Two.setLayout(new BoxLayout(Two,BoxLayout.X_AXIS));
- JLabel RedLabel = new JLabel("R value");
- Red = new JTextField();
- Red.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if (!Character.isDigit(evt.getKeyChar()) || Red.getText().length() > 2)
- {
- evt.consume();
- beep();
- }
- }
- });
- Red.setBounds(63,112,348,43);
- Red.setFont(DefaultFontSmall);
- Two.add(RedLabel);
- Two.add(Red);
- ParentPanel.add(Two);
- JPanel Three = new JPanel();
- Three.setLayout(new BoxLayout(Three,BoxLayout.X_AXIS));
- JLabel GreenLabel = new JLabel("G value");
- Green = new JTextField();
- Green.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if (!Character.isDigit(evt.getKeyChar()) || Green.getText().length() > 2)
- {
- evt.consume();
- beep();
- }
- }
- });
- Green.setBounds(63,142,348,43);
- Green.setFont(DefaultFontSmall);
- Three.add(GreenLabel);
- Three.add(Green);
- ParentPanel.add(Three);
- JPanel Four = new JPanel();
- Four.setLayout(new BoxLayout(Four,BoxLayout.X_AXIS));
- JLabel BlueLabel = new JLabel("B value");
- Blue = new JTextField();
- Blue.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if (!Character.isDigit(evt.getKeyChar()) || Blue.getText().length() > 2)
- {
- evt.consume();
- beep();
- }
- }
- });
- Blue.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- int RedValue = Integer.parseInt(Red.getText());
- int GreenValue = Integer.parseInt(Green.getText());
- int BlueValue = Integer.parseInt(Blue.getText());
- if ((RedValue > 255) || (BlueValue > 255) || (GreenValue > 255))
- {
- beep();
- }
- else
- {
- OutputArea.setForeground(new Color(RedValue,GreenValue,BlueValue));
- InputField.setForeground(new Color(RedValue,GreenValue,BlueValue));
- CloseAnimation(ColorFrame);
- ColorFrame.dispose();
- println("The color [" + RedValue + "," + GreenValue + "," + BlueValue + "] has been applied.");
- }
- }
- });
- Blue.setBounds(63,172,348,43);
- Blue.setFont(DefaultFontSmall);
- Four.add(BlueLabel);
- Four.add(Blue);
- ParentPanel.add(Four);
- JPanel Five = new JPanel();
- Five.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- Five.setLayout(new BoxLayout(Five,BoxLayout.X_AXIS));
- Apply = new JButton("Apply");
- Apply.setFocusPainted(false);
- Apply.setBackground(new Color(223,85,83));
- Apply.setFont(ButtonFont);
- Apply.addActionListener(this);
- Five.add(Apply);
- ParentPanel.add(Five);
- ColorFrame.setResizable(false);
- ColorFrame.add(ParentPanel);
- ColorFrame.pack();
- ColorFrame.setLocationRelativeTo(null);
- ColorFrame.setVisible(true);
- ColorFrame.setAlwaysOnTop(true);
- ColorFrame.setAlwaysOnTop(false);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\color.png");
- ColorFrame.setIconImage(img.getImage());
- }
- @Override
- public void mouseDragged(java.awt.event.MouseEvent e)
- {
- int x = e.getXOnScreen();
- int y = e .getYOnScreen();
- if (ConsoleFrame != null && ConsoleFrame.isFocused())
- {
- ConsoleFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (LoginFrame != null && LoginFrame.isFocused())
- {
- LoginFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (PictureFrame != null && PictureFrame.isFocused())
- {
- PictureFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (PixelFrame != null && PixelFrame.isFocused())
- {
- PixelFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (MusicFrame != null && MusicFrame.isFocused())
- {
- MusicFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (MediaFrame != null && MediaFrame.isFocused())
- {
- MediaFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (WeatherFrame != null && WeatherFrame.isFocused())
- {
- WeatherFrame.setLocation(x - xMouse, y - yMouse);
- }
- if (DebugFrame != null && DebugFrame.isFocused())
- {
- DebugFrame.setLocation(x - xMouse, y - yMouse);
- }
- }
- @Override
- public void mouseMoved(java.awt.event.MouseEvent e)
- {
- xMouse = e.getX();
- yMouse = e.getY();
- if (PositionMode)
- {
- println(xMouse + "," + yMouse);
- }
- }
- public void LogToDo(String WhatToDo)
- {
- try
- {
- if (WhatToDo != null && !WhatToDo.equals("") && !Filter(WhatToDo))
- {
- BufferedWriter TextOut = new BufferedWriter(new FileWriter("SASIDFiles\\Text\\Add.txt", true));
- TextOut.write("The input: " + operation);
- TextOut.write(System.getProperty("line.separator"));
- TextOut.write("Should: " + WhatToDo);
- TextOut.write(System.getProperty("line.separator"));
- TextOut.write(System.getProperty("line.separator"));
- TextOut.flush();
- QBox("Request completed; Nathan will consider it.");
- TextOut.close();
- }
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void font()
- {
- if (FontFrame != null)
- {
- CloseAnimation(FontFrame);
- FontFrame.dispose();
- }
- FontFrame = new JFrame();
- FontFrame.setSize(250, 270);
- FontFrame.setTitle("Font Picker");
- FontFrame.setResizable(false);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\font.png");
- FontFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- ParentPanel = new JPanel();
- JLabel Top = new JLabel("Select your desired font");
- ParentPanel.add(Top);
- String[] Fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
- FontList = new JList(Fonts);
- FontList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- JScrollPane FontListScroll = new JScrollPane(FontList,
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- ParentPanel.add(FontListScroll);
- ApplyFont = new JButton("Apply");
- ApplyFont.setFocusPainted(false);
- ApplyFont.setBackground(RegularRed);
- ApplyFont.addActionListener(this);
- ParentPanel.add(ApplyFont);
- FontFrame.add(ParentPanel);
- FontFrame.setLocationRelativeTo(null);
- FontFrame.setVisible(true);
- FontFrame.setAlwaysOnTop(true);
- FontFrame.setAlwaysOnTop(false);
- }
- public void beep()
- {
- Toolkit.getDefaultToolkit().beep();
- }
- public static void SBeep()
- {
- Toolkit.getDefaultToolkit().beep();
- }
- public boolean IsChristmas()
- {
- Calendar Checker = Calendar.getInstance();
- int Month = Checker.get(Calendar.MONTH) + 1;
- int Date = Checker.get(Calendar.DATE);
- if (Month == 12 && Date == 25)
- {
- return true;
- }
- return false;
- }
- public boolean IsHalloween()
- {
- Calendar Checker = Calendar.getInstance();
- int Month = Checker.get(Calendar.MONTH) + 1;
- int Date = Checker.get(Calendar.DATE);
- if (Month == 10 && Date == 31)
- {
- return true;
- }
- return false;
- }
- public boolean IsIndependenceDay()
- {
- Calendar Checker = Calendar.getInstance();
- int Month = Checker.get(Calendar.MONTH) + 1;
- int Date = Checker.get(Calendar.DATE);
- if (Month == 7 && Date == 4)
- {
- return true;
- }
- return false;
- }
- public boolean IsThanksgiving()
- {
- Calendar Checker = Calendar.getInstance();
- int year = Calendar.getInstance().get(Calendar.YEAR);
- int Month = Checker.get(Calendar.MONTH) + 1;
- int Date = Checker.get(Calendar.DATE);
- LocalDate RealTG = LocalDate.of(year, 11, 1).with(TemporalAdjusters.dayOfWeekInMonth(4, DayOfWeek.THURSDAY));
- if (Month == 11 && Date == RealTG.getDayOfMonth())
- {
- return true;
- }
- return false;
- }
- public boolean IsAprilFoolsDay()
- {
- Calendar Checker = Calendar.getInstance();
- int Month = Checker.get(Calendar.MONTH) + 1;
- int Date = Checker.get(Calendar.DATE);
- if (Month == 4 && Date == 1)
- {
- return true;
- }
- return false;
- }
- public void Disco(int iterations)
- {
- Thread DiscoThread = new Thread()
- {
- public void run()
- {
- try
- {
- boolean Fixed = false;
- boolean NumOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
- boolean CapsOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
- boolean ScrollOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
- for (int i = 1; i < iterations ; i++)
- {
- Robot Rob = new Robot();
- if (!Fixed)
- {
- Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, false);
- Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);
- Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, false);
- Fixed = true;
- }
- Rob.keyPress(KeyEvent.VK_NUM_LOCK);
- Rob.keyRelease(KeyEvent.VK_NUM_LOCK);
- Thread.sleep(170);
- Rob.keyPress(KeyEvent.VK_CAPS_LOCK);
- Rob.keyRelease(KeyEvent.VK_CAPS_LOCK);
- Thread.sleep(170);
- Rob.keyPress(KeyEvent.VK_SCROLL_LOCK);
- Rob.keyRelease(KeyEvent.VK_SCROLL_LOCK);
- Thread.sleep(170);
- Rob.keyPress(KeyEvent.VK_NUM_LOCK);
- Rob.keyRelease(KeyEvent.VK_NUM_LOCK);
- Thread.sleep(170);
- Rob.keyPress(KeyEvent.VK_CAPS_LOCK);
- Rob.keyRelease(KeyEvent.VK_CAPS_LOCK);
- Thread.sleep(170);
- Rob.keyPress(KeyEvent.VK_SCROLL_LOCK);
- Rob.keyRelease(KeyEvent.VK_SCROLL_LOCK);
- Thread.sleep(170);
- }
- Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, NumOn);
- Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, CapsOn);
- Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, ScrollOn);
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- };
- DiscoThread.start();
- }
- public void MathShell(String op)
- {
- if (!OneMathPrint)
- {
- println("Enter a math function in the following format:");
- println("<operation>(<parameter1>,<parameter2>) (parameter2 is optional)");
- println("Type \"quit\" to exit the math shell.");
- OneMathPrint = true;
- }
- if (op.equalsIgnoreCase("quit"))
- {
- CLC();
- OneMathPrint = false;
- MathShellMode = false;
- }
- else if (op.equalsIgnoreCase("clc"))
- {
- CLC();
- }
- else
- {
- int firstParen = op.indexOf("(");
- int comma = op.indexOf(",");
- int lastParen = op.indexOf(")");
- String operation = "";
- double param1 = 0.0;
- double param2 = 0.0;
- try
- {
- if (firstParen != -1)
- {
- operation = op.substring(0,firstParen);
- if (comma != -1)
- {
- param1 = Double.parseDouble(op.substring(firstParen+1,comma));
- if (lastParen != -1)
- {
- param2 = Double.parseDouble(op.substring(comma+1,lastParen));
- }
- }
- else if (lastParen != -1)
- {
- param1 = Double.parseDouble(op.substring(firstParen+1,lastParen));
- }
- Math(operation,param1,param2);
- }
- else
- {
- Math("help",0,0);
- }
- }
- catch(Exception e)
- {
- LogError(e);
- }
- }
- }
- public void Math(String operation, double param1, double param2)
- {
- if (operation.equalsIgnoreCase("abs"))
- {
- println(Math.abs(param1));
- }
- else if (operation.equalsIgnoreCase("ceil"))
- {
- println(Math.ceil(param1));
- }
- else if (operation.equalsIgnoreCase("floor"))
- {
- println(Math.floor(param1));
- }
- else if (operation.equalsIgnoreCase("log"))
- {
- println(Math.log(param1));
- }
- else if (operation.equalsIgnoreCase("log10"))
- {
- println(Math.log10(param1));
- }
- else if (operation.equalsIgnoreCase("max"))
- {
- println(Math.max(param1,param2));
- }
- else if (operation.equalsIgnoreCase("min"))
- {
- println(Math.min(param1,param2));
- }
- else if (operation.equalsIgnoreCase("pow"))
- {
- println(Math.pow(param1,param2));
- }
- else if (operation.equalsIgnoreCase("round"))
- {
- println(Math.round(param1));
- }
- else if (operation.equalsIgnoreCase("sqrt"))
- {
- println(Math.sqrt(param1));
- }
- else if (operation.equalsIgnoreCase("convert2"))
- {
- println(ToBinary((int)(param1)));
- }
- else if (operation.toLowerCase().contains("help"))
- {
- println("\nValid expressions:\nabs(arg), ceil(arg), floor(arg), log(arg, arg2), log10(arg),"
- + " max(arg, arg2), min(arg, arg2), pow(arg, arg2), round(arg), sqrt(arg), convert2(arg)");
- }
- }
- public void exit()
- {
- SaveFontColor();
- CloseAnimation(ConsoleFrame);
- if (HideOnClose.getState() == true)
- {
- ConsoleFrame.setVisible(false);
- }
- else
- {
- System.exit(0);
- }
- }
- public static void SExit()
- {
- System.exit(0);
- }
- Runnable CloseRunable = new Runnable()
- {
- @Override
- public void run()
- {
- CloseAnimation(ConsoleFrame);
- ConsoleFrame.dispose();
- exit();
- }
- };
- public void CloseAtHourMinute(int Hour, int Minute)
- {
- Calendar CloseCalendar = Calendar.getInstance();
- CloseCalendar.add(Calendar.DAY_OF_MONTH, 0);
- CloseCalendar.set(Calendar.HOUR_OF_DAY, Hour);
- CloseCalendar.set(Calendar.MINUTE, Minute);
- CloseCalendar.set(Calendar.SECOND, 0);
- CloseCalendar.set(Calendar.MILLISECOND, 0);
- long HowMany = (CloseCalendar.getTimeInMillis() - System.currentTimeMillis());
- ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
- scheduler.schedule(CloseRunable ,HowMany, TimeUnit.MILLISECONDS);
- }
- public void GetName()
- {
- CUsername = System.getProperty("user.name");
- OS = System.getProperty("os.name");
- }
- public void ShowProperties()
- {
- PropertiesList = new ArrayList<String>();
- Properties Props = System.getProperties();
- Enumeration<?> keys = Props.keys();
- while (keys.hasMoreElements())
- {
- String key = (String) keys.nextElement();
- String value = (String) Props.get(key);
- PropertiesList.add(key + ": " + value);
- }
- File file = null;
- BufferedWriter fw = null;
- try
- {
- file = File.createTempFile("Properties",".txt");
- file.deleteOnExit();
- fw = new BufferedWriter(new FileWriter(file));
- for (int i = 1 ; i < PropertiesList.size() ; i++)
- {
- String Line = PropertiesList.get(i);
- fw.write(Line);
- fw.write(System.getProperty("line.separator"));
- }
- fw.close();
- Desktop.getDesktop().open(file);
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void Preferences()
- {
- if (PreferencesFrame != null)
- {
- CloseAnimation(PreferencesFrame);
- PreferencesFrame.dispose();
- }
- PreferencesFrame = new JFrame();
- PreferencesFrame.setTitle("Preferences");
- PreferencesFrame.setResizable(false);
- PreferencesFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\preferences.png");
- PreferencesFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- JPanel TopPanel = new JPanel();
- TopPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- JLabel Top = new JLabel("Intro Music");
- TopPanel.add(Top);
- ParentPanel.add(TopPanel);
- JPanel MusicPanel = new JPanel();
- MusicPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- MusicOnStart = new JCheckBox("");
- if (GetPreference("PlayMusic") == 0)
- {
- MusicOnStart.setSelected(false);
- }
- else if (GetPreference("PlayMusic") == 1)
- {
- MusicOnStart.setSelected(true);
- }
- MusicOnStart.setFocusPainted(false);
- MusicPanel.add(MusicOnStart);
- ParentPanel.add(MusicPanel);
- JPanel SystemPropertiesLabelPanel = new JPanel();
- SystemPropertiesLabelPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- JLabel SystemPropertiesLabel = new JLabel("Dump System Props On Start");
- SystemPropertiesLabelPanel.add(SystemPropertiesLabel);
- ParentPanel.add(SystemPropertiesLabelPanel);
- JPanel SPOSPanel= new JPanel();
- SPOSPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- SPOS = new JCheckBox("");
- if (GetPreference("SystemPropertiesOnStart") == 0)
- {
- SPOS.setSelected(false);
- }
- else if (GetPreference("SystemPropertiesOnStart") == 1)
- {
- SPOS.setSelected(true);
- }
- SPOS.setFocusPainted(false);
- SPOSPanel.add(SPOS);
- ParentPanel.add(SPOSPanel);
- JPanel BottomPanel = new JPanel();
- ApplyPreferences = new JButton("Apply");
- ApplyPreferences.addActionListener(this);
- ApplyPreferences.setBackground(RegularRed);
- ApplyPreferences.setFocusPainted(false);
- BottomPanel.add(ApplyPreferences);
- ParentPanel.add(BottomPanel);
- PreferencesFrame.add(ParentPanel);
- PreferencesFrame.pack();
- PreferencesFrame.setLocationRelativeTo(null);
- PreferencesFrame.setVisible(true);
- PreferencesFrame.setAlwaysOnTop(true);
- PreferencesFrame.setAlwaysOnTop(false);
- }
- public int GetPreference(String Preference)
- {
- ReadPreferences();
- for (int i = 0 ; i < PreferencesList.size() ; i++)
- {
- if (PreferencesList.get(i).Name.equalsIgnoreCase(Preference))
- {
- return Integer.parseInt(PreferencesList.get(i).Binary);
- }
- }
- return 0;
- }
- public void ReadPreferences()
- {
- String[] Parts;
- try
- {
- PreferencesList.clear();
- CSVreader = new BufferedReader(new FileReader("JesseUsers\\" + Username + "\\Preferences.csv"));
- String Line;
- Line = CSVreader.readLine();
- while(Line != null)
- {
- Parts = Line.split(",");
- if (Parts.length >= 1)
- {
- PreferencesList.add(new Preference(Parts[0],Parts[1]));
- }
- Line = CSVreader.readLine();
- }
- CSVreader.close();
- }
- catch(Exception e)
- {
- LogError(e);
- }
- }
- public void WritePreferences(String Name, String ChangeBinary)
- {
- ReadPreferences();
- try
- {
- CSVwriter = new BufferedWriter(new FileWriter("JesseUsers\\" + Username + "\\Preferences.csv"));
- for (int i = 0 ; i < PreferencesList.size() ; i++)
- {
- if (PreferencesList.get(i).Name.equalsIgnoreCase(Name))
- {
- PreferencesList.get(i).Binary = ChangeBinary;
- }
- CSVwriter.write(PreferencesList.get(i).Name + "," + PreferencesList.get(i).Binary);
- CSVwriter.write("\r\n");
- CSVwriter.flush();
- }
- CSVwriter.close();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void GetBackgroundSize()
- {
- ImageIcon Size = new ImageIcon(GetCurrentBackground().toString());
- BackGroundX = Size.getIconWidth();
- BackGroundY = Size.getIconHeight();
- }
- public File GetCurrentBackground()
- {
- return ValidBackgroundPaths[CurrentBackgroundIndex];
- }
- public File[] GetBackgrounds()
- {
- File dir = new File("JesseUsers\\" + Username + "\\Backgrounds");
- FilenameFilter PNGFilter = new FilenameFilter()
- {
- public boolean accept(File dir, String filename)
- {
- return filename.endsWith(".png");
- }
- };
- ValidBackgroundPaths = dir.listFiles(PNGFilter);
- return dir.listFiles(PNGFilter);
- }
- public void GetScreenSize()
- {
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- ScreenX = (int) screenSize.getWidth();
- ScreenY = (int) screenSize.getHeight();
- }
- public void InternetConnect(String URL)
- {
- Desktop Internet = Desktop.getDesktop();
- try
- {
- Internet.browse(new URI(URL));
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void InternetConnect(URI URI)
- {
- Desktop Internet = Desktop.getDesktop();
- try
- {
- Internet.browse(URI);
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void OpenFile(String FilePath)
- {
- Desktop OpenFile = Desktop.getDesktop();
- try
- {
- File FileToOpen = new File(FilePath);
- URI FileURI = FileToOpen.toURI();
- OpenFile.browse(FileURI);
- }
- catch (Exception e)
- {
- try
- {
- QBox("I wasn't sure how to open that so here it is in your file explorer.");
- Runtime.getRuntime().exec("explorer.exe /select," + FilePath);
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- }
- }
- public boolean ShouldISwitch()
- {
- try
- {
- if (ValidBackgroundPaths.length > CurrentBackgroundIndex + 1 && ValidBackgroundPaths.length > 1)
- {
- return true;
- }
- }
- catch (Exception e)
- {
- return false;
- }
- return false;
- }
- public void CreateHash()
- {
- if (HashFrame != null)
- {
- CloseAnimation(HashFrame);
- HashFrame.dispose();
- }
- HashFrame = new JFrame();
- HashFrame.setResizable(false);
- HashFrame.setTitle("Hasher");
- HashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\hash.png");
- HashFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
- ParentPanel.setLayout(new BoxLayout(ParentPanel, BoxLayout.Y_AXIS));
- JPanel InstPanel = new JPanel();
- InstPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- JLabel Instructions = new JLabel("Enter your password to be hashed");
- InstPanel.add(Instructions);
- ParentPanel.add(InstPanel);
- HashField = new JPasswordField(20);
- HashField.setFont(DefaultFontSmall);
- HashField.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- String Hash = new String(HashField.getPassword());
- if (Hash.length() > 0)
- {
- String PrintHash = Hash(new String(HashField.getPassword()));
- CloseAnimation(HashFrame);
- HashFrame.dispose();
- QBox("Your hashed password is: " + PrintHash + "\nIt has also been copied to your clipboard.");
- StringSelection selection = new StringSelection(PrintHash);
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, selection);
- }
- }
- });
- JPanel FieldPanel = new JPanel();
- FieldPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- FieldPanel.add(HashField);
- ParentPanel.add(FieldPanel);
- JPanel ButtonPanel = new JPanel();
- ButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- HashButton = new JButton("Hash Password");
- HashButton.addActionListener(this);
- HashButton.setFocusPainted(false);
- HashButton.setBackground(RegularRed);
- ButtonPanel.add(HashButton);
- ParentPanel.add(ButtonPanel);
- HashFrame.add(ParentPanel);
- HashFrame.pack();
- HashFrame.setLocationRelativeTo(null);
- HashFrame.setVisible(true);
- HashFrame.setAlwaysOnTop(true);
- }
- public void DirectorySearch()
- {
- WindowsFeel(ConsoleFrame);
- File OpenFile = GetFile("");
- SwingFeel(ConsoleFrame);
- if (OpenFile != null)
- {
- OpenFile(OpenFile.toString());
- }
- }
- public void SwitchBackground()
- {
- CurrentBackgroundIndex++;
- GetBackgroundSize();
- ImageIcon NewIcon = null;
- NewIcon = new ImageIcon(ValidBackgroundPaths[CurrentBackgroundIndex].toString());
- ConsoleFrame.setBounds(0, 0, BackGroundX, BackGroundY);
- ParentPanel.setBounds(0, 0, BackGroundX, BackGroundY);
- ParentLabel.setBounds(0, 0, BackGroundX, BackGroundY);
- ParentLabel.setIcon(NewIcon);
- ParentLabel.setToolTipText(ValidBackgroundPaths[CurrentBackgroundIndex].getName().replace(".png", ""));
- OutputArea.setBounds(0, 0, BackGroundX - 20, BackGroundY - 204);
- OutputScroll.setBounds(10, 62, BackGroundX - 20, BackGroundY - 204);
- InputField.setBounds(10, 82 + OutputArea.getHeight(), BackGroundX - 20, BackGroundY - (OutputArea.getHeight() + 62 + 40));
- ConsoleDragLabel.setBounds(0,0,BackGroundX,30);
- minimize.setBounds(BackGroundX - 81, 4, 22, 20);
- ChangeSize.setBounds(BackGroundX - 54, 4, 22, 20);
- close.setBounds(BackGroundX - 27, 4, 22, 20);
- ConsoleFrame.repaint();
- ConsoleFrame.setLocationRelativeTo(null);
- ConsoleFrame.setVisible(true);
- ConsoleFrame.requestFocus();
- InputField.requestFocus();
- }
- public void here()
- {
- QBox("Here");
- }
- public void Calculator()
- {
- if (CalculatorFrame != null)
- {
- CloseAnimation(CalculatorFrame);
- CalculatorFrame.dispose();
- }
- CalculatorFrame = new JFrame();
- CalculatorFrame.setResizable(false);
- CalculatorFrame.setTitle("Calculator");
- CalculatorFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- CalculatorFrame.setResizable(false);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\Calculator.png");
- CalculatorFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- CalculatorField = new JTextField(20);
- CalculatorField.setText("");
- CalculatorField.addActionListener(this);
- CalculatorField.setEditable(false);
- CalculatorField.setFont(ButtonFont);
- ParentPanel.add(CalculatorField);
- GridLayout ButtonLayout = new GridLayout(5,4,5,5);
- JPanel CalcButtonPanel = new JPanel();
- CalcButtonPanel.setLayout(ButtonLayout);
- CalculatorAdd = new JButton("+");
- CalcButtonPanel.add(CalculatorAdd);
- CalculatorAdd.setFocusPainted(false);
- CalculatorAdd.setBackground(CalculatorOrange);
- CalculatorAdd.setFont(ButtonFont);
- CalculatorAdd.addActionListener(this);
- CalculatorSubtract = new JButton("-");
- CalcButtonPanel.add(CalculatorSubtract);
- CalculatorSubtract.setFocusPainted(false);
- CalculatorSubtract.setBackground(CalculatorOrange);
- CalculatorSubtract.setFont(ButtonFont);
- CalculatorSubtract.addActionListener(this);
- CalculatorMultiply = new JButton("*");
- CalcButtonPanel.add(CalculatorMultiply);
- CalculatorMultiply.setFocusPainted(false);
- CalculatorMultiply.setBackground(CalculatorOrange);
- CalculatorMultiply.setFont(ButtonFont);
- CalculatorMultiply.addActionListener(this);
- CalculatorDivide = new JButton("/");
- CalcButtonPanel.add(CalculatorDivide);
- CalculatorDivide.setFocusPainted(false);
- CalculatorDivide.setBackground(CalculatorOrange);
- CalculatorDivide.setFont(ButtonFont);
- CalculatorDivide.addActionListener(this);
- CalculatorSeven = new JButton("7");
- CalcButtonPanel.add(CalculatorSeven);
- CalculatorSeven.setFocusPainted(false);
- CalculatorSeven.setBackground(CalculatorOrange);
- CalculatorSeven.setFont(ButtonFont);
- CalculatorSeven.addActionListener(this);
- CalculatorEight = new JButton("8");
- CalcButtonPanel.add(CalculatorEight);
- CalculatorEight.setFocusPainted(false);
- CalculatorEight.setBackground(CalculatorOrange);
- CalculatorEight.setFont(ButtonFont);
- CalculatorEight.addActionListener(this);
- CalculatorNine = new JButton("9");
- CalcButtonPanel.add(CalculatorNine);
- CalculatorNine.setFocusPainted(false);
- CalculatorNine.setBackground(CalculatorOrange);
- CalculatorNine.setFont(ButtonFont);
- CalculatorNine.addActionListener(this);
- CalculatorEquals = new JButton("=");
- CalcButtonPanel.add(CalculatorEquals);
- CalculatorEquals.setFocusPainted(false);
- CalculatorEquals.setBackground(CalculatorOrange);
- CalculatorEquals.setFont(ButtonFont);
- CalculatorEquals.addActionListener(this);
- CalculatorFour = new JButton("4");
- CalcButtonPanel.add(CalculatorFour);
- CalculatorFour.setFocusPainted(false);
- CalculatorFour.setBackground(CalculatorOrange);
- CalculatorFour.setFont(ButtonFont);
- CalculatorFour.addActionListener(this);
- CalculatorFive = new JButton("5");
- CalcButtonPanel.add(CalculatorFive);
- CalculatorFive.setFocusPainted(false);
- CalculatorFive.setBackground(CalculatorOrange);
- CalculatorFive.setFont(ButtonFont);
- CalculatorFive.addActionListener(this);
- CalculatorSix = new JButton("6");
- CalcButtonPanel.add(CalculatorSix);
- CalculatorSix.setFocusPainted(false);
- CalculatorSix.setBackground(CalculatorOrange);
- CalculatorSix.setFont(ButtonFont);
- CalculatorSix.addActionListener(this);
- CalculatorClear = new JButton("CE");
- CalcButtonPanel.add(CalculatorClear);
- CalculatorClear.setFocusPainted(false);
- CalculatorClear.setBackground(CalculatorOrange);
- CalculatorClear.setFont(ButtonFont);
- CalculatorClear.addActionListener(this);
- CalculatorOne = new JButton("1");
- CalcButtonPanel.add(CalculatorOne);
- CalculatorOne.setFocusPainted(false);
- CalculatorOne.setBackground(CalculatorOrange);
- CalculatorOne.setFont(ButtonFont);
- CalculatorOne.addActionListener(this);
- CalculatorTwo = new JButton("2");
- CalcButtonPanel.add(CalculatorTwo);
- CalculatorTwo.setFocusPainted(false);
- CalculatorTwo.setBackground(CalculatorOrange);
- CalculatorTwo.setFont(ButtonFont);
- CalculatorTwo.addActionListener(this);
- CalculatorThree = new JButton("3");
- CalcButtonPanel.add(CalculatorThree);
- CalculatorThree.setFocusPainted(false);
- CalculatorThree.setBackground(CalculatorOrange);
- CalculatorThree.setFont(ButtonFont);
- CalculatorThree.addActionListener(this);
- CalculatorPercent = new JButton("%");
- CalcButtonPanel.add(CalculatorPercent);
- CalculatorPercent.setFocusPainted(false);
- CalculatorPercent.setBackground(CalculatorOrange);
- CalculatorPercent.setFont(ButtonFont);
- CalculatorPercent.addActionListener(this);
- CalculatorZero = new JButton("0");
- CalcButtonPanel.add(CalculatorZero);
- CalculatorZero.setFocusPainted(false);
- CalculatorZero.setBackground(CalculatorOrange);
- CalculatorZero.setFont(ButtonFont);
- CalculatorZero.addActionListener(this);
- CalculatorDecimal = new JButton(".");
- CalcButtonPanel.add(CalculatorDecimal);
- CalculatorDecimal.setFocusPainted(false);
- CalculatorDecimal.setBackground(CalculatorOrange);
- CalculatorDecimal.setFont(ButtonFont);
- CalculatorDecimal.addActionListener(this);
- CalculatorOpenP = new JButton("(");
- CalcButtonPanel.add(CalculatorOpenP);
- CalculatorOpenP.setFocusPainted(false);
- CalculatorOpenP.setBackground(CalculatorOrange);
- CalculatorOpenP.setFont(ButtonFont);
- CalculatorOpenP.addActionListener(this);
- CalculatorCloseP = new JButton(")");
- CalcButtonPanel.add(CalculatorCloseP);
- CalculatorCloseP.setFocusPainted(false);
- CalculatorCloseP.setBackground(CalculatorOrange);
- CalculatorCloseP.setFont(ButtonFont);
- CalculatorCloseP.addActionListener(this);
- ParentPanel.add(CalcButtonPanel);
- CalculatorFrame.add(ParentPanel);
- CalculatorFrame.pack();
- CalculatorFrame.setLocationRelativeTo(null);
- CalculatorFrame.setVisible(true);
- CalculatorFrame.setAlwaysOnTop(true);
- CalculatorFrame.setAlwaysOnTop(false);
- CalculatorFrame.requestFocus();
- }
- public void TicTacToe()
- {
- if (TTTFrame != null)
- {
- CloseAnimation(TTTFrame);
- TTTFrame.dispose();
- }
- TTTFrame = new JFrame();
- TTTFrame.setTitle("Tic Tac Toe");
- TTTFrame.setResizable(false);
- TTTFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- TTTFrame.setResizable(false);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\ttt.png");
- TTTFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- JPanel LabelPanel = new JPanel();
- LabelPanel.setLayout(new BorderLayout());
- TTTLabel = new JLabel();
- LabelPanel.add(TTTLabel, SwingConstants.CENTER);
- LabelPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ParentPanel.add(LabelPanel,SwingConstants.CENTER);
- JPanel ButtonPanel = new JPanel();
- GridLayout ButtonLayout = new GridLayout(3,3,5,5);
- ButtonPanel.setLayout(ButtonLayout);
- TTT1 = new JButton("");
- TTT1.setPreferredSize(new Dimension(60, 60));
- TTT1.setFocusPainted(false);
- TTT1.setBackground(Vanila);
- TTT1.setFont(ButtonFont);
- TTT1.addActionListener(this);
- ButtonPanel.add(TTT1);
- TTT2 = new JButton("");
- TTT2.setPreferredSize(new Dimension(60, 60));
- TTT2.setFocusPainted(false);
- TTT2.setBackground(Vanila);
- TTT2.setFont(ButtonFont);
- TTT2.addActionListener(this);
- ButtonPanel.add(TTT2);
- TTT3 = new JButton("");
- TTT3.setPreferredSize(new Dimension(60, 60));
- TTT3.setFocusPainted(false);
- TTT3.setBackground(Vanila);
- TTT3.setFont(ButtonFont);
- TTT3.addActionListener(this);
- ButtonPanel.add(TTT3);
- TTT4 = new JButton("");
- TTT4.setPreferredSize(new Dimension(60, 60));
- TTT4.setFocusPainted(false);
- TTT4.setBackground(Vanila);
- TTT4.setFont(ButtonFont);
- TTT4.addActionListener(this);
- ButtonPanel.add(TTT4);
- TTT5 = new JButton("");
- TTT5.setPreferredSize(new Dimension(60, 60));
- TTT5.setFocusPainted(false);
- TTT5.setBackground(Vanila);
- TTT5.setFont(ButtonFont);
- TTT5.addActionListener(this);
- ButtonPanel.add(TTT5);
- TTT6 = new JButton("");
- TTT6.setPreferredSize(new Dimension(60, 60));
- TTT6.setFocusPainted(false);
- TTT6.setBackground(Vanila);
- TTT6.setFont(ButtonFont);
- TTT6.addActionListener(this);
- ButtonPanel.add(TTT6);
- TTT7 = new JButton("");
- TTT7.setPreferredSize(new Dimension(60, 60));
- TTT7.setFocusPainted(false);
- TTT7.setBackground(Vanila);
- TTT7.setFont(ButtonFont);
- TTT7.addActionListener(this);
- ButtonPanel.add(TTT7);
- TTT8 = new JButton("");
- TTT8.setPreferredSize(new Dimension(60, 60));
- TTT8.setFocusPainted(false);
- TTT8.setBackground(Vanila);
- TTT8.setFont(ButtonFont);
- TTT8.addActionListener(this);
- ButtonPanel.add(TTT8);
- TTT9 = new JButton("");
- TTT9.setPreferredSize(new Dimension(60, 60));
- TTT9.setFocusPainted(false);
- TTT9.setBackground(Vanila);
- TTT9.setFont(ButtonFont);
- TTT9.addActionListener(this);
- ButtonPanel.add(TTT9);
- ButtonPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ParentPanel.add(ButtonPanel);
- JPanel ResetPanel = new JPanel();
- ResetPanel.setLayout(new BorderLayout());
- TTTReset = new JButton("Reset");
- TTTReset.setFocusPainted(false);
- TTTReset.setBackground(RegularRed);
- TTTReset.setFont(ButtonFont);
- TTTReset.addActionListener(this);
- ResetPanel.add(TTTReset, BorderLayout.CENTER);
- ResetPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ParentPanel.add(ResetPanel);
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- TTTFrame.add(ParentPanel);
- TTTFrame.pack();
- TTTFrame.setLocationRelativeTo(null);
- TTTFrame.setVisible(true);
- TTTFrame.setAlwaysOnTop(true);
- TTTFrame.setAlwaysOnTop(false);
- TTTFrame.requestFocus();
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- }
- public void UpdatePlayerTurnLabel()
- {
- if (CurrentPlayerTurn == PlayerX)
- {
- TTTLabel.setText("Player Turn: X");
- }
- else
- {
- TTTLabel.setText("Player Turn: O");
- }
- }
- public void TTTBoardReset()
- {
- CurrentPlayerTurn = PlayerX;
- UpdatePlayerTurnLabel();
- TTT1.setText("");
- TTT2.setText("");
- TTT3.setText("");
- TTT4.setText("");
- TTT5.setText("");
- TTT6.setText("");
- TTT7.setText("");
- TTT8.setText("");
- TTT9.setText("");
- }
- public void TTTCheckWin()
- {
- if (HasPlayerWon("X"))
- {
- QBox("X's have won the game! Congratulations!");
- TTTReset.doClick();
- }
- else if (HasPlayerWon("O"))
- {
- QBox("O's have won the game! Congratulations!");
- TTTReset.doClick();
- }
- else if (TTTBoardIsFull())
- {
- QBox("The game ended with no winners.");
- TTTReset.doClick();
- }
- }
- public boolean HasPlayerWon(String Player)
- {
- if (TTT1.getText().equals(Player) && TTT2.getText().equals(Player) && TTT3.getText().equals(Player))
- {
- return true;
- }
- if (TTT4.getText().equals(Player) && TTT5.getText().equals(Player) && TTT6.getText().equals(Player))
- {
- return true;
- }
- if (TTT7.getText().equals(Player) && TTT8.getText().equals(Player) && TTT9.getText().equals(Player))
- {
- return true;
- }
- if (TTT1.getText().equals(Player) && TTT4.getText().equals(Player) && TTT7.getText().equals(Player))
- {
- return true;
- }
- if (TTT2.getText().equals(Player) && TTT5.getText().equals(Player) && TTT8.getText().equals(Player))
- {
- return true;
- }
- if (TTT3.getText().equals(Player) && TTT6.getText().equals(Player) && TTT9.getText().equals(Player))
- {
- return true;
- }
- if (TTT1.getText().equals(Player) && TTT5.getText().equals(Player) && TTT9.getText().equals(Player))
- {
- return true;
- }
- if (TTT3.getText().equals(Player) && TTT5.getText().equals(Player) && TTT7.getText().equals(Player))
- {
- return true;
- }
- return false;
- }
- public boolean TTTBoardIsFull()
- {
- if (!TTT1.getText().isEmpty() && !TTT2.getText().isEmpty() &&
- !TTT3.getText().isEmpty() && !TTT4.getText().isEmpty() &&
- !TTT5.getText().isEmpty() && !TTT6.getText().isEmpty() &&
- !TTT7.getText().isEmpty() && !TTT8.getText().isEmpty() && !TTT9.getText().isEmpty())
- {
- return true;
- }
- return false;
- }
- public void Note()
- {
- if (NoteFrame != null)
- {
- CloseAnimation(NoteFrame);
- NoteFrame.dispose();
- }
- NoteFrame = new JFrame();
- NoteFrame.setResizable(false);
- NoteFrame.setTitle("Note");
- NoteFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- NoteFrame.setResizable(false);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\note.png");
- NoteFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- InitializeNotesList();
- FileSelectionList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- NoteListScroll = new JScrollPane(FileSelectionList,
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- NoteListScroll.setSize(400,400);
- NoteListScroll.setBackground(Vanila);
- ParentPanel.add(NoteListScroll);
- JPanel ButtonPanel = new JPanel();
- ButtonPanel.setLayout(new GridLayout(1,3,5,5));
- ButtonPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- AddNote = new JButton("Add Note");
- ButtonPanel.add(AddNote);
- AddNote.setFocusPainted(false);
- AddNote.setBackground(RegularRed);
- AddNote.setFont(ButtonFont);
- AddNote.addActionListener(this);
- OpenNote = new JButton("Open Note");
- ButtonPanel.add(OpenNote);
- OpenNote.setFocusPainted(false);
- OpenNote.setBackground(RegularRed);
- OpenNote.setFont(ButtonFont);
- OpenNote.addActionListener(this);
- DeleteNote = new JButton("Delete Note");
- ButtonPanel.add(DeleteNote);
- DeleteNote.setFocusPainted(false);
- DeleteNote.setBackground(RegularRed);
- DeleteNote.setFont(ButtonFont);
- DeleteNote.addActionListener(this);
- ParentPanel.add(ButtonPanel);
- NoteFrame.add(ParentPanel);
- NoteFrame.pack();
- NoteFrame.setLocationRelativeTo(null);
- NoteFrame.setVisible(true);
- NoteFrame.setAlwaysOnTop(true);
- NoteFrame.setAlwaysOnTop(false);
- NoteFrame.requestFocus();
- }
- public void InitializeNotesList()
- {
- File dir = new File("JesseUsers\\" + Username + "\\Notes");
- NoteList = new LinkedList<File>();
- NoteNameList = new LinkedList<String>();
- for (File file : dir.listFiles())
- {
- if (file.getName().endsWith((".txt")))
- {
- NoteList.add(file.getAbsoluteFile());
- NoteNameList.add(file.getName().toString().replace(".txt", ""));
- }
- }
- String[] NotesArray = new String[NoteNameList.size()];
- NotesArray = NoteNameList.toArray(NotesArray);
- FileSelectionList = new JList(NotesArray);
- FileSelectionList.addMouseListener(new MouseAdapter()
- {
- public void mouseClicked(MouseEvent evt)
- {
- if (evt.getClickCount() == 2 && FileSelectionList.getSelectedIndex() != -1)
- {
- OpenNote.doClick();
- }
- }
- });
- }
- public void InitializeBackgroundsList()
- {
- File dir = new File("JesseUsers\\" + Username + "\\Backgrounds");
- BackgroundsList = new LinkedList<File>();
- BackgroundsNameList = new LinkedList<String>();
- for (File file : dir.listFiles())
- {
- if (file.getName().endsWith((".png")))
- {
- BackgroundsList.add(file.getAbsoluteFile());
- BackgroundsNameList.add(file.getName().toString().replace(".png", ""));
- }
- }
- String[] BackgroundsArray = new String[BackgroundsNameList.size()];
- BackgroundsArray = BackgroundsNameList.toArray(BackgroundsArray);
- BackgroundSelectionList = new JList(BackgroundsArray);
- BackgroundSelectionList.addMouseListener(new MouseAdapter()
- {
- public void mouseClicked(MouseEvent evt)
- {
- if (evt.getClickCount() == 2 && BackgroundSelectionList.getSelectedIndex() != -1)
- {
- OpenBackground.doClick();
- }
- }
- });
- }
- public void InitializeMusicList()
- {
- File dir = new File("JesseUsers\\" + Username + "\\Music");
- MusicList = new LinkedList<File>();
- MusicNameList = new LinkedList<String>();
- for (File file : dir.listFiles())
- {
- if (file.getName().endsWith((".mp3")))
- {
- MusicList.add(file.getAbsoluteFile());
- MusicNameList.add(file.getName().toString().replace(".mp3", ""));
- }
- }
- String[] MusicArray = new String[MusicNameList.size()];
- MusicArray = MusicNameList.toArray(MusicArray);
- MusicSelectionList = new JList(MusicArray);
- MusicSelectionList.addMouseListener(new MouseAdapter()
- {
- public void mouseClicked(MouseEvent evt)
- {
- if (evt.getClickCount() == 2 && MusicSelectionList.getSelectedIndex() != -1)
- {
- OpenMusic.doClick();
- }
- }
- });
- }
- public void AddNote()
- {
- if (NewNoteFrame != null)
- {
- CloseAnimation(NewNoteFrame);
- NewNoteFrame.dispose();
- }
- NewNoteFrame = new JFrame();
- NewNoteFrame.setResizable(false);
- NewNoteFrame.setBounds(0,0,600,800);
- NewNoteFrame.setTitle("New Note");
- NewNoteFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\note.png");
- NewNoteFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- JLabel FileNameLabel = new JLabel("Note Title");
- FileNameLabel.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- JPanel TopPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- TopPanel.add(FileNameLabel,SwingConstants.CENTER);
- ParentPanel.add(TopPanel,SwingConstants.CENTER);
- NewNoteField = new JTextField(30);
- NewNoteField.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- JPanel MiddlePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- MiddlePanel.add(NewNoteField);
- ParentPanel.add(MiddlePanel);
- JLabel NoteTextLabel = new JLabel("Note Contents");
- NoteTextLabel.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- JPanel BottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- BottomPanel.add(NoteTextLabel);
- ParentPanel.add(BottomPanel);
- NewNoteArea = new JTextArea(20,20);
- NewNoteArea.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- NewNoteArea.setAutoscrolls(false);
- NewNoteArea.setLineWrap(true);
- NewNoteArea.setWrapStyleWord(true);
- NewNoteArea.setBorder(new LineBorder(new Color(0, 0, 0)));
- JScrollPane NewNoteScroll = new JScrollPane(NewNoteArea,
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- NewNoteScroll.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));
- NewNoteScroll.getViewport().setBorder(null);
- NewNoteScroll.setViewportBorder(null);
- NewNoteScroll.setBorder(BorderFactory.createEmptyBorder(0,20,20,20));
- NewNoteScroll.setPreferredSize(new Dimension(570,780));
- ParentPanel.add(NewNoteScroll);
- SubmitNewNote = new JButton("Create Note");
- SubmitNewNote.setFocusPainted(false);
- SubmitNewNote.setBackground(RegularRed);
- SubmitNewNote.setFont(ButtonFont);
- SubmitNewNote.addActionListener(this);
- JPanel ButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- ButtonPanel.add(SubmitNewNote);
- ButtonPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10));
- ParentPanel.add(ButtonPanel);
- ParentPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
- NewNoteFrame.add(ParentPanel);
- NewNoteFrame.setLocationRelativeTo(null);
- NewNoteFrame.setVisible(true);
- NewNoteFrame.setAlwaysOnTop(true);
- NewNoteFrame.setAlwaysOnTop(false);
- NewNoteField.requestFocus();
- }
- public void YouTubeThumbnail()
- {
- if (YTTNFrame != null)
- {
- CloseAnimation(YTTNFrame);
- YTTNFrame.dispose();
- }
- YTTNFrame = new JFrame();
- YTTNFrame.setResizable(false);
- YTTNFrame.setTitle("YouTube Thumbnail");
- YTTNFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\youtube.png");
- YTTNFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- JLabel VideoID = new JLabel("Enter a valid YouTube video ID");
- VideoID.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- JPanel TopPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- TopPanel.add(VideoID);
- ParentPanel.add(TopPanel);
- YTTNField = new JTextField(30);
- YTTNField.addActionListener(this);
- YTTNField.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if(YTTNField.getText().length() >= 11 && !(evt.getKeyChar()==KeyEvent.VK_DELETE || evt.getKeyChar() == KeyEvent.VK_BACKSPACE))
- {
- beep();
- evt.consume();
- }
- }
- });
- YTTNField.addKeyListener(new java.awt.event.KeyAdapter()
- {
- char[] ValidChars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2',
- '3','4','5','6','7','8','9','-','_'};
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- boolean InArray = false;
- for (char c : ValidChars)
- {
- if (c == evt.getKeyChar())
- {
- InArray = true;
- break;
- }
- }
- if (!InArray)
- {
- evt.consume();
- }
- }
- });
- YTTNField.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- YTTNField.setBorder(new LineBorder(new Color(0, 0, 0)));
- JPanel MiddlePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- MiddlePanel.add(YTTNField);
- ParentPanel.add(MiddlePanel);
- GetYTTN = new JButton("Get Thumbnail");
- GetYTTN.setFocusPainted(false);
- GetYTTN.setBackground(RegularRed);
- GetYTTN.setFont(ButtonFont);
- GetYTTN.addActionListener(this);
- JPanel ButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- ButtonPanel.add(GetYTTN);
- ParentPanel.add(ButtonPanel);
- ParentPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
- YTTNFrame.add(ParentPanel);
- YTTNFrame.pack();
- YTTNFrame.setLocationRelativeTo(null);
- YTTNFrame.setVisible(true);
- YTTNFrame.setAlwaysOnTop(true);
- YTTNFrame.setAlwaysOnTop(false);
- YTTNField.requestFocus();
- }
- public void CreateUser()
- {
- if (LoginFrame != null)
- {
- SwingFeel(LoginFrame);
- }
- else if (ConsoleFrame != null)
- {
- SwingFeel(ConsoleFrame);
- }
- if (CreateUserFrame != null)
- {
- CloseAnimation(CreateUserFrame);
- CreateUserFrame.dispose();
- }
- CreateUserFrame = new JFrame();
- CreateUserFrame.setTitle("Create User");
- CreateUserFrame.setResizable(false);
- CreateUserFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- CreateUserFrame.setIconImage(SASIDIcon.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- JLabel NameLabel = new JLabel("Username: ", SwingConstants.CENTER);
- NameLabel.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- JPanel NameLabelPanel = new JPanel();
- NameLabelPanel.add(NameLabel, SwingConstants.CENTER);
- ParentPanel.add(NameLabelPanel);
- NewUserName = new JTextField();
- NewUserName.addActionListener(this);
- NewUserName.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- NewUserName.addKeyListener(new java.awt.event.KeyAdapter()
- {
- public void keyTyped(java.awt.event.KeyEvent evt)
- {
- if (NewUserName.getText().length() > 15)
- {
- evt.consume();
- }
- }
- });
- NewUserName.setBorder(new LineBorder(new Color(0, 0, 0)));
- NewUserName.addKeyListener(new KeyListener()
- {
- @Override
- public void keyPressed(java.awt.event.KeyEvent e)
- {
- CreateNewUser.setToolTipText("Finalize the user \"" + NewUserName.getText() + "\"");
- if (NewUserName.getText().length() == 1)
- {
- NewUserName.setText(NewUserName.getText().toUpperCase());
- }
- }
- @Override
- public void keyReleased(java.awt.event.KeyEvent e)
- {
- CreateNewUser.setToolTipText("Finalize the user \"" + NewUserName.getText() + "\"");
- if (NewUserName.getText().length() == 1)
- {
- NewUserName.setText(NewUserName.getText().toUpperCase());
- }
- }
- @Override
- public void keyTyped(java.awt.event.KeyEvent e)
- {
- CreateNewUser.setToolTipText("Finalize the user \"" + NewUserName.getText() + "\"");
- if (NewUserName.getText().length() == 1)
- {
- NewUserName.setText(NewUserName.getText().toUpperCase());
- }
- }
- });
- ParentPanel.add(NewUserName);
- JLabel PasswordLabel = new JLabel("Password: ", SwingConstants.CENTER);
- PasswordLabel.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- JLabel PasswordConfLabel = new JLabel("Re-enter pass: ", SwingConstants.CENTER);
- PasswordConfLabel.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- NewUserPassword = new JPasswordField(15);
- NewUserPassword.setFont(DefaultFontSmall);
- NewUserPassword.addActionListener(this);
- NewUserPassword.setBorder(new LineBorder(new Color(0, 0, 0)));
- NewUserPasswordconf = new JPasswordField(15);
- NewUserPasswordconf.setFont(DefaultFontSmall);
- NewUserPasswordconf.addActionListener(this);
- NewUserPasswordconf.setBorder(new LineBorder(new Color(0, 0, 0)));
- JPanel PasswordLabelPanel = new JPanel();
- PasswordLabelPanel.add(PasswordLabel, SwingConstants.CENTER);
- ParentPanel.add(PasswordLabelPanel);
- ParentPanel.add(NewUserPassword);
- JPanel PasswordConfLabelPanel = new JPanel();
- PasswordConfLabelPanel.add(PasswordConfLabel,SwingConstants.CENTER);
- ParentPanel.add(PasswordConfLabelPanel);
- ParentPanel.add(NewUserPasswordconf);
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ChooseBackground = new JLabel("Choose background", SwingConstants.CENTER);
- ChooseBackground.setToolTipText("Click me to choose a background");
- ChooseBackground.setFont(new Font("Tahoma",Font.BOLD,18));
- ChooseBackground.setForeground(new Color(75,75,75));
- ChooseBackground.addMouseListener(this);
- ChooseBackground.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ChooseBackground.setFont(ButtonFont);
- JPanel BackgroundPanel = new JPanel();
- BackgroundPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- BackgroundPanel.add(ChooseBackground);
- ParentPanel.add(BackgroundPanel);
- CreateNewUser = new JLabel("Create user", SwingConstants.CENTER);
- CreateNewUser.setFont(new Font("Tahoma",Font.BOLD,18));
- CreateNewUser.setForeground(new Color(75,75,75));
- CreateNewUser.addMouseListener(this);
- CreateNewUser.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- CreateNewUser.setFont(ButtonFont);
- JPanel CreatePanel = new JPanel();
- CreatePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
- CreatePanel.add(CreateNewUser);
- ParentPanel.add(CreatePanel);
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- CreateUserFrame.add(ParentPanel);
- CreateUserFrame.pack();
- CreateUserFrame.setLocationRelativeTo(null);
- CreateUserFrame.setVisible(true);
- CreateUserFrame.setAlwaysOnTop(true);
- CreateUserFrame.setAlwaysOnTop(false);
- NewUserName.requestFocus();
- }
- public void ComputerProperties()
- {
- File file = null;
- BufferedWriter fw = null;
- try
- {
- file = File.createTempFile("Computer Properties",".txt");
- file.deleteOnExit();
- fw = new BufferedWriter(new FileWriter(file));
- fw.write("Available processors (cores): " + Runtime.getRuntime().availableProcessors());
- fw.write(System.getProperty("line.separator"));
- fw.write("Free memory (bytes): " + Runtime.getRuntime().freeMemory());
- fw.write(System.getProperty("line.separator"));
- long maxMemory = Runtime.getRuntime().maxMemory();
- fw.write("Maximum memory (bytes): " + (maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory));
- fw.write(System.getProperty("line.separator"));
- fw.write("Total memory available to JVM (bytes): " + Runtime.getRuntime().totalMemory());
- fw.write(System.getProperty("line.separator"));
- File[] roots = File.listRoots();
- for (File root : roots)
- {
- fw.write("File system root: " + root.getAbsolutePath());
- fw.write(System.getProperty("line.separator"));
- fw.write("Total space (bytes): " + root.getTotalSpace());
- fw.write(System.getProperty("line.separator"));
- fw.write("Free space (bytes): " + root.getFreeSpace());
- fw.write(System.getProperty("line.separator"));
- fw.write("Usable space (bytes): " + root.getUsableSpace());
- }
- fw.close();
- Desktop.getDesktop().open(file);
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- public void DeleteAccount()
- {
- Object[] options = {"No! I want my user", "Sounds good; kill me"};
- WindowsFeel(ConsoleFrame);
- int choice = JOptionPane.showOptionDialog(null,"Are you sure you want to permanently delete this account?\nThis action cannot be undone!", "",
- JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, SASIDIcon, options, options[0]);
- if (choice == 1)
- {
- DeleteFolder(new File("JesseUsers\\" + Username));
- CloseAnimation(ConsoleFrame);
- ConsoleFrame.dispose();
- Login(false);
- }
- }
- public void DeleteFolder(File folder)
- {
- File[] files = folder.listFiles();
- if (files != null)
- {
- for (File f: files)
- {
- if (f.isDirectory())
- {
- DeleteFolder(f);
- }
- else
- {
- f.delete();
- }
- }
- }
- folder.delete();
- }
- public void SystemSounds()
- {
- JFrame SoundFrame = new JFrame();
- SoundFrame.setResizable(false);
- SoundFrame.setTitle("System Sounds");
- SoundFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\SystemSounds.png");
- SoundFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- GridLayout Grid = new GridLayout(16,1,5,5);
- ParentPanel.setLayout(Grid);
- JLabel SoundLabel = new JLabel("Windows System Sounds");
- SoundLabel.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- ParentPanel.add(SoundLabel);
- JButton DefaultSound = new JButton("Default Sound");
- DefaultSound.setFocusPainted(false);
- DefaultSound.setBackground(RegularRed);
- DefaultSound.setFont(ButtonFont);
- DefaultSound.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.default");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(DefaultSound);
- JButton CloseSound = new JButton("Close Sound");
- CloseSound.setFocusPainted(false);
- CloseSound.setBackground(RegularRed);
- CloseSound.setFont(ButtonFont);
- CloseSound.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.close");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(CloseSound);
- JButton MaximizeSound = new JButton("Maximize Sound");
- MaximizeSound.setFocusPainted(false);
- MaximizeSound.setBackground(RegularRed);
- MaximizeSound.setFont(ButtonFont);
- MaximizeSound.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.maximize");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(MaximizeSound);
- JButton MinimizeSound = new JButton("Minimize Sound");
- MinimizeSound.setFocusPainted(false);
- MinimizeSound.setBackground(RegularRed);
- MinimizeSound.setFont(ButtonFont);
- MinimizeSound.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.minimize");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(MinimizeSound);
- JButton MenuSound = new JButton("Menu Command Sound");
- MenuSound.setFocusPainted(false);
- MenuSound.setBackground(RegularRed);
- MenuSound.setFont(ButtonFont);
- MenuSound.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.menuCommand");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(MenuSound);
- JButton MenuPopup = new JButton("Menu Popup Sound");
- MenuPopup.setFocusPainted(false);
- MenuPopup.setBackground(RegularRed);
- MenuPopup.setFont(ButtonFont);
- MenuPopup.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.menuPopup");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(MenuPopup);
- JButton OpenSound = new JButton("Open Sound");
- OpenSound.setFocusPainted(false);
- OpenSound.setBackground(RegularRed);
- OpenSound.setFont(ButtonFont);
- OpenSound.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.open");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(OpenSound);
- JButton RestoreDown = new JButton("Restore Down Sound");
- RestoreDown.setFocusPainted(false);
- RestoreDown.setBackground(RegularRed);
- RestoreDown.setFont(ButtonFont);
- RestoreDown.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.restoreDown");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(RestoreDown);
- JButton RestoreUp = new JButton("Restore Up Sound");
- RestoreUp.setFocusPainted(false);
- RestoreUp.setBackground(RegularRed);
- RestoreUp.setFont(ButtonFont);
- RestoreUp.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.restoreUp");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(RestoreUp);
- JButton Asterisk = new JButton("Asterisk Sound");
- Asterisk.setFocusPainted(false);
- Asterisk.setBackground(RegularRed);
- Asterisk.setFont(ButtonFont);
- Asterisk.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.asterisk");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(Asterisk);
- JButton Exclamation = new JButton("Exclamation Sound");
- Exclamation.setFocusPainted(false);
- Exclamation.setBackground(RegularRed);
- Exclamation.setFont(ButtonFont);
- Exclamation.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.exclamation");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(Exclamation);
- JButton Exit = new JButton("Exit Sound");
- Exit.setFocusPainted(false);
- Exit.setBackground(RegularRed);
- Exit.setFont(ButtonFont);
- Exit.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.exit");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(Exit);
- JButton Hand = new JButton("Hand Sound");
- Hand.setFocusPainted(false);
- Hand.setBackground(RegularRed);
- Hand.setFont(ButtonFont);
- Hand.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.hand");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(Hand);
- JButton Question = new JButton("Question Sound");
- Question.setFocusPainted(false);
- Question.setBackground(RegularRed);
- Question.setFont(ButtonFont);
- Question.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.question");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(Question);
- JButton Start = new JButton("Start Sound");
- Start.setFocusPainted(false);
- Start.setBackground(RegularRed);
- Start.setFont(ButtonFont);
- Start.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- final Runnable Sound = (Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.start");
- if (Sound != null)
- {
- Sound.run();
- }
- }
- });
- ParentPanel.add(Start);
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- SoundFrame.add(ParentPanel);
- SoundFrame.pack();
- SoundFrame.setLocationRelativeTo(null);
- SoundFrame.setVisible(true);
- SoundFrame.setAlwaysOnTop(true);
- SoundFrame.setAlwaysOnTop(false);
- SoundFrame.requestFocus();
- }
- public void Pixelate(File path, int pixelsize)
- {
- try
- {
- final int PIX_SIZE = pixelsize;
- ReturnImage = ImageIO.read(path);
- Raster src = ReturnImage.getData();
- WritableRaster dest = src.createCompatibleWritableRaster();
- for (int y = 0; y < src.getHeight(); y += PIX_SIZE)
- {
- for (int x = 0; x < src.getWidth(); x += PIX_SIZE)
- {
- double[] pixel = new double[3];
- pixel = src.getPixel(x, y, pixel);
- for (int yd = y; (yd < y + PIX_SIZE) && (yd < dest.getHeight()); yd++)
- {
- for (int xd = x; (xd < x + PIX_SIZE) && (xd < dest.getWidth()); xd++)
- {
- dest.setPixel(xd, yd, pixel);
- }
- }
- }
- }
- ReturnImage.setData(dest);
- NewName = path.getName().replace(".png", "") + "_Pixelated_Magnitude_" + pixelsize + ".png";
- if (PixelFrame != null)
- {
- CloseAnimation(PixelFrame);
- PixelFrame.dispose();
- }
- PixelFrame = new JFrame();
- PixelFrame.setUndecorated(true);
- PixelFrame.setTitle("Pixelation");
- PixelFrame.addMouseMotionListener(this);
- PixelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- JPanel ParentPanel = new JPanel();
- ParentPanel.setLayout(new BorderLayout());
- PixelFrame.setContentPane(ParentPanel);
- JLabel PictureLabel = new JLabel(new ImageIcon(ReturnImage));
- ParentPanel.add(PictureLabel, BorderLayout.PAGE_START);
- ApproveImage = new JButton("Approve Image");
- ApproveImage.setFocusPainted(false);
- ApproveImage.setBackground(new Color(223,85,83));
- ApproveImage.setFont(ButtonFont);
- ApproveImage.addActionListener(this);
- ApproveImage.setSize(PixelFrame.getX(),20);
- ParentPanel.add(ApproveImage,BorderLayout.PAGE_END);
- ParentPanel.repaint();
- PixelFrame.pack();
- PixelFrame.setVisible(true);
- PixelFrame.setLocationRelativeTo(null);
- PixelFrame.setAlwaysOnTop(true);
- PixelFrame.setAlwaysOnTop(false);
- PixelFrame.setResizable(false);
- PixelFrame.setIconImage(SASIDIcon.getImage());
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public File GetFile(String Description)
- {
- WindowsFeel(ConsoleFrame);
- try
- {
- JFileChooser Chooser = new JFileChooser();
- Chooser.setDialogTitle(Description);
- int choice = 0;
- if (ConsoleFrame != null)
- {
- choice = Chooser.showOpenDialog(ConsoleFrame);
- }
- else if (LoginFrame != null)
- {
- choice = Chooser.showOpenDialog(LoginFrame);
- }
- if (choice == JFileChooser.APPROVE_OPTION)
- {
- return Chooser.getSelectedFile();
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return null;
- }
- public void WindowsFeel(Component Component)
- {
- try
- {
- UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
- SwingUtilities.updateComponentTreeUI(Component);
- }
- catch (Exception e)
- {
- }
- }
- public void SwingFeel(Component Component)
- {
- try
- {
- UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
- SwingUtilities.updateComponentTreeUI(Component);
- Component.revalidate();
- Component.repaint();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public BufferedImage ImageFromConsole(int x, int y, File UneditedImage)
- {
- BufferedImage ReturnImage = null;
- try
- {
- File CurrentConsole = UneditedImage;
- Image ConsoleImage = ImageIO.read(CurrentConsole);
- Image TransferImage = ConsoleImage.getScaledInstance(x, y, Image.SCALE_SMOOTH);
- ReturnImage = new BufferedImage(TransferImage.getWidth(null), TransferImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
- Graphics2D bGr = ReturnImage.createGraphics();
- bGr.drawImage(TransferImage, 0, 0, null);
- bGr.dispose();
- return ReturnImage;
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return ReturnImage;
- }
- public boolean OnLastBackground()
- {
- if (ValidBackgroundPaths.length == CurrentBackgroundIndex + 1)
- {
- return true;
- }
- return true;
- }
- public void UserFontAndColor()
- {
- try
- {
- BufferedReader FontColor = new BufferedReader(new FileReader("JesseUsers\\" + Username + "\\FontColor.txt"));
- String FontName = FontColor.readLine();
- String Color[] = FontColor.readLine().split(",");
- UserFont = new Font(FontName, Font.BOLD, 30);
- UserColor = new Color(Integer.parseInt(Color[0]),Integer.parseInt(Color[1]),Integer.parseInt(Color[2]));
- FontColor.close();
- InputField.setForeground(UserColor);
- OutputArea.setForeground(UserColor);
- InputField.setFont(UserFont);
- OutputArea.setFont(UserFont);
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void SaveFontColor()
- {
- try
- {
- Font SaveFont = OutputArea.getFont();
- Color SaveColor = OutputArea.getForeground();
- BufferedWriter FontColorWriter = new BufferedWriter(new FileWriter("JesseUsers\\" + Username + "\\FontColor.txt"));
- FontColorWriter.write(SaveFont.getName());
- FontColorWriter.write(System.getProperty("line.separator"));
- FontColorWriter.write(SaveColor.getRed() + "," + SaveColor.getGreen() + "," + SaveColor.getBlue());
- FontColorWriter.flush();
- FontColorWriter.close();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void CloseAnimation(JFrame frame)
- {
- try
- {
- if (frame != null && frame.isVisible())
- {
- Point point = frame.getLocationOnScreen();
- int x = (int) point.getX();
- int y = (int) point.getY();
- for (int i = y ; i >= 0 - frame.getHeight() ; i -= 30)
- {
- Thread.sleep(1);
- frame.setLocation(x, i);
- }
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void MinimizeAnimation(JFrame frame)
- {
- Point point = frame.getLocationOnScreen();
- int x = (int) point.getX();
- int y = (int) point.getY();
- try
- {
- for (int i = y ; i <= frame.getHeight() ; i += 30)
- {
- Thread.sleep(1);
- frame.setLocation(x, i);
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void SwitchBackgroundToLeft()
- {
- Point point = ConsoleFrame.getLocationOnScreen();
- int x = (int) point.getX();
- int y = (int) point.getY();
- try
- {
- for (int i = x ; i >= 0 - ConsoleFrame.getWidth() ; i -= 30)
- {
- Thread.sleep(1);
- ConsoleFrame.setLocation(i, y);
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void SwitchBackgroundFromLeft()
- {
- ConsoleFrame.setLocationRelativeTo(null);
- Point point = ConsoleFrame.getLocationOnScreen();
- int x = (int) point.getX();
- int y = (int) point.getY();
- ConsoleFrame.setLocation(ScreenX, y);
- try
- {
- for (int i = ScreenX ; i >= x ; i -= 30)
- {
- Thread.sleep(1);
- ConsoleFrame.setLocation(i, y);
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- @Override
- public void mouseClicked(MouseEvent evt)
- {
- }
- @Override
- public void mouseEntered(MouseEvent evt)
- {
- Object control = evt.getSource();
- if (control == CloseLog)
- {
- CloseLog.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close2.png"));
- }
- else if (control == NewUserLabel)
- {
- NewUserLabel.setText("Create an account!");
- NewUserLabel.setForeground(RegularRed);
- }
- else if (control == CreateNewUser)
- {
- CreateNewUser.setText("Start working!");
- }
- else if (control == ChooseBackground)
- {
- if (ChooseBackground.getName() == "No file chosen")
- {
- ChooseBackground.setText("No file chosen");
- }
- else
- {
- ChooseBackground.setText(CreateUserBackground.getName());
- }
- }
- else if (control == close)
- {
- close.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close2.png"));
- }
- else if (control == minimize)
- {
- minimize.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Minimize2.png"));
- }
- else if (control == ChangeSize)
- {
- ChangeSize.setIcon(new ImageIcon("SASIDFiles\\Pictures\\ChangeSize2.png"));
- }
- else if (control == MinimizeWeather)
- {
- MinimizeWeather.setIcon(new ImageIcon("SASIDFiles\\Pictures\\MinimizeWeather2.png"));
- }
- else if (control == CloseWeather)
- {
- CloseWeather.setIcon(new ImageIcon("SASIDFiles\\Pictures\\CloseWeather2.png"));
- }
- else if (control == DebugButton)
- {
- DebugButton.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Debug2.png"));
- }
- else if (control == CloseDebug)
- {
- CloseDebug.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close2.png"));
- }
- else if (control == CloseMusic)
- {
- CloseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close2.png"));
- }
- }
- @Override
- public void mouseExited(MouseEvent evt)
- {
- Object control = evt.getSource();
- if (control == CloseLog)
- {
- CloseLog.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close1.png"));
- }
- else if (control == NewUserLabel)
- {
- NewUserLabel.setText("Don't have an account?");
- NewUserLabel.setForeground(Vanila);
- }
- else if (control == ChooseBackground)
- {
- ChooseBackground.setText("Choose background");
- }
- else if (control == CreateNewUser)
- {
- CreateNewUser.setText("Create user");
- }
- else if (control == close)
- {
- close.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close1.png"));
- }
- else if (control == minimize)
- {
- minimize.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Minimize1.png"));
- }
- else if (control == ChangeSize)
- {
- ChangeSize.setIcon(new ImageIcon("SASIDFiles\\Pictures\\ChangeSize1.png"));
- }
- else if (control == MinimizeWeather)
- {
- MinimizeWeather.setIcon(new ImageIcon("SASIDFiles\\Pictures\\MinimizeWeather1.png"));
- }
- else if (control == CloseWeather)
- {
- CloseWeather.setIcon(new ImageIcon("SASIDFiles\\Pictures\\CloseWeather1.png"));
- }
- else if (control == DebugButton)
- {
- DebugButton.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Debug1.png"));
- }
- else if (control == CloseDebug)
- {
- CloseDebug.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close1.png"));
- }
- else if (control == CloseMusic)
- {
- CloseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Close1.png"));
- }
- }
- @Override
- public void mousePressed(MouseEvent evt)
- {
- }
- @Override
- public void mouseReleased(MouseEvent evt)
- {
- Object source = evt.getSource();
- if (source == SplashLabel)
- {
- InternetConnect("https://www.youtube.com/watch?v=VeHIOSxAQVA");
- }
- else if (source == NewUserLabel)
- {
- CreateUser();
- }
- else if (source == ChooseBackground)
- {
- if (LoginFrame != null)
- {
- WindowsFeel(LoginFrame);
- CreateUserBackground = GetFile("Select any png file");
- SwingFeel(LoginFrame);
- }
- else if (ConsoleFrame != null)
- {
- WindowsFeel(ConsoleFrame);
- CreateUserBackground = GetFile("Select any png file");
- SwingFeel(ConsoleFrame);
- }
- }
- else if (source == CreateNewUser)
- {
- try
- {
- String name = NewUserName.getText().trim();
- String pass = new String(NewUserPassword.getPassword());
- String passconf = new String (NewUserPasswordconf.getPassword());
- if (!pass.equals(passconf) && !pass.equals("") && pass != null)
- {
- QBox("Sorry, but your passwords did not match. Please try again.");
- NewUserPassword.setText("");
- NewUserPasswordconf.setText("");
- }
- else if (pass.length() <= 4)
- {
- QBox("Sorry, but your password length should be greater than\n"
- + "four characters for security reasons. Please try again.");
- NewUserPassword.setText("");
- NewUserPasswordconf.setText("");
- }
- else if (name == null || pass == null || passconf == null || CreateUserBackground.getName() == "No file chosen" || name == "" || pass == "" || passconf == "" || name.length() == 0)
- {
- QBox("Sorry, but one of the required fields was left blank.\nPlease try again.");
- NewUserPassword.setText("");
- NewUserPasswordconf.setText("");
- }
- else
- {
- File NewUserFolder = new File("JesseUsers\\" + name);
- DeleteFolder(NewUserFolder);
- NewUserFolder.mkdirs();
- File prefs = new File("JesseUsers\\" + name + "\\Preferences.csv");
- prefs.createNewFile();
- File music = new File("JesseUsers\\" + name + "\\Music");
- music.mkdir();
- File notes = new File("JesseUsers\\" + name + "\\Notes");
- notes.mkdir();
- File backgrounds = new File("JesseUsers\\" + name + "\\Backgrounds");
- backgrounds.mkdir();
- File Source = CreateUserBackground;
- File Destination = new File("JesseUsers\\" + name + "\\Backgrounds\\" + Source.getName());
- Files.copy(Source.toPath(), Destination.toPath());
- String WritingPass = Hash(pass);
- BufferedWriter PasswordWriter = new BufferedWriter(new FileWriter("JesseUsers\\" + name + "\\Password.txt"));
- PasswordWriter.write(WritingPass);
- PasswordWriter.flush();
- PasswordWriter.close();
- BufferedWriter FontColorWriter = new BufferedWriter(new FileWriter("JesseUsers\\" + name + "\\FontColor.txt"));
- FontColorWriter.write("Tahoma");
- FontColorWriter.write(System.getProperty("line.separator"));
- FontColorWriter.write(Vanila.getRed() + "," + Vanila.getGreen() + "," + Vanila.getBlue());
- FontColorWriter.flush();
- FontColorWriter.close();
- CSVwriter = new BufferedWriter(new FileWriter("JesseUsers\\" + name + "\\Preferences.csv"));
- CSVwriter.write("PlayMusic,0");
- CSVwriter.write(System.getProperty("line.separator"));
- CSVwriter.write("SystemPropertiesOnStart,0");
- CSVwriter.close();
- CloseAnimation(CreateUserFrame);
- CreateUserFrame.dispose();
- QBox("The new user \"" + name + "\" has been created successfully.");
- if (ConsoleFrame != null)
- {
- CloseAnimation(ConsoleFrame);
- ConsoleFrame.dispose();
- Login(false);
- }
- }
- }
- catch (Exception ex)
- {
- LogError(ex);
- }
- }
- else if (source == DisplayLabel)
- {
- StringSelection selection = new StringSelection(DisplayLabel.getText());
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(selection, selection);
- }
- }
- public boolean IsPalindrome(char[] Word)
- {
- int i1 = 0;
- int i2 = Word.length - 1;
- while (i2 > i1)
- {
- if (Word[i1] != Word[i2])
- {
- return false;
- }
- i1++;
- i2--;
- }
- return true;
- }
- public void RandomYoutube()
- {
- YouTubeThread = new Thread()
- {
- @Override
- public void run()
- {
- ConsoleFrame.setTitle("YouTube script running");
- String Start = "https://www.youtube.com/watch?v=";
- String UUID = "";
- char[] ValidChars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2',
- '3','4','5','6','7','8','9','-','_'};
- YouTubeScript = true;
- for (int j = 1 ; j < 100000 ; j++)
- {
- try
- {
- Start = "https://www.youtube.com/watch?v=";
- UUID = "";
- if (!YouTubeScript)
- {
- break;
- }
- for (int i = 1 ; i < 12 ; i++)
- {
- UUID = UUID + ValidChars[RI(0,63)];
- }
- println("Iteration " + j + " checked UUID: " + UUID);
- Start = Start + UUID;
- String YouTubeURL = "https://img.youtube.com/vi/REPLACE/hqdefault.jpg";
- YouTubeURL = YouTubeURL.replace("REPLACE", Start);
- URL url;
- url = new URL(YouTubeURL);
- BufferedImage Thumbnail = ImageIO.read(url);
- JLabel PictureLabel = new JLabel(new ImageIcon(Thumbnail));
- JFrame ThumbnailFrame = new JFrame();
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\youtube.png");
- final String Video = "https://www.youtube.com/watch?v=" + Start;
- PictureLabel.addMouseListener(new MouseAdapter()
- {
- public void mouseClicked(MouseEvent e)
- {
- InternetConnect(Video);
- }
- });
- PictureLabel.setToolTipText("Click To Open Video");
- ThumbnailFrame.setIconImage(img.getImage());
- ThumbnailFrame.setResizable(false);
- ThumbnailFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ThumbnailFrame.getContentPane().add(PictureLabel);
- ThumbnailFrame.pack();
- ThumbnailFrame.setLocationRelativeTo(null);
- ThumbnailFrame.setVisible(true);
- break;
- }
- catch (Exception e)
- {
- }
- }
- }
- };
- YouTubeThread.start();
- }
- public void Iconified()
- {
- Thread IconifiedThread = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- Thread.sleep(600000);
- }
- catch (Exception e)
- {
- LogError(e);
- }
- TrayIcon.displayMessage("Your best friend SASID is feeling lonely.",
- "Hello, " + Username + ".\nPlease use my abundant features or make a suggestion as to what could be added." , MessageType.INFO);
- }
- };
- IconifiedThread.start();
- }
- public void mp3(File StartPlaying)
- {
- if (MusicFrame != null)
- {
- CloseAnimation(MusicFrame);
- MusicFrame.dispose();
- }
- MusicFrame = new JFrame();
- MusicFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- MusicFrame.setUndecorated(true);
- MusicFrame.setTitle("MP3 Player");
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\Music.png");
- MusicFrame.setIconImage(img.getImage());
- MusicFrame.setBounds(0,0,904,604);
- MusicLabel = new JLabel();
- MusicLabel.setIcon(new ImageIcon("SASIDFiles\\Pictures\\mp3.png"));
- MusicLabel.setBounds(0, 0, 904, 604);
- MusicFrame.setContentPane(MusicLabel);
- MusicDragLabel = new JLabel();
- MusicDragLabel.setBounds(0,0,904 - 27,25);
- MusicDragLabel.addMouseMotionListener(this);
- MusicLabel.add(MusicDragLabel);
- CloseMusic = new JButton("");
- CloseMusic.setToolTipText("Close");
- CloseMusic.addActionListener(this);
- CloseMusic.setBounds(883, 0, 22, 20);
- CloseMusic.addMouseListener(this);
- ImageIcon exit = new ImageIcon("SASIDFiles\\Pictures\\Close1.png");
- CloseMusic.setIcon(exit);
- MusicLabel.add(CloseMusic);
- CloseMusic.setFocusPainted(false);
- CloseMusic.setOpaque(false);
- CloseMusic.setContentAreaFilled(false);
- CloseMusic.setBorderPainted(false);
- MusicTitleLabel = new JLabel("",SwingConstants.CENTER);
- MusicTitleLabel.setBounds(287,19,373,18);
- MusicTitleLabel.setToolTipText("Currently Playing");
- MusicTitleLabel.setFont(new Font("HeadPlane",Font.BOLD,18));
- MusicTitleLabel.setForeground(Vanila);
- MusicTitleLabel.setText("No audio currently playing");
- MusicLabel.add(MusicTitleLabel);
- MusicVolumeSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 100);
- MusicVolumeSlider.setBounds(391,528,234,24);
- MusicVolumeSlider.setMinimum(0);
- MusicVolumeSlider.setMaximum(100);
- MusicVolumeSlider.setMajorTickSpacing(10);
- MusicVolumeSlider.setMinorTickSpacing(1);
- MusicVolumeSlider.setPaintTicks(false);
- MusicVolumeSlider.setPaintLabels(false);
- MusicVolumeSlider.setVisible(true);
- MusicVolumeSlider.setForeground(Vanila);
- MusicVolumeSlider.setFont(new Font("HeadPlane",Font.BOLD,18));
- MusicVolumeSlider.addChangeListener(this);
- MusicVolumeSlider.setOpaque(false);
- MusicVolumeSlider.setToolTipText("Volume");
- MusicVolumeSlider.setFocusable(false);
- MusicLabel.add(MusicVolumeSlider);
- PlayPauseMusic = new JButton("");
- PlayPauseMusic.setToolTipText("Play");
- PlayPauseMusic.addActionListener(this);
- PlayPauseMusic.setBounds(71,326,80,78);
- ImageIcon Play = new ImageIcon("SASIDFiles\\Pictures\\Play.png");
- PlayPauseMusic.setIcon(Play);
- MusicLabel.add(PlayPauseMusic);
- PlayPauseMusic.setFocusPainted(false);
- PlayPauseMusic.setOpaque(false);
- PlayPauseMusic.setContentAreaFilled(false);
- PlayPauseMusic.setBorderPainted(false);
- LastMusic = new JButton("");
- LastMusic.setToolTipText("Last Audio");
- LastMusic.addActionListener(this);
- LastMusic.setBounds(71,411,80,78);
- ImageIcon Last = new ImageIcon("SASIDFiles\\Pictures\\SkipBack.png");
- LastMusic.setIcon(Last);
- MusicLabel.add(LastMusic);
- LastMusic.setFocusPainted(false);
- LastMusic.setOpaque(false);
- LastMusic.setContentAreaFilled(false);
- LastMusic.setBorderPainted(false);
- NextMusic = new JButton("");
- NextMusic.setToolTipText("Next Audio");
- NextMusic.addActionListener(this);
- NextMusic.setBounds(161,411,80,78);
- ImageIcon Next = new ImageIcon("SASIDFiles\\Pictures\\Skip.png");
- NextMusic.setIcon(Next);
- MusicLabel.add(NextMusic);
- NextMusic.setFocusPainted(false);
- NextMusic.setOpaque(false);
- NextMusic.setContentAreaFilled(false);
- NextMusic.setBorderPainted(false);
- LoopMusic = new JButton("");
- LoopMusic.setToolTipText("Loop Audio");
- LoopMusic.addActionListener(this);
- LoopMusic.setBounds(71,499,80,78);
- ImageIcon Loop = new ImageIcon("SASIDFiles\\Pictures\\NoRepeat.png");
- LoopMusic.setIcon(Loop);
- MusicLabel.add(LoopMusic);
- LoopMusic.setFocusPainted(false);
- LoopMusic.setOpaque(false);
- LoopMusic.setContentAreaFilled(false);
- LoopMusic.setBorderPainted(false);
- StopMusic = new JButton("");
- StopMusic.setToolTipText("Stop");
- StopMusic.addActionListener(this);
- StopMusic.setBounds(161,499,80,78);
- ImageIcon Stop = new ImageIcon("SASIDFiles\\Pictures\\Stop.png");
- StopMusic.setIcon(Stop);
- MusicLabel.add(StopMusic);
- StopMusic.setFocusPainted(false);
- StopMusic.setOpaque(false);
- StopMusic.setContentAreaFilled(false);
- StopMusic.setBorderPainted(false);
- SelectMusicDir = new JButton("");
- SelectMusicDir.setToolTipText("Open File");
- SelectMusicDir.addActionListener(this);
- SelectMusicDir.setBounds(250,499,80,78);
- ImageIcon File = new ImageIcon("SASIDFiles\\Pictures\\SelectFile.png");
- SelectMusicDir.setIcon(File);
- MusicLabel.add(SelectMusicDir);
- SelectMusicDir.setFocusPainted(false);
- SelectMusicDir.setOpaque(false);
- SelectMusicDir.setContentAreaFilled(false);
- SelectMusicDir.setBorderPainted(false);
- MusicFrame.setLocationRelativeTo(null);
- MusicFrame.setVisible(true);
- MusicFrame.setAlwaysOnTop(true);
- MusicFrame.setAlwaysOnTop(false);
- MusicFrame.requestFocus();
- if (StartPlaying != null)
- {
- InitMusic(StartPlaying);
- }
- }
- public void Play(File path)
- {
- try
- {
- if (MP3Player != null)
- {
- MP3Player.close();
- MP3Player = null;
- }
- FIS = new FileInputStream(path.toString());
- BIS = new BufferedInputStream(FIS);
- MP3Player = new Player(BIS);
- SongTotalLength = FIS.available();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- MusicTitleLabel.setText(MusicFiles[CurrentMusicIndex].getName().replace(".mp3", ""));
- PlayPauseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Pause.png"));
- PlayPauseMusic.setToolTipText("Pause");
- PlayIcon = false;
- MP3Player.play();
- if (RepeatAudio)
- {
- Play(MusicFiles[CurrentMusicIndex]);
- }
- MusicTitleLabel.setText("No audio currently playing");
- PlayPauseMusic.setIcon(new ImageIcon("SASIDFiles\\Pictures\\Play.png"));
- PlayPauseMusic.setToolTipText("Play");
- PlayIcon = true;
- PauseLocation = 0;
- SongTotalLength = 0;
- MusicStopped = true;
- }
- catch (Exception e)
- {
- }
- }
- }.start();
- }
- public void ResumeMusic()
- {
- new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- MP3Player.play();
- if (RepeatAudio)
- {
- Play(MusicFiles[CurrentMusicIndex]);
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- }.start();
- }
- @Override
- public void stateChanged(ChangeEvent evt)
- {
- Object Control = evt.getSource();
- if (Control == MusicVolumeSlider)
- {
- Info Source = Port.Info.SPEAKER;
- Info Headphones = Port.Info.HEADPHONE;
- if (AudioSystem.isLineSupported(Source))
- {
- try
- {
- Port outline = (Port) AudioSystem.getLine(Source);
- outline.open();
- FloatControl VolumeControl = (FloatControl) outline.getControl(FloatControl.Type.VOLUME);
- VolumeControl.setValue( (float) (MusicVolumeSlider.getValue() * 0.01));
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- if (AudioSystem.isLineSupported(Headphones))
- {
- try
- {
- Port outline = (Port) AudioSystem.getLine(Headphones);
- outline.open();
- FloatControl VolumeControl = (FloatControl) outline.getControl(FloatControl.Type.VOLUME);
- VolumeControl.setValue( (float) (MusicVolumeSlider.getValue() * 0.01));
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- }
- }
- public boolean InternetUnReachable()
- {
- Process Ping;
- try
- {
- Ping = java.lang.Runtime.getRuntime().exec("ping -n 1 www.google.com");
- int ReturnValue = Ping.waitFor();
- if (ReturnValue == 0)
- {
- return false;
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return true;
- }
- public void DebugCheck()
- {
- try
- {
- if (new File("SASIDFiles\\Text\\.DA").exists())
- {
- BufferedReader DebugReader = new BufferedReader(new FileReader("SASIDFiles\\Text\\.DA"));
- String DebugCode = DebugReader.readLine();
- DebugReader.close();
- if (DebugCode.equals("dfjlg24356#$%^--*GHJK&*(^_(^)*(468dghdfg#%^(%ddw45sfdH6")
- && CUsername.equalsIgnoreCase("nathan") && ComputerName().equalsIgnoreCase("NathanLenovo"))
- {
- DebugMode = true;
- }
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public String ComputerName()
- {
- String Return = null;
- try
- {
- InetAddress Add = InetAddress.getLocalHost();
- Return = Add.getHostName();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return Return;
- }
- public void Location()
- {
- try
- {
- String Key = "https://api.ipdata.co/?api-key=8eac4e7ab34eb235c4a888bfdbedc8bb8093ec1490790d139cf58932";
- URL Querry = new URL(Key);
- BufferedReader BR = new BufferedReader(new InputStreamReader(Querry.openStream()));
- String CurrentLine;
- while ((CurrentLine = BR.readLine()) != null)
- {
- if (CurrentLine.contains("city"))
- {
- UserCity = (CurrentLine.replace("city", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("\"region\""))
- {
- UserState = (CurrentLine.replace("region", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("\"region_code\""))
- {
- UserStateAbr = (CurrentLine.replace("region_code", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("organisation"))
- {
- UserISP = (CurrentLine.replace("organisation", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("\"country_name\""))
- {
- UserCountry = (CurrentLine.replace("country_name", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("\"country_code\""))
- {
- UserCountryAbr = (CurrentLine.replace("country_code", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("\"latitude\""))
- {
- UserLat = (CurrentLine.replace("latitude", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- else if (CurrentLine.contains("\"longitude\""))
- {
- UserLon = (CurrentLine.replace("longitude", "").replace(",", "").replace("\"", "").replace(":", "").trim());
- }
- }
- BR.close();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void Fib(int a, int b)
- {
- int c = a + b;
- print(", " + c);
- if (c < 100000000)
- {
- Fib(b,c);
- }
- }
- public void OpenNote(File File)
- {
- if (NoteEditorFrame != null)
- {
- CloseAnimation(NoteEditorFrame);
- NoteEditorFrame.dispose();
- }
- NoteEditorFrame = new JFrame();
- NoteEditorFrame.setTitle("Note Editor");
- NoteEditorFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- NoteEditorFrame.setUndecorated(false);
- NoteEditorFrame.setTitle(File.getName().replace(".txt", ""));
- NoteEditorFrame.setBounds(0,0,600,800);
- NoteEditorFrame.setResizable(false);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\Note.png");
- NoteEditorFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- NoteEditorFrame.setContentPane(ParentPanel);
- ParentPanel.setLayout(new BorderLayout());
- NoteEditArea = new JTextArea(20,20);
- NoteEditArea.setFont(new Font("Comic Sans MS",Font.BOLD,15));
- NoteEditArea.setBorder(new LineBorder(new Color(0, 0, 0)));
- NoteEditArea.setEditable(true);
- NoteEditArea.setAutoscrolls(true);
- NoteEditArea.setBounds(5,5,570,780);
- NoteEditArea.setLineWrap(true);
- NoteEditArea.setWrapStyleWord(true);
- NoteEditArea.setFocusable(true);
- NoteScroll = new JScrollPane(NoteEditArea,
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- NoteScroll.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));
- NoteScroll.getViewport().setBorder(null);
- NoteScroll.setViewportBorder(null);
- NoteScroll.setBorder(new LineBorder(new Color(0, 0, 0)));
- NoteScroll.setBounds(5,5,570,780);
- NoteScroll.setBorder(new EmptyBorder(10, 10, 10, 10));
- ParentPanel.add(NoteScroll, BorderLayout.CENTER);
- try
- {
- BufferedReader InitReader = new BufferedReader(new FileReader(File));
- String Line = InitReader.readLine();
- while (Line != null)
- {
- NoteEditArea.append(Line + "\n");
- Line = InitReader.readLine();
- }
- InitReader.close();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- CurrentUserNote = File;
- SaveNote = new JButton("Save & Resign");
- SaveNote.setFocusPainted(false);
- SaveNote.setBackground(new Color(223,85,83));
- SaveNote.setFont(ButtonFont);
- SaveNote.addActionListener(this);
- SaveNote.setSize(200,50);
- JPanel SavePanel = new JPanel();
- SavePanel.add(SaveNote, SwingConstants.CENTER);
- ParentPanel.add(SavePanel, BorderLayout.PAGE_END);
- ParentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- NoteEditorFrame.setLocationRelativeTo(null);
- NoteEditorFrame.setVisible(true);
- NoteEditorFrame.setAlwaysOnTop(true);
- NoteEditorFrame.setAlwaysOnTop(false);
- NoteEditorFrame.requestFocus();
- }
- public void EditUser()
- {
- if (EditUserFrame != null)
- {
- CloseAnimation(EditUserFrame);
- EditUserFrame.dispose();
- }
- EditUserFrame = new JFrame();
- EditUserFrame.setResizable(false);
- EditUserFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- EditUserFrame.setResizable(false);
- EditUserFrame.setIconImage(SASIDIcon.getImage());
- EditUserFrame.setTitle("Edit User Files");
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- JLabel BackgroundLabel = new JLabel("Backgrounds", SwingConstants.CENTER);
- BackgroundLabel.setFont(new Font("sans serif", Font.BOLD, 25));
- JPanel LabelPanel = new JPanel();
- LabelPanel.add(BackgroundLabel);
- ParentPanel.add(LabelPanel);
- InitializeBackgroundsList();
- BackgroundSelectionList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- BackgroundListScroll = new JScrollPane(BackgroundSelectionList,
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- BackgroundListScroll.setSize(400,400);
- BackgroundListScroll.setBackground(Vanila);
- ParentPanel.add(BackgroundListScroll);
- JPanel ButtonPanel = new JPanel();
- ButtonPanel.setLayout(new GridLayout(1,3,5,5));
- ButtonPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- AddBackground = new JButton("Add Background");
- ButtonPanel.add(AddBackground);
- AddBackground.setFocusPainted(false);
- AddBackground.setBackground(RegularRed);
- AddBackground.setFont(ButtonFont);
- AddBackground.addActionListener(this);
- OpenBackground = new JButton("Open Background");
- ButtonPanel.add(OpenBackground);
- OpenBackground.setFocusPainted(false);
- OpenBackground.setBackground(RegularRed);
- OpenBackground.setFont(ButtonFont);
- OpenBackground.addActionListener(this);
- DeleteBackground = new JButton("Delete Background");
- ButtonPanel.add(DeleteBackground);
- DeleteBackground.setFocusPainted(false);
- DeleteBackground.setBackground(RegularRed);
- DeleteBackground.setFont(ButtonFont);
- DeleteBackground.addActionListener(this);
- ParentPanel.add(ButtonPanel);
- JLabel MusicLabel = new JLabel("Music", SwingConstants.CENTER);
- MusicLabel.setFont(new Font("sans serif", Font.BOLD, 25));
- JPanel MusicLabelPanel = new JPanel();
- MusicLabelPanel.add(MusicLabel);
- ParentPanel.add(MusicLabelPanel);
- InitializeMusicList();
- MusicSelectionList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- MusicListScroll = new JScrollPane(MusicSelectionList,
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- MusicListScroll.setSize(400,400);
- MusicListScroll.setBackground(Vanila);
- ParentPanel.add(MusicListScroll);
- JPanel BottomButtonPanel = new JPanel();
- BottomButtonPanel.setLayout(new GridLayout(1,3,5,5));
- BottomButtonPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- AddMusic = new JButton("Add Music");
- BottomButtonPanel.add(AddMusic);
- AddMusic.setFocusPainted(false);
- AddMusic.setBackground(RegularRed);
- AddMusic.setFont(ButtonFont);
- AddMusic.addActionListener(this);
- OpenMusic = new JButton("Open Music");
- BottomButtonPanel.add(OpenMusic);
- OpenMusic.setFocusPainted(false);
- OpenMusic.setBackground(RegularRed);
- OpenMusic.setFont(ButtonFont);
- OpenMusic.addActionListener(this);
- DeleteMusic = new JButton("Delete Music");
- BottomButtonPanel.add(DeleteMusic);
- DeleteMusic.setFocusPainted(false);
- DeleteMusic.setBackground(RegularRed);
- DeleteMusic.setFont(ButtonFont);
- DeleteMusic.addActionListener(this);
- ParentPanel.add(BottomButtonPanel);
- EditUserFrame.add(ParentPanel);
- EditUserFrame.pack();
- EditUserFrame.setLocationRelativeTo(null);
- EditUserFrame.setVisible(true);
- EditUserFrame.setAlwaysOnTop(true);
- EditUserFrame.setAlwaysOnTop(false);
- EditUserFrame.requestFocus();
- }
- public void InitMusic(File File)
- {
- File[] SelectedFileDir = File.getParentFile().listFiles();
- ArrayList<File> ValidFiles = new ArrayList<File>();
- for (int i = 0 ; i < SelectedFileDir.length ; i++)
- {
- if (SelectedFileDir[i].toString().endsWith(".mp3"))
- {
- ValidFiles.add(SelectedFileDir[i]);
- if (ValidFiles.get(i).equals(File))
- {
- CurrentMusicIndex = i;
- }
- }
- }
- MusicFiles = ValidFiles.toArray(new File[ValidFiles.size()]);
- Play(MusicFiles[CurrentMusicIndex]);
- }
- public void MACAddress()
- {
- try
- {
- File DotToken = new File("SASIDFiles\\Text\\.token");
- if (!DotToken.exists())
- {
- TrayIcon.displayMessage("Unauthorized", "Sorry, but you are not authorized to use SASID", MessageType.ERROR);
- System.exit(0);
- }
- else
- {
- String DefaultUUID = "511c7c52-40c8-4e5b-8e24-bfb8293e9758"; //when giving the program to others, make sure the .token file is set to this
- BufferedReader BR = new BufferedReader(new FileReader("SASIDFiles\\Text\\.token"));
- String Line = BR.readLine();
- BR.close();
- if (Line.equals(DefaultUUID))
- {
- BufferedWriter BW = new BufferedWriter(new FileWriter("SASIDFiles\\Text\\.token", false));
- BW.write(getMACAddress());
- BW.close();
- }
- else if (!Line.equals(getMACAddress()))
- {
- TrayIcon.displayMessage("Unauthorized", "Sorry, but you are not authorized to use SASID", MessageType.ERROR);
- System.exit(0);
- }
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public String getMACAddress()
- {
- byte[] MAC = null;
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- NetworkInterface NI = NetworkInterface.getByInetAddress(address);
- MAC = NI.getHardwareAddress();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- StringBuilder sb = new StringBuilder();
- for (int i = 0 ; i < MAC.length ; i++)
- {
- sb.append(String.format("%02X%s", MAC[i], (i < MAC.length - 1) ? "-" : ""));
- }
- return sb.toString();
- }
- public void SocialMedia()
- {
- if (MediaFrame != null)
- {
- CloseAnimation(MediaFrame);
- MediaFrame.dispose();
- }
- MediaFrame = new JFrame();
- MediaFrame.setTitle("Media Widget");
- MediaFrame.setAlwaysOnTop(true);
- MediaFrame.setSize(500, 128);
- MediaFrame.setUndecorated(true);
- MediaFrame.addMouseMotionListener(this);
- MediaFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- JLabel MediaLabel = new JLabel(new ImageIcon("SASIDFiles\\Pictures\\SocialMedia.png"));
- MediaFrame.setContentPane(MediaLabel);
- Facebook = new JButton("");
- Facebook.setToolTipText("Facebook");
- Facebook.addActionListener(this);
- Facebook.setBounds(6,8,114,114);
- MediaLabel.add(Facebook);
- Facebook.setFocusPainted(false);
- Facebook.setOpaque(false);
- Facebook.setContentAreaFilled(false);
- Facebook.setBorderPainted(false);
- Twitter = new JButton("");
- Twitter.setToolTipText("Twitter");
- Twitter.addActionListener(this);
- Twitter.setBounds(132,8,115,114);
- MediaLabel.add(Twitter);
- Twitter.setFocusPainted(false);
- Twitter.setOpaque(false);
- Twitter.setContentAreaFilled(false);
- Twitter.setBorderPainted(false);
- Instagram = new JButton("");
- Instagram.setToolTipText("Instagram");
- Instagram.addActionListener(this);
- Instagram.setBounds(258,9,114,110);
- MediaLabel.add(Instagram);
- Instagram.setFocusPainted(false);
- Instagram.setOpaque(false);
- Instagram.setContentAreaFilled(false);
- Instagram.setBorderPainted(false);
- YouTube = new JButton("");
- YouTube.setToolTipText("YouTube");
- YouTube.addActionListener(this);
- YouTube.setBounds(379,7,115,110);
- MediaLabel.add(YouTube);
- YouTube.setFocusPainted(false);
- YouTube.setOpaque(false);
- YouTube.setContentAreaFilled(false);
- YouTube.setBorderPainted(false);
- MediaFrame.pack();
- MediaFrame.setVisible(true);
- MediaFrame.setLocationRelativeTo(null);
- MediaFrame.setResizable(false);
- MediaFrame.setIconImage(SASIDIcon.getImage());
- }
- public void WeatherWidget()
- {
- WeatherStats();
- Location();
- if (WeatherFrame != null)
- {
- CloseAnimation(WeatherFrame);
- WeatherFrame.dispose();
- }
- WeatherFrame = new JFrame();
- WeatherFrame.setTitle("Weather");
- WeatherFrame.setSize(1500,844);
- WeatherFrame.setUndecorated(true);
- WeatherFrame.addWindowListener(this);
- WeatherFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- WeatherLabel = new JLabel(new ImageIcon("SASIDFiles\\Pictures\\Weather.png"));
- WeatherFrame.setContentPane(WeatherLabel);
- WeatherDragLabel = new JLabel();
- WeatherDragLabel.setBounds(0,0,1426,27);
- WeatherDragLabel.addMouseMotionListener(this);
- WeatherLabel.add(WeatherDragLabel);
- MinimizeWeather = new JButton("");
- MinimizeWeather.setToolTipText("Minimize");
- MinimizeWeather.addActionListener(this);
- MinimizeWeather.addMouseListener(this);
- MinimizeWeather.setBounds(1425,10,41,23);
- ImageIcon Minimize = new ImageIcon("SASIDFiles\\Pictures\\MinimizeWeather1.png");
- MinimizeWeather.setIcon(Minimize);
- WeatherLabel.add(MinimizeWeather);
- MinimizeWeather.setFocusPainted(false);
- MinimizeWeather.setOpaque(false);
- MinimizeWeather.setContentAreaFilled(false);
- MinimizeWeather.setBorderPainted(false);
- CloseWeather = new JButton("");
- CloseWeather.setToolTipText("Close");
- CloseWeather.addActionListener(this);
- CloseWeather.addMouseListener(this);
- CloseWeather.setBounds(1468,4,27,32);
- ImageIcon Close = new ImageIcon("SASIDFiles\\Pictures\\CloseWeather1.png");
- CloseWeather.setIcon(Close);
- WeatherLabel.add(CloseWeather);
- CloseWeather.setFocusPainted(false);
- CloseWeather.setOpaque(false);
- CloseWeather.setContentAreaFilled(false);
- CloseWeather.setBorderPainted(false);
- CurrentTimeLabel = new JLabel();
- CurrentTimeLabel.setForeground(Vanila);
- CurrentTimeLabel.setFont(WeatherFontBig);
- CurrentTimeLabel.setBounds(48,85,798,37);
- CurrentTimeLabel.setText(WeatherTime());
- WeatherLabel.add(CurrentTimeLabel, SwingConstants.CENTER);
- LocationLabel = new JLabel();
- LocationLabel.setForeground(Vanila);
- LocationLabel.setFont(WeatherFontBig);
- LocationLabel.setBounds(235,129,293,37);
- LocationLabel.setText(UserCity + ", " + UserStateAbr);
- WeatherLabel.add(LocationLabel, SwingConstants.CENTER);
- CurrentWeatherIconLabel = new JLabel(new ImageIcon("SASIDFiles\\Pictures\\" + WeatherIcon + ".png"));
- CurrentWeatherIconLabel.setBounds(49, 192, 102, 88);
- WeatherLabel.add(CurrentWeatherIconLabel);
- CurrentWeatherLabel = new JLabel();
- CurrentWeatherLabel.setForeground(Vanila);
- CurrentWeatherLabel.setFont(WeatherFontBig);
- CurrentWeatherLabel.setBounds(49,304,361,33);
- CurrentWeatherLabel.setText(CapsFirst(WeatherCondition));
- WeatherLabel.add(CurrentWeatherLabel);
- TemperatureLabel = new JLabel();
- TemperatureLabel.setForeground(Vanila);
- TemperatureLabel.setFont(WeatherFontBig);
- TemperatureLabel.setBounds(49,434,355,46);
- TemperatureLabel.setText("Temperature: " + Temperature + "F");
- WeatherLabel.add(TemperatureLabel);
- UVIndexLabel = new JLabel();
- UVIndexLabel.setForeground(Vanila);
- UVIndexLabel.setFont(WeatherFontBig);
- UVIndexLabel.setBounds(56,500,210,50);
- UVIndexLabel.setText("UV Index: " + UVIndex);
- WeatherLabel.add(UVIndexLabel);
- CloudCoverLabel = new JLabel();
- CloudCoverLabel.setForeground(Vanila);
- CloudCoverLabel.setFont(WeatherFontBig);
- CloudCoverLabel.setBounds(56,555,350,50);
- CloudCoverLabel.setText("Cloud Cover: " + CloudCover);
- WeatherLabel.add(CloudCoverLabel);
- WindSpeedLabel = new JLabel();
- WindSpeedLabel.setForeground(Vanila);
- WindSpeedLabel.setFont(WeatherFontBig);
- WindSpeedLabel.setBounds(49,671,404,48);
- WindSpeedLabel.setText("Wind Speed: " + WindSpeed + "mph");
- WeatherLabel.add(WindSpeedLabel);
- WindDirectionLabel = new JLabel();
- WindDirectionLabel.setForeground(Vanila);
- WindDirectionLabel.setFont(WeatherFontBig);
- WindDirectionLabel.setBounds(49,739,559,44);
- WindDirectionLabel.setText("Wind Direction: " + WindDirection + ", " + WindDirection());
- WeatherLabel.add(WindDirectionLabel);
- HumidityLabel = new JLabel();
- HumidityLabel.setForeground(Vanila);
- HumidityLabel.setFont(WeatherFontBig);
- HumidityLabel.setBounds(1134,370,330,47);
- HumidityLabel.setText("Humidity: " + Humidity + "%");
- WeatherLabel.add(HumidityLabel,SwingConstants.CENTER);
- PressureLabel = new JLabel();
- PressureLabel.setForeground(Vanila);
- PressureLabel.setFont(WeatherFontBig);
- PressureLabel.setBounds(1134,438,390,47);
- PressureLabel.setText("Pressure: " + Double.parseDouble(Pressure) / 1000 + "atm");
- WeatherLabel.add(PressureLabel, SwingConstants.CENTER);
- VisibilityLabel = new JLabel();
- VisibilityLabel.setForeground(Vanila);
- VisibilityLabel.setFont(WeatherFontBig);
- VisibilityLabel.setBounds(1134,510,330,47);
- VisibilityLabel.setText("Visibility: " + Double.parseDouble(Visibility) / 1000 + "mi");
- WeatherLabel.add(VisibilityLabel, SwingConstants.CENTER);
- SunriseLabel = new JLabel();
- SunriseLabel.setForeground(Vanila);
- SunriseLabel.setFont(WeatherFontBig);
- SunriseLabel.setBounds(1132,740,145,47);
- SunriseLabel.setText(Sunrise + "am");
- WeatherLabel.add(SunriseLabel, SwingConstants.CENTER);
- SunsetLabel = new JLabel();
- SunsetLabel.setForeground(Vanila);
- SunsetLabel.setFont(WeatherFontBig);
- SunsetLabel.setBounds(1292,740,145,47);
- SunsetLabel.setText(Sunset + "pm");
- WeatherLabel.add(SunsetLabel, SwingConstants.CENTER);
- WeatherFrame.setVisible(true);
- WeatherFrame.setLocationRelativeTo(null);
- WeatherFrame.setAlwaysOnTop(true);
- WeatherFrame.setAlwaysOnTop(false);
- WeatherFrame.setResizable(false);
- WeatherFrame.setIconImage(new ImageIcon("SASIDFiles\\Pictures\\WeatherIcon.png").getImage());
- UpdateClock = true;
- RefreshClock();
- UpdateWeather = true;
- RefreshWeather();
- }
- public void WeatherStats()
- {
- try
- {
- Location();
- SunriseSunset();
- String DarkString = "https://api.darksky.net/forecast/3fc1a7e3f22eb67764c7dc222144bbe0/" + UserLat + "," + UserLon + "?exclude=currently,minutely,daily,alerts,flags";
- URL URL = new URL(DarkString);
- BufferedReader WeatherReader = new BufferedReader(new InputStreamReader(URL.openStream()));
- String PureJSON = WeatherReader.readLine().split("}")[0] + "}]}}";
- PureJSON = PureJSON.split("data\":")[1].replace("[", "");
- PureJSON = PureJSON.split("},")[0];
- PureJSON = PureJSON.replace("}", "").replace("{", "").replace("]", "").replace("\"","");
- String[] parts = PureJSON.split(",");
- for (int i = 0 ; i < parts.length ; i++)
- {
- if (parts[i].contains("temperature") && !parts[i].contains("apparent"))
- {
- Temperature = parts[i].replace("temperature:", "");
- }
- else if (parts[i].contains("summary"))
- {
- WeatherSummary = parts[i].replace("summary:", "");
- }
- else if (parts[i].contains("pressure"))
- {
- Pressure = parts[i].replace("pressure:", "");
- Pressure = Pressure.substring(0, Math.min(Pressure.length(), 4));
- }
- else if (parts[i].contains("humidity"))
- {
- Humidity = parts[i].replace("humidity:", "").replace("0.","");
- }
- else if (parts[i].contains("cloudCover"))
- {
- CloudCover = parts[i].replace("cloudCover:", "").replace("0.", "") + "%";
- }
- else if (parts[i].contains("uvIndex"))
- {
- UVIndex = parts[i].replace("uvIndex:", "");
- }
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public String[] CombineArrays(String[] a, String[] b)
- {
- int length = a.length + b.length;
- String[] result = new String[length];
- System.arraycopy(a, 0, result, 0, a.length);
- System.arraycopy(b, 0, result, a.length, b.length);
- return result;
- }
- public String CapsFirst(String Word)
- {
- StringBuilder SB = new StringBuilder(Word.length());
- String[] Words = Word.split("\\ ");
- for (int i = 0 ; i < Words.length ; i++)
- {
- SB.append(Character.toUpperCase(Words[i].charAt(0))).append(Words[i].substring(1)).append(" ");
- }
- return SB.toString();
- }
- public String WindDirection()
- {
- double w = Double.parseDouble(WindDirection);
- if (w == 0)
- {
- return "N";
- }
- else if (w == 90)
- {
- return "E";
- }
- else if (w == 180)
- {
- return "S";
- }
- else if (w == 270)
- {
- return "W";
- }
- else if (w > 0 && w < 90)
- {
- return "NE";
- }
- else if (w > 90 && w < 180)
- {
- return "SE";
- }
- else if (w > 180 && w < 270)
- {
- return "SW";
- }
- else if (w > 270 && w < 360)
- {
- return "NW";
- }
- return "";
- }
- public void RefreshWeather()
- {
- Thread WeatherThread = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- while (UpdateWeather)
- {
- Thread.sleep(1800000);
- LocationLabel.setText(UserCity + ", " + UserStateAbr);
- CurrentWeatherLabel.setText(CapsFirst(WeatherCondition));
- TemperatureLabel.setText("Temperature: " + Temperature + "F");
- UVIndexLabel.setText("UV Index: " + UVIndex);
- CloudCoverLabel.setText("Cloud Cover: " + CloudCover);
- WindSpeedLabel.setText("Wind Speed: " + WindSpeed + "mph");
- WindDirectionLabel.setText("Wind Direction: " + WindDirection + ", " + WindDirection());
- HumidityLabel.setText("Humidity: " + Humidity + "%");
- PressureLabel.setText("Pressure: " + Double.parseDouble(Pressure) / 1000 + "atm");
- VisibilityLabel.setText("Visibility: " + Double.parseDouble(Visibility) / 1000 + "mi");
- SunriseLabel.setText(Sunrise + "am");
- SunsetLabel.setText(Sunset + "pm");
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- };
- WeatherThread.start();
- }
- public void RefreshClock()
- {
- Thread TimeThread = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- while (UpdateClock)
- {
- Thread.sleep(1000);
- CurrentTimeLabel.setText(WeatherTime());
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- };
- TimeThread.start();
- }
- public void Tray()
- {
- if (!SystemTray.isSupported())
- {
- println("SystemTray is not supported");
- }
- MenuItem YouTube = new MenuItem("YouTube");
- YouTube.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- InternetConnect("https://www.youtube.com");
- }
- });
- MenuItem Weather = new MenuItem("Weather");
- Weather.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- WeatherWidget();
- }
- });
- MenuItem Music = new MenuItem("Music");
- Music.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- mp3(null);
- }
- });
- MenuItem Show = new MenuItem("Show Console");
- Show.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if (ConsoleFrame != null)
- {
- ConsoleFrame.setVisible(true);
- ConsoleFrame.setLocationRelativeTo(null);
- }
- }
- });
- HideOnClose = new CheckboxMenuItem("Hide on close");
- HideOnClose.setState(false);
- MenuItem Exit = new MenuItem("Exit");
- Exit.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- Tray.remove(TrayIcon);
- System.exit(0);
- }
- });
- Popup.add(YouTube);
- Popup.addSeparator();
- Popup.add(Weather);
- Popup.addSeparator();
- Popup.add(Music);
- Popup.addSeparator();
- Popup.add(Show);
- Popup.addSeparator();
- Popup.add(HideOnClose);
- Popup.addSeparator();
- Popup.add(Exit);
- TrayIcon.setPopupMenu(Popup);
- try
- {
- Tray.add(TrayIcon);
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- @Override
- public void windowActivated(WindowEvent e)
- {
- }
- @Override
- public void windowClosed(WindowEvent e)
- {
- }
- @Override
- public void windowClosing(WindowEvent e)
- {
- }
- @Override
- public void windowDeactivated(WindowEvent e)
- {
- }
- @Override
- public void windowDeiconified(WindowEvent e)
- {
- Object Source = e.getSource();
- if (Source == ConsoleFrame)
- {
- StopMusic();
- ConsoleFrame.setLocation(RestoreX, RestoreY);
- ConsoleFrame.setVisible(true);
- }
- else if (Source == WeatherFrame)
- {
- WeatherFrame.setLocation(WeatherRestoreX, WeatherRestoreY);
- WeatherFrame.setVisible(true);
- }
- }
- @Override
- public void windowIconified(WindowEvent e)
- {
- Object source = e.getSource();
- if (source == ConsoleFrame)
- {
- Iconified();
- }
- }
- @Override
- public void windowOpened(WindowEvent e)
- {
- }
- public void SunriseSunset()
- {
- try
- {
- Location();
- String Key = "2d790dd0766f1da62af488f101380c75";
- String OpenString = "https://api.openweathermap.org/data/2.5/weather?q=" + UserCity + "&appid=" + Key + "&units=imperial";
- URL URL = new URL(OpenString);
- BufferedReader WeatherReader = new BufferedReader(new InputStreamReader(URL.openStream()));
- String[] Fields = {"",""};
- String Line;
- while ((Line = WeatherReader.readLine()) != null)
- {
- String[] LineArray = Line.replace("{", "").replace("}", "")
- .replace(":", "").replace("\"", "").replace("[", "")
- .replace("]", "").replace(":", "").split(",");
- Fields = CombineArrays(Fields, LineArray);
- }
- WeatherReader.close();
- for (int i = 0 ; i < Fields.length ; i++)
- {
- if (Fields[i].contains("sunrise"))
- {
- Sunrise = Fields[i].replaceAll("[^\\d.]", "");
- }
- else if (Fields[i].contains("sunset"))
- {
- Sunset = Fields[i].replaceAll("[^\\d.]", "");
- }
- else if (Fields[i].contains("icon"))
- {
- WeatherIcon = Fields[i].replace("icon", "");
- }
- else if (Fields[i].contains("speed"))
- {
- WindSpeed = Fields[i].replaceAll("[^\\d.]", "");
- }
- else if (Fields[i].contains("deg"))
- {
- WindDirection = Fields[i].replaceAll("[^\\d.]", "");
- }
- else if (Fields[i].contains("description"))
- {
- WeatherCondition = Fields[i].replace("description", "");
- }
- else if (Fields[i].contains("visibility"))
- {
- Visibility = Fields[i].replaceAll("[^\\d.]", "");
- }
- }
- SimpleDateFormat dateFormatter = new SimpleDateFormat("h:mm");
- Date SunriseTime = new Date ((long) Integer.parseInt(Sunrise) * 1000);
- Sunrise = dateFormatter.format(SunriseTime);
- Date SunsetTime = new Date ((long) Integer.parseInt(Sunset) * 1000);
- Sunset = dateFormatter.format(SunsetTime);
- Date Time = new Date();
- if (Time.getTime() > SunsetTime.getTime())
- {
- WeatherIcon = WeatherIcon.replace("d", "n");
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public void Debug()
- {
- try
- {
- if (DebugFrame != null)
- {
- CloseAnimation(DebugFrame);
- DebugFrame.dispose();
- }
- DebugFrame = new JFrame();
- DebugFrame.setTitle("Debug Menu");
- DebugFrame.setSize(1350,900);
- DebugFrame.setUndecorated(true);
- DebugFrame.addWindowListener(this);
- DebugFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- DebugLabel = new JLabel(new ImageIcon("SASIDFiles\\Pictures\\DebugBackground.png"));
- DebugFrame.setContentPane(DebugLabel);
- DebugDragLabel = new JLabel();
- DebugDragLabel.setBounds(0,0,1350,27);
- DebugDragLabel.addMouseMotionListener(this);
- DebugDragLabel.setOpaque(true);
- DebugDragLabel.setBackground(new Color(26,32,51));
- DebugLabel.add(DebugDragLabel);
- CloseDebug = new JButton("");
- CloseDebug.setToolTipText("Close");
- CloseDebug.addActionListener(this);
- CloseDebug.addMouseListener(this);
- CloseDebug.setBounds(1323, 4, 22, 20);
- ImageIcon exit = new ImageIcon("SASIDFiles\\Pictures\\Close1.png");
- CloseDebug.setIcon(exit);
- DebugDragLabel.add(CloseDebug);
- CloseDebug.setFocusPainted(false);
- CloseDebug.setOpaque(false);
- CloseDebug.setContentAreaFilled(false);
- CloseDebug.setBorderPainted(false);
- DisplayLabel = new JLabel("",SwingConstants.LEFT);
- DisplayLabel.setFont(new Font("Segoe UI Black", Font.BOLD, 25));
- DisplayLabel.setForeground(Vanila);
- DecimalFormat GigaFormater = new DecimalFormat("##.###");
- double GigaBytes = ( (double) Runtime.getRuntime().freeMemory()) / 1024 / 1024 / 1024;
- InetAddress address = InetAddress.getLocalHost();
- NetworkInterface NI = NetworkInterface.getByInetAddress(address);
- DisplayLabel.setText("<html>" + "Time requested: " + WeatherTime() + "<br/>ISP: " + UserISP + "<br/>City: " + UserCity + "<br/>State: " + UserState + "<br/>Country: " + UserCountry
- + "<br/>Latitude: " + UserLat + " Degrees N<br/>Longitude: " + UserLon + " Degrees W<br/>Latency: " + Latency() + " ms<br/>Google Reachable: "
- + SiteReachable("https:////www.google.com") + "<br/>YouTube Reachable: " + SiteReachable("https:////www.youtube.com") + "<br/>Apple Reachable: "
- + SiteReachable("https:////www.apple.com//") + "<br/>Microsoft Reachable: " + SiteReachable("https:////www.microsoft.com//en-us//")
- + "<br/>User Name: " + CUsername + "<br/>Computer Name: " + ComputerName() + "<br/>Available Cores: " + Runtime.getRuntime().availableProcessors()
- + "<br/>Available Memory: " + Runtime.getRuntime().freeMemory() + " Bytes [" + GigaFormater.format(GigaBytes) + " GigaBytes]<br/>Operating System: "
- + OS + "<br/>Java Version: " + System.getProperty("java.version") + "<br/>Network Interface Name: " + NI.getName() + "<br/>NI Display Name: "
- + NI.getDisplayName() + "<br/>Network MTU: " + NI.getMTU() + "<br/>Host Address: " + address.getHostAddress() + "<br/>Local Host Address: "
- + address.getLocalHost() + "<br/>Loopback Address: " + address.getLoopbackAddress() + "</html>");
- DisplayLabel.setFocusable(true);
- DisplayLabel.setToolTipText("Click to copy stats to clipboard");
- DisplayLabel.addMouseListener(this);
- DebugLabel.add(DisplayLabel);
- DisplayLabel.setBounds(50, 50, 1300, 850);
- DebugFrame.setVisible(true);
- DebugFrame.setLocationRelativeTo(null);
- DebugFrame.setAlwaysOnTop(true);
- DebugFrame.setAlwaysOnTop(false);
- DebugFrame.setResizable(false);
- DebugFrame.setIconImage(new ImageIcon("SASIDFiles\\Pictures\\Debug.png").getImage());
- }
- catch (Exception e)
- {
- LogError(e);
- }
- }
- public int Latency()
- {
- Socket Sock = new Socket();
- SocketAddress Address = new InetSocketAddress("www.google.com", 80);
- int Timeout = 2000;
- long start = System.currentTimeMillis();
- try
- {
- Sock.connect(Address, Timeout);
- }
- catch (Exception e)
- {
- LogError(e);
- }
- long stop = System.currentTimeMillis();
- int Latency = (int) (stop - start);
- try
- {
- Sock.close();
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return Latency;
- }
- public boolean SiteReachable(String URL)
- {
- Process Ping;
- try
- {
- Ping = java.lang.Runtime.getRuntime().exec("ping -n 1 " + URL);
- int ReturnValue = Ping.waitFor();
- if (ReturnValue == 0)
- {
- return false;
- }
- }
- catch (Exception e)
- {
- LogError(e);
- }
- return true;
- }
- public String NumberFormat(String Format)
- {
- StringBuilder builder = new StringBuilder(Format.length() + "-".length() * (Format.length()/3)+1);
- int index = 0;
- String prefix = "";
- while (index < Format.length())
- {
- builder.append(prefix);
- prefix = "-";
- builder.append(Format.substring(index, Math.min(index + 3, Format.length())));
- index += 3;
- }
- return builder.toString();
- }
- public void Hangman()
- {
- SwingFeel(ConsoleFrame);
- if (HangmanFrame != null)
- {
- CloseAnimation(HangmanFrame);
- HangmanFrame.dispose();
- }
- HangmanFrame = new JFrame();
- HangmanFrame.setTitle("Hangman");
- HangmanFrame.setResizable(false);
- HangmanFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- ImageIcon img = new ImageIcon("SASIDFiles\\Pictures\\hangman8.png");
- HangmanFrame.setIconImage(img.getImage());
- ParentPanel = new JPanel();
- ParentPanel.setLayout(new BoxLayout(ParentPanel,BoxLayout.Y_AXIS));
- HangmanLabel = new JLabel("SASID Hangman");
- HangmanLabel.setFont(new Font("sans serif", Font.BOLD, 30));
- JPanel LabelPanel = new JPanel();
- LabelPanel.add(HangmanLabel, SwingConstants.CENTER);
- LabelPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ParentPanel.add(LabelPanel);
- HangmanImageLabel = new JLabel();
- HangmanImageLabel.setIcon(new ImageIcon("SASIDFiles\\Pictures\\hangman.png"));
- JPanel ImagePanel = new JPanel();
- ImagePanel.add(HangmanImageLabel, SwingConstants.CENTER);
- ImagePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- ParentPanel.add(ImagePanel);
- JPanel ButtonPanel = new JPanel();
- GridLayout ButtonLayout = new GridLayout(2,13,5,5);
- ButtonPanel.setLayout(ButtonLayout);
- HangmanA = new JButton("A");
- HangmanA.setPreferredSize(new Dimension(60, 60));
- HangmanA.setFocusPainted(false);
- HangmanA.setBackground(Vanila);
- HangmanA.setFont(ButtonFont);
- HangmanA.addActionListener(this);
- ButtonPanel.add(HangmanA);
- HangmanB = new JButton("B");
- HangmanB.setPreferredSize(new Dimension(60, 60));
- HangmanB.setFocusPainted(false);
- HangmanB.setBackground(Vanila);
- HangmanB.setFont(ButtonFont);
- HangmanB.addActionListener(this);
- ButtonPanel.add(HangmanB);
- HangmanC = new JButton("C");
- HangmanC.setPreferredSize(new Dimension(60, 60));
- HangmanC.setFocusPainted(false);
- HangmanC.setBackground(Vanila);
- HangmanC.setFont(ButtonFont);
- HangmanC.addActionListener(this);
- ButtonPanel.add(HangmanC);
- HangmanD = new JButton("D");
- HangmanD.setPreferredSize(new Dimension(60, 60));
- HangmanD.setFocusPainted(false);
- HangmanD.setBackground(Vanila);
- HangmanD.setFont(ButtonFont);
- HangmanD.addActionListener(this);
- ButtonPanel.add(HangmanD);
- HangmanE = new JButton("E");
- HangmanE.setPreferredSize(new Dimension(60, 60));
- HangmanE.setFocusPainted(false);
- HangmanE.setBackground(Vanila);
- HangmanE.setFont(ButtonFont);
- HangmanE.addActionListener(this);
- ButtonPanel.add(HangmanE);
- HangmanF = new JButton("F");
- HangmanF.setPreferredSize(new Dimension(60, 60));
- HangmanF.setFocusPainted(false);
- HangmanF.setBackground(Vanila);
- HangmanF.setFont(ButtonFont);
- HangmanF.addActionListener(this);
- ButtonPanel.add(HangmanF);
- HangmanG = new JButton("G");
- HangmanG.setPreferredSize(new Dimension(60, 60));
- HangmanG.setFocusPainted(false);
- HangmanG.setBackground(Vanila);
- HangmanG.setFont(ButtonFont);
- HangmanG.addActionListener(this);
- ButtonPanel.add(HangmanG);
- HangmanH = new JButton("H");
- HangmanH.setPreferredSize(new Dimension(60, 60));
- HangmanH.setFocusPainted(false);
- HangmanH.setBackground(Vanila);
- HangmanH.setFont(ButtonFont);
- HangmanH.addActionListener(this);
- ButtonPanel.add(HangmanH);
- HangmanI = new JButton("I");
- HangmanI.setPreferredSize(new Dimension(60, 60));
- HangmanI.setFocusPainted(false);
- HangmanI.setBackground(Vanila);
- HangmanI.setFont(ButtonFont);
- HangmanI.addActionListener(this);
- ButtonPanel.add(HangmanI);
- HangmanJ = new JButton("J");
- HangmanJ.setPreferredSize(new Dimension(60, 60));
- HangmanJ.setFocusPainted(false);
- HangmanJ.setBackground(Vanila);
- HangmanJ.setFont(ButtonFont);
- HangmanJ.addActionListener(this);
- ButtonPanel.add(HangmanJ);
- HangmanK = new JButton("K");
- HangmanK.setPreferredSize(new Dimension(60, 60));
- HangmanK.setFocusPainted(false);
- HangmanK.setBackground(Vanila);
- HangmanK.setFont(ButtonFont);
- HangmanK.addActionListener(this);
- ButtonPanel.add(HangmanK);
- HangmanL = new JButton("L");
- HangmanL.setPreferredSize(new Dimension(60, 60));
- HangmanL.setFocusPainted(false);
- HangmanL.setBackground(Vanila);
- HangmanL.setFont(ButtonFont);
- HangmanL.addActionListener(this);
- ButtonPanel.add(HangmanL);
- HangmanM = new JButton("M");
- HangmanM.setPreferredSize(new Dimension(60, 60));
- HangmanM.setFocusPainted(false);
- HangmanM.setBackground(Vanila);
- HangmanM.setFont(ButtonFont);
- HangmanM.addActionListener(this);
- ButtonPanel.add(HangmanM);
- HangmanN = new JButton("N");
- HangmanN.setPreferredSize(new Dimension(60, 60));
- HangmanN.setFocusPainted(false);
- HangmanN.setBackground(Vanila);
- HangmanN.setFont(ButtonFont);
- HangmanN.addActionListener(this);
- ButtonPanel.add(HangmanN);
- HangmanO = new JButton("O");
- HangmanO.setPreferredSize(new Dimension(60, 60));
- HangmanO.setFocusPainted(false);
- HangmanO.setBackground(Vanila);
- HangmanO.setFont(ButtonFont);
- HangmanO.addActionListener(this);
- ButtonPanel.add(HangmanO);
- HangmanP = new JButton("P");
- HangmanP.setPreferredSize(new Dimension(60, 60));
- HangmanP.setFocusPainted(false);
- HangmanP.setBackground(Vanila);
- HangmanP.setFont(ButtonFont);
- HangmanP.addActionListener(this);
- ButtonPanel.add(HangmanP);
- HangmanQ = new JButton("Q");
- HangmanQ.setPreferredSize(new Dimension(60, 60));
- HangmanQ.setFocusPainted(false);
- HangmanQ.setBackground(Vanila);
- HangmanQ.setFont(ButtonFont);
- HangmanQ.addActionListener(this);
- ButtonPanel.add(HangmanQ);
- HangmanR = new JButton("R");
- HangmanR.setPreferredSize(new Dimension(60, 60));
- HangmanR.setFocusPainted(false);
- HangmanR.setBackground(Vanila);
- HangmanR.setFont(ButtonFont);
- HangmanR.addActionListener(this);
- ButtonPanel.add(HangmanR);
- HangmanS = new JButton("S");
- HangmanS.setPreferredSize(new Dimension(60, 60));
- HangmanS.setFocusPainted(false);
- HangmanS.setBackground(Vanila);
- HangmanS.setFont(ButtonFont);
- HangmanS.addActionListener(this);
- ButtonPanel.add(HangmanS);
- HangmanT = new JButton("T");
- HangmanT.setPreferredSize(new Dimension(60, 60));
- HangmanT.setFocusPainted(false);
- HangmanT.setBackground(Vanila);
- HangmanT.setFont(ButtonFont);
- HangmanT.addActionListener(this);
- ButtonPanel.add(HangmanT);
- HangmanU = new JButton("U");
- HangmanU.setPreferredSize(new Dimension(60, 60));
- HangmanU.setFocusPainted(false);
- HangmanU.setBackground(Vanila);
- HangmanU.setFont(ButtonFont);
- HangmanU.addActionListener(this);
- ButtonPanel.add(HangmanU);
- HangmanV = new JButton("V");
- HangmanV.setPreferredSize(new Dimension(60, 60));
- HangmanV.setFocusPainted(false);
- HangmanV.setBackground(Vanila);
- HangmanV.setFont(ButtonFont);
- HangmanV.addActionListener(this);
- ButtonPanel.add(HangmanV);
- HangmanW = new JButton("W");
- HangmanW.setPreferredSize(new Dimension(60, 60));
- HangmanW.setFocusPainted(false);
- HangmanW.setBackground(Vanila);
- HangmanW.setFont(ButtonFont);
- HangmanW.addActionListener(this);
- ButtonPanel.add(HangmanW);
- HangmanX = new JButton("X");
- HangmanX.setPreferredSize(new Dimension(60, 60));
- HangmanX.setFocusPainted(false);
- HangmanX.setBackground(Vanila);
- HangmanX.setFont(ButtonFont);
- HangmanX.addActionListener(this);
- ButtonPanel.add(HangmanX);
- HangmanY = new JButton("Y");
- HangmanY.setPreferredSize(new Dimension(60, 60));
- HangmanY.setFocusPainted(false);
- HangmanY.setBackground(Vanila);
- HangmanY.setFont(ButtonFont);
- HangmanY.addActionListener(this);
- ButtonPanel.add(HangmanY);
- HangmanZ = new JButton("Z");
- HangmanZ.setPreferredSize(new Dimension(60, 60));
- HangmanZ.setFocusPainted(false);
- HangmanZ.setBackground(Vanila);
- HangmanZ.setFont(ButtonFont);
- HangmanZ.addActionListener(this);
- ButtonPanel.add(HangmanZ);
- ParentPanel.add(ButtonPanel);
- JPanel ResetPanel = new JPanel();
- ResetPanel.setLayout(new BorderLayout());
- HangmanReset = new JButton("Reset");
- HangmanReset.setFocusPainted(false);
- HangmanReset.setBackground(RegularRed);
- HangmanReset.setFont(ButtonFont);
- HangmanReset.addActionListener(this);
- ResetPanel.add(HangmanReset, BorderLayout.CENTER);
- ResetPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- ParentPanel.add(ResetPanel);
- ParentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- HangmanFrame.add(ParentPanel);
- HangmanFrame.pack();
- HangmanFrame.setLocationRelativeTo(null);
- HangmanFrame.setVisible(true);
- HangmanFrame.setAlwaysOnTop(true);
- HangmanFrame.setAlwaysOnTop(false);
- HangmanFrame.requestFocus();
- StartHangman();
- }
- public void StartHangman()
- {
- HangmanLabel.setFont(new Font("Dialog Font",Font.BOLD,30));
- HangmanReset.setText("Reset");
- String [] words = {"adult","advice","arrangement","attempt","August","Autumn","border","breeze","brick","calm","canal","Casey","cast","chose","claws","coach"
- ,"constantly","contrast","cookies","customs","damage","Danny","deeply","depth","discussion","doll","donkey","Egypt","Ellen","essential","exchange","exist"
- ,"explanation","facing","film","finest","fireplace","floating","folks","fort","garage","grabbed","grandmother","habit","happily","Harry","heading","hunter"
- ,"Illinois","image","independent","instant","January","kids","label","Lee","lungs","manufacturing","Martin","mathematics","melted","memory","mill","mission"
- ,"monkey","Mount","mysterious","neighborhood","Norway","nuts","occasionally","official","ourselves","palace","Pennsylvania","Philadelphia","plates","poetry"
- ,"policeman","positive","possibly","practical","pride","promised","recall","relationship","remarkable","require","rhyme","rocky","rubbed","rush","sale"
- ,"satellites","satisfied","scared","selection","shake","shaking","shallow","shout","silly","simplest","slight","slip","slope","soap","solar","species"
- ,"spin","stiff","swung","tales","thumb","tobacco","toy","trap","treated","tune","University","vapor","vessels","wealth","wolf","zoo"};
- HangmanWord = words[RI(0, words.length - 1)].toLowerCase();
- HangmanLabel.setText(FillString(HangmanWord.length(), " _ "));
- HangmanImageLabel.setIcon(new ImageIcon("SASIDFiles\\Pictures\\hangman.png"));
- HangmanWrongGuesses = 0;
- HangmanA.setEnabled(true);
- HangmanA.setForeground(Color.black);
- HangmanB.setEnabled(true);
- HangmanB.setForeground(Color.black);
- HangmanC.setEnabled(true);
- HangmanC.setForeground(Color.black);
- HangmanD.setEnabled(true);
- HangmanD.setForeground(Color.black);
- HangmanE.setEnabled(true);
- HangmanE.setForeground(Color.black);
- HangmanF.setEnabled(true);
- HangmanF.setForeground(Color.black);
- HangmanG.setEnabled(true);
- HangmanG.setForeground(Color.black);
- HangmanH.setEnabled(true);
- HangmanH.setForeground(Color.black);
- HangmanI.setEnabled(true);
- HangmanI.setForeground(Color.black);
- HangmanJ.setEnabled(true);
- HangmanJ.setForeground(Color.black);
- HangmanK.setEnabled(true);
- HangmanK.setForeground(Color.black);
- HangmanL.setEnabled(true);
- HangmanL.setForeground(Color.black);
- HangmanM.setEnabled(true);
- HangmanM.setForeground(Color.black);
- HangmanN.setEnabled(true);
- HangmanN.setForeground(Color.black);
- HangmanO.setEnabled(true);
- HangmanO.setForeground(Color.black);
- HangmanP.setEnabled(true);
- HangmanP.setForeground(Color.black);
- HangmanQ.setEnabled(true);
- HangmanQ.setForeground(Color.black);
- HangmanR.setEnabled(true);
- HangmanR.setForeground(Color.black);
- HangmanS.setEnabled(true);
- HangmanS.setForeground(Color.black);
- HangmanT.setEnabled(true);
- HangmanT.setForeground(Color.black);
- HangmanU.setEnabled(true);
- HangmanU.setForeground(Color.black);
- HangmanV.setEnabled(true);
- HangmanV.setForeground(Color.black);
- HangmanW.setEnabled(true);
- HangmanW.setForeground(Color.black);
- HangmanX.setEnabled(true);
- HangmanX.setForeground(Color.black);
- HangmanY.setEnabled(true);
- HangmanY.setForeground(Color.black);
- HangmanZ.setEnabled(true);
- HangmanZ.setForeground(Color.black);
- }
- public void LetterChosen(String letter)
- {
- if (HangmanWord.toLowerCase().contains(letter.toLowerCase()))
- {
- char[] CurrentWordState = HangmanLabel.getText().replace(" ", "").toLowerCase().toCharArray();
- char[] CurrentWord = HangmanWord.toLowerCase().toCharArray();
- for (int i = 0 ; i < CurrentWordState.length; i++)
- {
- if (CurrentWord[i] == letter.charAt(0))
- {
- CurrentWordState[i] = CurrentWord[i];
- }
- }
- String NewHangmanWord = new String(CurrentWordState);
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < NewHangmanWord.length(); i++)
- {
- if (i > 0)
- {
- result.append(" ");
- }
- result.append(NewHangmanWord.charAt(i));
- }
- HangmanLabel.setText(result.toString());
- if (!HangmanLabel.getText().contains("_"))
- {
- HangmanLabel.setFont(new Font("Dialog Font",Font.BOLD,20));
- HangmanLabel.setText("Good job! You guessed the word \"" + HangmanWord + ".\" Would you like to play again?");
- HangmanA.setEnabled(false);
- HangmanB.setEnabled(false);
- HangmanC.setEnabled(false);
- HangmanD.setEnabled(false);
- HangmanE.setEnabled(false);
- HangmanF.setEnabled(false);
- HangmanG.setEnabled(false);
- HangmanH.setEnabled(false);
- HangmanI.setEnabled(false);
- HangmanJ.setEnabled(false);
- HangmanK.setEnabled(false);
- HangmanL.setEnabled(false);
- HangmanM.setEnabled(false);
- HangmanN.setEnabled(false);
- HangmanO.setEnabled(false);
- HangmanP.setEnabled(false);
- HangmanQ.setEnabled(false);
- HangmanR.setEnabled(false);
- HangmanS.setEnabled(false);
- HangmanT.setEnabled(false);
- HangmanU.setEnabled(false);
- HangmanV.setEnabled(false);
- HangmanW.setEnabled(false);
- HangmanX.setEnabled(false);
- HangmanY.setEnabled(false);
- HangmanZ.setEnabled(false);
- HangmanReset.setText("Play Again");
- }
- }
- else
- {
- if (HangmanWrongGuesses == 7)
- {
- HangmanImageLabel.setIcon(new ImageIcon("SASIDFiles\\Pictures\\hangman8.png"));
- HangmanLabel.setFont(new Font("Dialog Font",Font.BOLD,20));
- HangmanLabel.setText("Game over! You were unable to guess \"" + HangmanWord + ".\" Would you like to play again?");
- HangmanA.setEnabled(false);
- HangmanB.setEnabled(false);
- HangmanC.setEnabled(false);
- HangmanD.setEnabled(false);
- HangmanE.setEnabled(false);
- HangmanF.setEnabled(false);
- HangmanG.setEnabled(false);
- HangmanH.setEnabled(false);
- HangmanI.setEnabled(false);
- HangmanJ.setEnabled(false);
- HangmanK.setEnabled(false);
- HangmanL.setEnabled(false);
- HangmanM.setEnabled(false);
- HangmanN.setEnabled(false);
- HangmanO.setEnabled(false);
- HangmanP.setEnabled(false);
- HangmanQ.setEnabled(false);
- HangmanR.setEnabled(false);
- HangmanS.setEnabled(false);
- HangmanT.setEnabled(false);
- HangmanU.setEnabled(false);
- HangmanV.setEnabled(false);
- HangmanW.setEnabled(false);
- HangmanX.setEnabled(false);
- HangmanY.setEnabled(false);
- HangmanZ.setEnabled(false);
- HangmanReset.setText("Play Again");
- }
- else
- {
- HangmanWrongGuesses++;
- HangmanImageLabel.setIcon(new ImageIcon("SASIDFiles\\Pictures\\hangman" + HangmanWrongGuesses + ".png"));
- }
- }
- }
- public String FillString(int count, String c)
- {
- StringBuilder sb = new StringBuilder(count);
- for (int i = 0 ; i < count ; i++)
- {
- sb.append(c);
- }
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement