public static void main(String[] args) { String osName = System.getProperty("os.name"); if (osName != null && !osName.equals("")) { if (osName.toLowerCase().contains("windows")) { try { UIManager.setLookAndFeel(new WindowsLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } } } MainWindow mainWindow = new MainWindow(); mainWindow.setTitle("Jar Class Finder"); URL url = Launcher.class.getClassLoader().getResource("cn/jun/image/JarClassFinderLogo.png"); ImageIcon imageIcon = new ImageIcon(url); Image image = imageIcon.getImage(); mainWindow.setIconImage(image); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainWindow.setVisible(true); }
/** * Starts the program, creating the main objects. * * @return A reference to the application's MainWindow. */ public MainWindow start() { ActionFactory actionFactory; // create the main objects and link them together process = new biogenesis.Process(); currentWorld = new CurrentWorld(new World(new STOrganismFactory())); mainWindow = new MainWindow(currentWorld, process); visibleWorld = new VisibleWorld(mainWindow, currentWorld); mainWindow.setIconImage(imageIcon.getImage()); currentWorld.getWorld().genesis(); netServer = new NetServerThread(currentWorld); currentWorld.addListener(netServer); // sets net server if (Utils.ACCEPT_CONNECTIONS) { netServer.setAcceptConnections(true); netServer.startServer(); } // sets listeners netServer.addStatusListener(mainWindow.getStatusBar()); process.addTimeListener(mainWindow); process.addTimeListener(currentWorld); // starts timer process.startLifeProcess(Utils.DELAY); // initialize actions ActionFactory.init(mainWindow, process, currentWorld, visibleWorld, netServer); actionFactory = ActionFactory.getInstance(); // set specific actions as listeners mainWindow.addWindowListener(actionFactory.getQuitAction()); mainWindow.getOrganismTracker().addObserver(actionFactory.getAbortTrackingAction()); process.addPauseListener(actionFactory.getStartStopAction()); // create menu bars initToolBar(); mainWindow.setJMenuBar(new MainMenu()); return mainWindow; }