}
}*/ Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize2 = tk.getScreenSize(); Insets insets = tk.getScreenInsets(theApp.getGraphicsConfiguration()); screenSize2.width -= (insets.left + insets.right); screenSize2.height -= (insets.top + insets.bottom); theApp.setSize(screenSize2); theApp.setLocation(insets.left, insets.top);
    public static void main(String[] args) {        String javaVersion = System.getProperty("java.version");        StringBuffer version = new StringBuffer(javaVersion);        for (int i=version.length()-1; i>=0; i--){            if (version.charAt(i)=='.'){                version.deleteCharAt(i);            }        }        if (javaVersion.length()>2){            javaVersion = javaVersion.substring(0, 2);        }        boolean gueltig = false;        try{            int versionsNr = Integer.parseInt(version.toString().substring(0,2));            if (versionsNr >= 14){                gueltig = true;            }        }        catch(Exception e){            //nix zu tun        }        if (!gueltig){            JOptionPane.showMessageDialog(new Frame(), "Es wird mindestens JRE 1.4 bentigt!", "appleJuice Client",                                          JOptionPane.ERROR_MESSAGE);        }        boolean processLink = false;        String link = "";        if (args != null && args.length > 0) {            try {                for (int i = 0; i < args.length; i++) {                    if (args[i].indexOf("-path=") != -1) {                        System.setProperty("user.dir", args[i].substring(6));                        break;                    }                }                boolean hilfeAusgegeben = false;                for (int i = 0; i < args.length; i++) {                    if (args[i].compareTo("-help") == 0) {                        if (hilfeAusgegeben) {                            continue;                        }                        System.out.println();                        System.out.println(                            " -help                       Diese Uebersicht.");                        System.out.println(" -path=<pfad>                Ausfuehrpfad setzen. Alles im GUI ist relativ zu diesem.");                        System.out.println(                            " -link=<md5Passwort|link>    ajfsp-Link ans GUI uebergeben. " +                            " Das GUI wird ggf gestartet.");                        System.out.println();                        hilfeAusgegeben = true;                    }                    if (args[i].indexOf("-link=") != -1) {                        link = args[i].substring(6);                        int PORT = PropertiesManager.getOptionsManager().                            getLinkListenerPort();                        String passwort = PropertiesManager.getOptionsManager().                            getRemoteSettings().getOldPassword();                        Socket socket = new Socket("localhost", PORT);                        PrintStream out = new PrintStream(socket.                            getOutputStream());                        out.println(passwort + "|" + link);                        socket.close();                        System.exit(0);                    }                }            }            catch (IOException ioE) {                //Keine bisherige GUI-Instanz vorhanden, also GUI oeffnen                processLink = true;            }            catch (Exception e) {                System.exit(1);            }        }        else{            int PORT = PropertiesManager.getOptionsManager().                getLinkListenerPort();            String passwort = PropertiesManager.getOptionsManager().                getRemoteSettings().getOldPassword();            try {                Socket socket = new Socket("localhost", PORT);                socket.close();                //bereits ein GUI vorhanden, also GUI schliessen                JOptionPane.showMessageDialog(new Frame(), "Eine Instanz des GUIs ist bereits in Verwendung.",                                              "appleJuice Client", JOptionPane.ERROR_MESSAGE);                System.exit(1);            }            catch (IOException ex) {                //alles bestens            }        }        Logger rootLogger = Logger.getRootLogger();        logger = Logger.getLogger(AppleJuiceClient.class.getName());        try {            if (PropertiesManager.getOptionsManager().isThemesSupported()) {                java.lang.reflect.Method method = JFrame.class.                    getMethod("setDefaultLookAndFeelDecorated",                              new Class[] {boolean.class});                method.invoke(null, new Object[] {Boolean.TRUE});                method = JDialog.class.                    getMethod("setDefaultLookAndFeelDecorated",                              new Class[] {boolean.class});                method.invoke(null, new Object[] {Boolean.TRUE});            }        }        catch (Exception e) {            if (logger.isEnabledFor(Level.FATAL)) {                logger.fatal("Programmabbruch", e);            }        }        String datum = new SimpleDateFormat("ddMMyyyy_HHmmss").format(new Date(            System.currentTimeMillis()));        String dateiName;        dateiName = datum + ".html";        layout = new HTMLLayout();        layout.setTitle("appleJuice-Core-GUI-Log " + datum);        layout.setLocationInfo(true);        Level logLevel = PropertiesManager.getOptionsManager().getLogLevel();        try {            rootLogger.addAppender(new ConsoleAppender());            String path = System.getProperty("user.dir") + File.separator +                "logs";            File aFile = new File(path);            if (!aFile.exists()) {                aFile.mkdir();            }            fileAppenderPath = path + File.separator + dateiName;            if (logLevel != Level.OFF) {                FileAppender fileAppender = new FileAppender(layout,                    fileAppenderPath);                rootLogger.removeAllAppenders();                rootLogger.addAppender(fileAppender);            }        }        catch (IOException ioe) {            ioe.printStackTrace();        }        rootLogger.setLevel(logLevel);        try {            String nachricht = "appleJuice-Core-GUI Version " +                ApplejuiceFassade.GUI_VERSION + " wird gestartet...";            ConnectFrame connectFrame = new ConnectFrame();            connectFrame.show();            Splash splash = new Splash(connectFrame, IconManager.getInstance().getIcon(                "splashscreen").getImage());            splash.show();            if (logger.isEnabledFor(Level.INFO)) {                logger.info(nachricht);            }            System.out.println(nachricht);            nachricht = "erkanntes GUI-OS: " + System.getProperty("os.name");            if (logger.isEnabledFor(Level.INFO)) {                logger.info(nachricht);            }            String titel = null;            LanguageSelector languageSelector = LanguageSelector.getInstance();            QuickConnectionSettingsDialog remoteDialog = null;            int versuche = 0;            AppleJuiceDialog.initThemes();            while (!ApplejuiceFassade.istCoreErreichbar()) {                versuche++;                titel = ZeichenErsetzer.korrigiereUmlaute(languageSelector.                    getFirstAttrbuteByTagName(new String[] {"mainform",                                              "caption"}));                nachricht = ZeichenErsetzer.korrigiereUmlaute(languageSelector.                    getFirstAttrbuteByTagName(new String[] {"javagui",                                              "startup",                                              "fehlversuch"}));                SoundPlayer.getInstance().playSound(SoundPlayer.VERWEIGERT);                splash.setVisible(false);                JOptionPane.showMessageDialog(connectFrame, nachricht, titel,                                              JOptionPane.ERROR_MESSAGE);                remoteDialog = new QuickConnectionSettingsDialog(connectFrame);                remoteDialog.show();                if (remoteDialog.getResult() ==                    QuickConnectionSettingsDialog.ABGEBROCHEN) {                    nachricht = ZeichenErsetzer.korrigiereUmlaute(                        languageSelector.                        getFirstAttrbuteByTagName(new String[] {"javagui",                                                  "startup",                                                  "verbindungsfehler"}));                    nachricht = nachricht.replaceFirst("%s",                        PropertiesManager.getOptionsManager().                        getRemoteSettings().                        getHost());                    JOptionPane.showMessageDialog(connectFrame, nachricht, titel,                                                  JOptionPane.OK_OPTION);                    logger.fatal(nachricht);                    System.out.println("Fehler: " + nachricht);                    connectFrame.dispose();                    System.exit( -1);                }                splash.setVisible(true);            }            if (versuche > 0) {                SoundPlayer.getInstance().playSound(SoundPlayer.ZUGANG_GEWAEHRT);            }            PositionManager lm = PropertiesManager.getPositionManager();            final AppleJuiceDialog theApp = new AppleJuiceDialog();            if (lm.isLegal()) {                theApp.setLocation(lm.getMainXY());                theApp.setSize(lm.getMainDimension());            }            else {                theApp.setLocation(20, 20);            }            connectFrame.dispose();            theApp.show();            nachricht = "appleJuice-Core-GUI luft...";            if (logger.isEnabledFor(Level.INFO)) {                logger.info(nachricht);            }            System.out.println(nachricht);            splash.dispose();            LinkListener linkListener = new LinkListener();            if (processLink) {                ApplejuiceFassade.getInstance().processLink(link);            }            if (PropertiesManager.getOptionsManager().isErsterStart()) {                WizardDialog wizardDialog = new WizardDialog(theApp, true);                Dimension appDimension = wizardDialog.getSize();                Dimension screenSize = Toolkit.getDefaultToolkit().                    getScreenSize();                wizardDialog.setLocation( (screenSize.width -                                           appDimension.width) / 2,                                         (screenSize.height -                                          appDimension.height) / 2);                wizardDialog.show();            }            Thread versionWorker = new Thread() {                public void run() {                    if (logger.isEnabledFor(Level.DEBUG)) {                        logger.debug("VersionWorkerThread gestartet. " + this);                    }                    try {                        String downloadData = WebsiteContentLoader.                            getWebsiteContent("http://download.berlios.de", 80,                            "/applejuicejava/version.txt");                        if (downloadData.length() > 0) {                            int pos1 = downloadData.indexOf("|");                            String aktuellsteVersion = downloadData.substring(0, pos1);                            StringTokenizer token1 = new StringTokenizer(                                aktuellsteVersion, ".");                            StringTokenizer token2 = new StringTokenizer(                                ApplejuiceFassade.GUI_VERSION, ".");                            if (token1.countTokens() != 3 ||                                token2.countTokens() != 3) {                                return;                            }                            String[] versionInternet = new String[3];                            String[] aktuelleVersion = new String[3];                            for (int i = 0; i < 3; i++) {                                versionInternet[i] = token1.nextToken();                                aktuelleVersion[i] = token2.nextToken();                            }                            int versionsInfoModus = PropertiesManager.                                getOptionsManager().getVersionsinfoModus();                            boolean showInfo = false;                            boolean versionUpdate = false;                            boolean importantUpdate = false;                            boolean cosmeticUpdate = false;                            if (Integer.parseInt(versionInternet[0]) >                                Integer.parseInt(aktuelleVersion[0])) {                                versionUpdate = true;                            }                            else if (Integer.parseInt(versionInternet[1]) >                                     Integer.parseInt(aktuelleVersion[1])) {                                importantUpdate = true;                            }                            else if (Integer.parseInt(versionInternet[2]) >                                     Integer.parseInt(aktuelleVersion[2])) {                                cosmeticUpdate = true;                            }                            if (versionsInfoModus==2                                && (cosmeticUpdate || importantUpdate || versionUpdate )){                                showInfo = true;                            }                            else if(versionsInfoModus==1                                    && (importantUpdate || versionUpdate)){                                showInfo = true;                            }                            else if(versionsInfoModus==0                                    && versionUpdate){                                showInfo = true;                            }                            if (showInfo) {                                int pos2 = downloadData.lastIndexOf("|");                                String winLink = downloadData.substring(pos1 + 1, pos2);                                String sonstigeLink = downloadData.substring(pos2 + 1);                                UpdateInformationDialog updateInformationDialog =                                    new UpdateInformationDialog(theApp, aktuellsteVersion, winLink, sonstigeLink);                                updateInformationDialog.show();                            }                        }                    }                    catch (Exception e) {                        if (logger.isEnabledFor(Level.INFO)) {                            logger.info(                                "Aktualisierungsinformationen konnten nicht geladen werden. Server down?");                        }                    }                    if (logger.isEnabledFor(Level.DEBUG)) {                        logger.debug("VersionWorkerThread beendet. " + this);                    }                }            };            versionWorker.start();        }        catch (Exception e) {            if (logger.isEnabledFor(Level.FATAL)) {                logger.fatal("Programmabbruch", e);            }            System.exit( -1);        }    }