Example usage for javax.swing ImageIcon getImage

List of usage examples for javax.swing ImageIcon getImage

Introduction

In this page you can find the example usage for javax.swing ImageIcon getImage.

Prototype

@Transient
public Image getImage() 

Source Link

Document

Returns this icon's Image.

Usage

From source file:de.main.sessioncreator.DesktopApplication1View.java

public DesktopApplication1View(SingleFrameApplication app) {
    super(app);/*www . ja v a2  s  .c om*/
    java.net.URL imgURL = getClass().getResource("resources/sc.gif");
    ImageIcon image = new ImageIcon(imgURL, "session creator");
    this.getFrame().setIconImage(image.getImage());
    this.getFrame().pack();
    Dimension dimension = new Dimension(1030, 650);
    this.getFrame().setMinimumSize(dimension);
    this.getFrame().setTitle("SessionCreator - Wizard");

    initComponents();

    swingHelper.setConfigPaths(wizardTfPathTodo);
    swingHelper.setConfigPaths(wizardTfPathSubmitted);
    swingHelper.setConfigPaths(wizardtfCoverageini);
    progressBar.setVisible(false);
    MouseListener popupListener = activateActionListener();
    wizardtaBugs.addMouseListener(popupListener);
    wizardtaIssues.addMouseListener(popupListener);
    swingHelper.setTesterCombox(wizardCmbxTester);
    wizardtabp.setSelectedIndex(0);
    swingHelper.setTab1EnableAt(wizardtabp, 0);
    wizardbtnStart.setVisible(false);
    wizardbtntopStart.setEnabled(false);
    wizardbtnStop.setVisible(false);
    wizardbtntopStop.setEnabled(false);
    wizardbtnSave.setVisible(false);
    wizardbtntopSave.setEnabled(false);
    wizardbtnNew.setVisible(false);
    wizardbtntopNew.setEnabled(false);
    saveMenuItem.setEnabled(false);
    wizardCmbxMoreTester.setEnabled(false);
    if (wizardshown) {
        wizardbtnAddAreas.addActionListener(new AddListener());
        sessionWizardMenuItem.setEnabled(false);
        reviewVieMenuItem.setEnabled(true);
        sessionReportMenuItem.setEnabled(true);
        viewReviewsPanel.setVisible(false);
        reportPanel.setVisible(false);
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void applyPrefsToUI() {
    if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize())) {
        toolbarButtonMargin.set(2, 14, 2, 14);
    } else {//from www .  j a va2s. co m
        toolbarButtonMargin.set(0, 0, 0, 0);
    }
    if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize())) {
        //iterate on buttons and resize them to 16x16
        for (int chip = 0; chip < 2; chip++) {
            for (Component component : toolBar[chip].getComponents()) {
                if (component instanceof JButton) {
                    JButton button = (JButton) component;
                    ImageIcon icon = (ImageIcon) button.getClientProperty(BUTTON_PROPERTY_KEY_ICON);
                    if (icon != null) {
                        Image newImg = icon.getImage().getScaledInstance(16, 16, java.awt.Image.SCALE_SMOOTH);
                        button.setIcon(new ImageIcon(newImg));
                    }
                }
            }
        }
    } else {
        //iterate on buttons and revert to original icon
        for (int chip = 0; chip < 2; chip++) {
            for (Component component : toolBar[chip].getComponents()) {
                if (component instanceof JButton) {
                    JButton button = (JButton) component;
                    ImageIcon icon = (ImageIcon) button.getClientProperty(BUTTON_PROPERTY_KEY_ICON);
                    if (icon != null) {
                        button.setIcon(icon);
                    }
                }
            }
        }
    }
    initProgrammableTimerAnimationIcons(prefs.getButtonSize());
    for (int chip = 0; chip < 2; chip++) {
        toolBar[chip].revalidate();
    }
}

From source file:Form.Principal.java

public void PerfilUsuario(int idUsuario) {
    idUsuarioPerfil = idUsuario;//w w  w  . j  av a  2s.  c o m
    try {
        File FotoPerfil = new File("Imagenes/Fotos Perfil/" + idUsuario + ".png");
        File FotoPerfil2 = new File("Imagenes/Fotos Perfil/" + idUsuario + ".jpg");
        Comando = Funcion.Select(st, "SELECT * FROM usuarios WHERE id = " + idUsuario + ";");
        if (FotoPerfil.exists()) {
            ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + idUsuario + ".png");
            Image ImagenEscalada = Imagen.getImage().getScaledInstance(jLabel2.getWidth(), jLabel2.getHeight(),
                    Image.SCALE_SMOOTH);
            Icon IconoEscalado = new ImageIcon(ImagenEscalada);
            jLabel2.setIcon(IconoEscalado);
        } else if (FotoPerfil2.exists()) {
            ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + idUsuario + ".jpg");
            Image ImagenEscalada = Imagen.getImage().getScaledInstance(jLabel2.getWidth(), jLabel2.getHeight(),
                    Image.SCALE_SMOOTH);
            Icon IconoEscalado = new ImageIcon(ImagenEscalada);
            jLabel2.setIcon(IconoEscalado);
        } else {
            ImageIcon Imagen = new ImageIcon(getClass().getResource("/Imagen/Default.png"));
            Image ImagenEscalada = Imagen.getImage().getScaledInstance(jLabel2.getWidth(), jLabel2.getHeight(),
                    Image.SCALE_SMOOTH);
            Icon IconoEscalado = new ImageIcon(ImagenEscalada);
            jLabel2.setIcon(IconoEscalado);
        }
        while (Comando.next()) {
            jTextField24.setText(Comando.getString("Nombre"));
            jTextField26.setText(Comando.getString("contrasena"));
            if (Comando.getString("tipo").equals("Usuario")) {
                jComboBox1.setSelectedIndex(0);
            } else if (Comando.getString("tipo").equals("Administrador")) {
                jComboBox1.setSelectedIndex(1);
            }
            jTextField23.setText(Comando.getString("correo"));
            jPasswordField1.setText(Comando.getString("Contcorreo"));
        }
    } catch (Exception e) {
        System.out.println(e);
    }
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Tries to do the login, if doAutoLogin is set to true it will try without displaying a dialog
 * and if the login fails then it will display the dialog
 * @param userName single signon username (for application)
 * @param password single signon password (for application)
 * @param usrPwdProvider the provider/*from   ww w .j  ava  2s.  c  o  m*/
 * @param engageUPPrefs indicates whether the username and password should be loaded and remembered by local prefs
 * @param doAutoLogin whether to try to automatically log the user in
 * @param doAutoClose whether it should automatically close the window when it is logged in successfully
 * @param useDialog use a Dialog or a Frame
 * @param listener a listener for when it is logged in or fails
 * @param iconName name of icon to use
 * @param title name
 * @param appName name
 * @param appIconName application icon name
 * @param helpContext help context for Help button on dialog
 */
public static DatabaseLoginPanel doLogin(final String userName, final String password,
        final boolean engageUPPrefs, final MasterPasswordProviderIFace usrPwdProvider,
        final boolean doAutoClose, final boolean useDialog, final DatabaseLoginListener listener,
        final String iconName, final String title, final String appName, final String appIconName,
        final String helpContext, final boolean appCanUpdateSchema) //frame's icon name
{

    ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std32);
    if (StringUtils.isNotEmpty(appIconName)) {
        ImageIcon imgIcon = IconManager.getIcon(appIconName);
        if (imgIcon != null) {
            icon = imgIcon;
        }
    }

    if (useDialog) {
        JDialog.setDefaultLookAndFeelDecorated(false);
        DatabaseLoginDlg dlg = new DatabaseLoginDlg((Frame) UIRegistry.getTopWindow(), userName, password,
                engageUPPrefs, listener, iconName, helpContext);
        JDialog.setDefaultLookAndFeelDecorated(true);
        dlg.setDoAutoClose(doAutoClose);
        dlg.setModal(true);
        if (StringUtils.isNotEmpty(title)) {
            dlg.setTitle(title);
        }
        dlg.setIconImage(icon.getImage());
        UIHelper.centerAndShow(dlg);
        return dlg.getDatabaseLoginPanel();

    }
    // else
    class DBListener implements DatabaseLoginListener {
        protected JFrame frame;
        protected DatabaseLoginListener frameDBListener;
        protected boolean doAutoCloseOfListener;

        public DBListener(JFrame frame, DatabaseLoginListener frameDBListener, boolean doAutoCloseOfListener) {
            this.frame = frame;
            this.frameDBListener = frameDBListener;
            this.doAutoCloseOfListener = doAutoCloseOfListener;
        }

        public void loggedIn(final Window window, final String databaseName, final String userNameArg) {
            log.debug("UIHelper.doLogin[DBListener]");
            if (doAutoCloseOfListener) {
                frame.setVisible(false);
            }
            frameDBListener.loggedIn(window, databaseName, userNameArg);
        }

        public void cancelled() {
            frame.setVisible(false);
            frameDBListener.cancelled();
        }
    }
    JFrame.setDefaultLookAndFeelDecorated(false);

    JFrame frame = new JFrame(title);
    DatabaseLoginPanel panel;
    if (StringUtils.isNotEmpty(title)) {
        panel = new DatabaseLoginPanel(userName, password, engageUPPrefs, usrPwdProvider,
                new DBListener(frame, listener, doAutoClose), false, true, title, appName, iconName,
                helpContext);
    } else {
        panel = new DatabaseLoginPanel(userName, password, engageUPPrefs, usrPwdProvider,
                new DBListener(frame, listener, doAutoClose), false, true, null, null, iconName, helpContext);
    }

    panel.setAppCanUpdateSchema(appCanUpdateSchema);
    panel.setAutoClose(doAutoClose);
    panel.setWindow(frame);
    frame.setContentPane(panel);
    frame.setIconImage(icon.getImage());
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    frame.pack();

    UIHelper.centerAndShow(frame);

    return panel;
}

From source file:Form.Principal.java

public void PanelUsuarios() {
    int i = 0;//from w  w  w  .j  a  va  2 s.co  m
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color azul = new Color(0, 153, 255);
    Color rojo = new Color(221, 76, 76);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st, "SELECT * FROM usuarios where Tipo!='Administrador';");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel12.add(Panel);
            //Tamao del panel
            Panel.setSize(500, 200);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 40 + (i * 220);
            Panel.setLocation(175, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo
            JLabel Foto = new JLabel();
            Foto.setSize(150, 150);
            File FotoPerfil = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png");
            File FotoPerfil2 = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg");
            if (FotoPerfil.exists()) {
                ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png");
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            } else if (FotoPerfil2.exists()) {
                ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg");
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            } else {
                ImageIcon Imagen = new ImageIcon(getClass().getResource("/Imagen/Default.png"));
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            }
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre de Usuario: " + Comandos.getString("Nombre"));
            JLabel Contrasena = new JLabel();
            Contrasena.setText(("Contrasea: " + Comandos.getString("contrasena")));
            JButton Editar = new JButton();
            Editar.setText("Editar");
            Editar.setName(Comandos.getString("id"));
            Editar.setBackground(azul);
            JButton Eliminar = new JButton();
            Eliminar.setText("Eliminar");
            Eliminar.setName(Comandos.getString("id"));
            Eliminar.setBackground(rojo);
            MouseListener mlEditar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    presionadoactual = 24;
                    Color azul = new Color(0, 182, 230);
                    jButton24.setBackground(azul);
                    JButton source = (JButton) e.getSource();
                    System.out.println(source.getName());
                    jPanel17.setVisible(false);
                    jButton30.setLocation(470, 480);
                    jButton31.setLocation(270, 480);
                    jLabel2.setToolTipText(null);
                    jTabbedPane2.setSelectedIndex(5);
                    editando = true;
                    PerfilUsuario(Integer.parseInt(source.getName()));
                    Color gris = new Color(44, 44, 44);
                    jButton4.setBackground(gris);
                }
            };
            MouseListener mlEliminar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    System.out.println(source.getName());
                    Funcion.Update(st, "DELETE FROM usuarios WHERE id = " + source.getName() + ";");
                    jPanel12.removeAll();
                    PanelUsuarios();
                    jPanel12.repaint();
                }
            };
            Editar.addMouseListener(mlEditar);
            Eliminar.addMouseListener(mlEliminar);
            //Fuente del texto;
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 15));
            Nombre.setForeground(gris);
            Contrasena.setFont(new Font("Verdana", Font.PLAIN, 15));
            Contrasena.setForeground(gris);
            Editar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Editar.setForeground(Color.white);
            Eliminar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Eliminar.setForeground(Color.white);
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(Foto);
            Panel.add(Nombre);
            Panel.add(Contrasena);
            Panel.add(Editar);
            Panel.add(Eliminar);
            Foto.setLocation(10, 20);
            Nombre.setLocation(170, 30);
            Nombre.setSize(300, 45);
            Contrasena.setLocation(170, 60);
            Contrasena.setSize(300, 45);
            Editar.setLocation(170, 100);
            Editar.setSize(120, 40);
            Eliminar.setLocation(315, 100);
            Eliminar.setSize(120, 40);
            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel12.setPreferredSize(new Dimension(jPanel12.getWidth(), Altura + 150));

}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void createAndShowFullGUI() {
    // Create and setup window
    final JFrame jframe = new JFrame(Constants.APP_NAME);
    jframe.setName(Constants.APP_NAME + ".main");

    int min_width = CML_OPT_WIDTH;
    int min_height = CML_OPT_HEIGHT;
    jframe.setPreferredSize(new Dimension(min_width, min_height));
    jframe.setMinimumSize(new Dimension(min_width, min_height));
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - min_width) / 2;
    int y = (screen.height - min_height) / 2;
    jframe.setBounds(x, y, min_width, min_height);

    // Set application icon
    if (Utilities.appCustomization().equals("ywesee")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("desitin")) {
        ImageIcon img = new ImageIcon(Constants.DESITIN_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("meddrugs")) {
        ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("zurrose")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    }//  w w w.ja v a 2 s. co  m

    // ------ Setup menubar ------
    JMenuBar menu_bar = new JMenuBar();
    // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right!
    // -- Menu "Datei" --
    JMenu datei_menu = new JMenu("Datei");
    if (Utilities.appLanguage().equals("fr"))
        datei_menu.setText("Fichier");
    menu_bar.add(datei_menu);
    JMenuItem print_item = new JMenuItem("Drucken...");
    JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "...");
    JMenuItem quit_item = new JMenuItem("Beenden");
    if (Utilities.appLanguage().equals("fr")) {
        print_item.setText("Imprimer");
        quit_item.setText("Terminer");
    }
    datei_menu.add(print_item);
    datei_menu.addSeparator();
    datei_menu.add(settings_item);
    datei_menu.addSeparator();
    datei_menu.add(quit_item);

    // -- Menu "Aktualisieren" --
    JMenu update_menu = new JMenu("Aktualisieren");
    if (Utilities.appLanguage().equals("fr"))
        update_menu.setText("Mise  jour");
    menu_bar.add(update_menu);
    final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet...");
    updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei...");
    update_menu.add(updatedb_item);
    update_menu.add(choosedb_item);
    if (Utilities.appLanguage().equals("fr")) {
        updatedb_item.setText("Tlcharger la banque de donnes...");
        updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        choosedb_item.setText("Ajourner la banque de donnes...");
    }

    // -- Menu "Hilfe" --
    JMenu hilfe_menu = new JMenu("Hilfe");
    if (Utilities.appLanguage().equals("fr"))
        hilfe_menu.setText("Aide");
    menu_bar.add(hilfe_menu);

    JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "...");
    JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet");
    if (Utilities.appCustomization().equals("meddrugs"))
        ywesee_item.setText("med-drugs im Internet");
    JMenuItem report_item = new JMenuItem("Error Report...");
    JMenuItem contact_item = new JMenuItem("Kontakt...");

    if (Utilities.appLanguage().equals("fr")) {
        // Extrawunsch med-drugs
        if (Utilities.appCustomization().equals("meddrugs"))
            about_item.setText(Constants.APP_NAME);
        else
            about_item.setText("A propos de " + Constants.APP_NAME + "...");
        contact_item.setText("Contact...");
        if (Utilities.appCustomization().equals("meddrugs"))
            ywesee_item.setText("med-drugs sur Internet");
        else
            ywesee_item.setText(Constants.APP_NAME + " sur Internet");
        report_item.setText("Rapport d'erreur...");
    }
    hilfe_menu.add(about_item);
    hilfe_menu.add(ywesee_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(report_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(contact_item);

    // Menu "Abonnieren" (only for ywesee)
    JMenu subscribe_menu = new JMenu("Abonnieren");
    if (Utilities.appLanguage().equals("fr"))
        subscribe_menu.setText("Abonnement");
    if (Utilities.appCustomization().equals("ywesee")) {
        menu_bar.add(subscribe_menu);
    }

    jframe.setJMenuBar(menu_bar);

    // ------ Setup toolbar ------
    JToolBar toolBar = new JToolBar("Database");
    toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64));
    final JToggleButton selectAipsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png"));
    final JToggleButton selectFavoritesButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png"));
    final JToggleButton selectInteractionsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png"));
    final JToggleButton selectShoppingCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png"));
    final JToggleButton selectComparisonCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png"));

    final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton,
            selectShoppingCartButton, selectComparisonCartButton };

    if (Utilities.appLanguage().equals("de")) {
        setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    } else if (Utilities.appLanguage().equals("fr")) {
        setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    }

    // Add to toolbar and set up
    toolBar.setBackground(m_toolbar_bg);
    toolBar.add(selectAipsButton);
    toolBar.addSeparator();
    toolBar.add(selectFavoritesButton);
    toolBar.addSeparator();
    toolBar.add(selectInteractionsButton);
    if (!Utilities.appCustomization().equals("zurrose")) {
        toolBar.addSeparator();
        toolBar.add(selectShoppingCartButton);
    }
    if (Utilities.appCustomization().equals("zurrorse")) {
        toolBar.addSeparator();
        toolBar.add(selectComparisonCartButton);
    }
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    // Progress indicator (not working...)
    toolBar.addSeparator(new Dimension(32, 32));
    toolBar.add(m_progress_indicator);

    // ------ Setup settingspage ------
    final SettingsPage settingsPage = new SettingsPage(jframe, m_rb);
    // Attach observer to it
    settingsPage.addObserver(new Observer() {
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            if (m_shopping_cart != null) {
                // Refresh some stuff
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
        }
    });

    jframe.addWindowListener(new WindowListener() {
        // Use WindowAdapter!
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
            m_web_panel.dispose();
            Runtime.getRuntime().exit(0);
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // Save shopping cart
            int index = m_shopping_cart.getCartIndex();
            if (index > 0 && m_web_panel != null)
                m_web_panel.saveShoppingCartWithIndex(index);
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
    print_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            m_web_panel.print();
        }
    });
    settings_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            settingsPage.display();
        }
    });
    quit_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                // Save shopping cart
                int index = m_shopping_cart.getCartIndex();
                if (index > 0 && m_web_panel != null)
                    m_web_panel.saveShoppingCartWithIndex(index);
                // Save settings
                WindowSaver.saveSettings();
                m_web_panel.dispose();
                Runtime.getRuntime().exit(0);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    });
    subscribe_menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI(
                                "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent event) {
            // do nothing
        }

        @Override
        public void menuCanceled(MenuEvent event) {
            // do nothing
        }
    });
    contact_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI.create(
                                "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    report_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            // Check first m_application_folder otherwise resort to
            // pre-installed report
            String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE
                    + Utilities.appLanguage() + ".html";
            if (!(new File(report_file)).exists())
                report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE
                        + Utilities.appLanguage() + ".html";
            // Open report file in browser
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new File(report_file).toURI());
                } catch (IOException e) {
                    // TODO:
                }
            }
        }
    });
    ywesee_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(
                                new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        if (Utilities.appLanguage().equals("de"))
                            Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch"));
                        else if (Utilities.appLanguage().equals("fr"))
                            Desktop.getDesktop()
                                    .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    about_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
            ad.AboutDialog();
        }
    });

    // Container
    final Container container = jframe.getContentPane();
    container.setBackground(Color.WHITE);
    container.setLayout(new BorderLayout());

    // ==== Toolbar =====
    container.add(toolBar, BorderLayout.NORTH);

    // ==== Left panel ====
    JPanel left_panel = new JPanel();
    left_panel.setBackground(Color.WHITE);
    left_panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 2, 2, 2);

    // ---- Search field ----
    final SearchField searchField = new SearchField("Suche Prparat");
    if (Utilities.appLanguage().equals("fr"))
        searchField.setText("Recherche Specialit");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(searchField, gbc);
    left_panel.add(searchField, gbc);

    // ---- Buttons ----
    // Names
    String l_title = "Prparat";
    String l_author = "Inhaberin";
    String l_atccode = "Wirkstoff / ATC Code";
    String l_regnr = "Zulassungsnummer";
    String l_ingredient = "Wirkstoff";
    String l_therapy = "Therapie";
    String l_search = "Suche";

    if (Utilities.appLanguage().equals("fr")) {
        l_title = "Spcialit";
        l_author = "Titulaire";
        l_atccode = "Principe Active / Code ATC";
        l_regnr = "Nombre Enregistration";
        l_ingredient = "Principe Active";
        l_therapy = "Thrapie";
        l_search = "Recherche";
    }

    ButtonGroup bg = new ButtonGroup();

    JToggleButton but_title = new JToggleButton(l_title);
    setupToggleButton(but_title);
    bg.add(but_title);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_title, gbc);
    left_panel.add(but_title, gbc);

    JToggleButton but_auth = new JToggleButton(l_author);
    setupToggleButton(but_auth);
    bg.add(but_auth);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_auth, gbc);
    left_panel.add(but_auth, gbc);

    JToggleButton but_atccode = new JToggleButton(l_atccode);
    setupToggleButton(but_atccode);
    bg.add(but_atccode);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_atccode, gbc);
    left_panel.add(but_atccode, gbc);

    JToggleButton but_regnr = new JToggleButton(l_regnr);
    setupToggleButton(but_regnr);
    bg.add(but_regnr);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_regnr, gbc);
    left_panel.add(but_regnr, gbc);

    JToggleButton but_therapy = new JToggleButton(l_therapy);
    setupToggleButton(but_therapy);
    bg.add(but_therapy);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_therapy, gbc);
    left_panel.add(but_therapy, gbc);

    // ---- Card layout ----
    final CardLayout cardl = new CardLayout();
    cardl.setHgap(-4); // HACK to make things look better!!
    final JPanel p_results = new JPanel(cardl);
    m_list_titles = new ListPanel();
    m_list_auths = new ListPanel();
    m_list_regnrs = new ListPanel();
    m_list_atccodes = new ListPanel();
    m_list_ingredients = new ListPanel();
    m_list_therapies = new ListPanel();
    // Contraints
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 10;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    //
    p_results.add(m_list_titles, l_title);
    p_results.add(m_list_auths, l_author);
    p_results.add(m_list_regnrs, l_regnr);
    p_results.add(m_list_atccodes, l_atccode);
    p_results.add(m_list_ingredients, l_ingredient);
    p_results.add(m_list_therapies, l_therapy);

    // --> container.add(p_results, gbc);
    left_panel.add(p_results, gbc);
    left_panel.setBorder(null);
    // First card to show
    cardl.show(p_results, l_title);

    // ==== Right panel ====
    JPanel right_panel = new JPanel();
    right_panel.setBackground(Color.WHITE);
    right_panel.setLayout(new GridBagLayout());

    // ---- Section titles ----
    m_section_titles = null;
    if (Utilities.appLanguage().equals("de")) {
        m_section_titles = new IndexPanel(SectionTitle_DE);
    } else if (Utilities.appLanguage().equals("fr")) {
        m_section_titles = new IndexPanel(SectionTitle_FR);
    }
    m_section_titles.setMinimumSize(new Dimension(150, 150));
    m_section_titles.setMaximumSize(new Dimension(320, 1000));

    // ---- Fachinformation ----
    m_web_panel = new WebPanel2();
    m_web_panel.setMinimumSize(new Dimension(320, 150));

    // Add JSplitPane on the RIGHT
    final int Divider_location = 150;
    final int Divider_size = 10;
    final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles,
            m_web_panel);
    split_pane_right.setOneTouchExpandable(true);
    split_pane_right.setDividerLocation(Divider_location);
    split_pane_right.setDividerSize(Divider_size);

    // Add JSplitPane on the LEFT
    JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel,
            split_pane_right /* right_panel */);
    split_pane_left.setOneTouchExpandable(true);
    split_pane_left.setDividerLocation(320); // Sets the pane divider location
    split_pane_left.setDividerSize(Divider_size);
    container.add(split_pane_left, BorderLayout.CENTER);

    // Add status bar on the bottom
    JPanel statusPanel = new JPanel();
    statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16));
    statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
    container.add(statusPanel, BorderLayout.SOUTH);

    final JLabel m_status_label = new JLabel("");
    m_status_label.setHorizontalAlignment(SwingConstants.LEFT);
    statusPanel.add(m_status_label);

    // Add mouse listener
    searchField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            searchField.setText("");
        }
    });

    final String final_title = l_title;
    final String final_author = l_author;
    final String final_atccode = l_atccode;
    final String final_regnr = l_regnr;
    final String final_therapy = l_therapy;
    final String final_search = l_search;

    // Internal class that implements switching between buttons
    final class Toggle {
        public void toggleButton(JToggleButton jbn) {
            for (int i = 0; i < list_of_buttons.length; ++i) {
                if (jbn == list_of_buttons[i])
                    list_of_buttons[i].setSelected(true);
                else
                    list_of_buttons[i].setSelected(false);
            }
        }
    }
    ;

    // ------ Add toolbar action listeners ------
    selectAipsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectAipsButton);
            // Set state 'aips'
            if (!m_curr_uistate.getUseMode().equals("aips")) {
                m_curr_uistate.setUseMode("aips");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        m_query_str = searchField.getText();
                        int num_hits = retrieveAipsSearchResults(false);
                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                        //
                        if (med_index < 0 && prev_med_index >= 0)
                            med_index = prev_med_index;
                        m_web_panel.updateText();
                        if (num_hits == 0) {
                            m_web_panel.emptyPage();
                        }
                    }
                });
            }
        }
    });
    selectFavoritesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectFavoritesButton);
            // Set state 'favorites'
            if (!m_curr_uistate.getUseMode().equals("favorites")) {
                m_curr_uistate.setUseMode("favorites");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // m_query_str = searchField.getText();
                        // Clear the search container
                        med_search.clear();
                        for (String regnr : favorite_meds_set) {
                            List<Medication> meds = m_sqldb.searchRegNr(regnr);
                            if (!meds.isEmpty()) { // Add med database ID
                                med_search.add(meds.get(0));
                            }
                        }
                        // Sort list of meds
                        Collections.sort(med_search, new Comparator<Medication>() {
                            @Override
                            public int compare(final Medication m1, final Medication m2) {
                                return m1.getTitle().compareTo(m2.getTitle());
                            }
                        });

                        sTitle();
                        cardl.show(p_results, final_title);

                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });
    selectInteractionsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectInteractionsButton);
            // Set state 'interactions'
            if (!m_curr_uistate.getUseMode().equals("interactions")) {
                m_curr_uistate.setUseMode("interactions");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_query_str = searchField.getText();
                        retrieveAipsSearchResults(false);
                        // Switch to interaction mode
                        m_web_panel.updateInteractionsCart();
                        m_web_panel.repaint();
                        m_web_panel.validate();
                    }
                });
            }
        }
    });
    selectShoppingCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String email_adr = m_prefs.get("emailadresse", "");
            if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address
                m_preferences_ok = true;
            if (m_preferences_ok) {
                m_preferences_ok = false; // Check always
                new Toggle().toggleButton(selectShoppingCartButton);
                // Set state 'shopping'
                if (!m_curr_uistate.getUseMode().equals("shopping")) {
                    m_curr_uistate.setUseMode("shopping");
                    // Show middle pane
                    split_pane_right.setDividerSize(Divider_size);
                    split_pane_right.setDividerLocation(Divider_location);
                    m_section_titles.setVisible(true);
                    // Set right panel title
                    m_web_panel.setTitle(m_rb.getString("shoppingCart"));
                    // Switch to shopping cart
                    int index = 1;
                    if (m_shopping_cart != null) {
                        index = m_shopping_cart.getCartIndex();
                        m_web_panel.loadShoppingCartWithIndex(index);
                        // m_shopping_cart.printShoppingBasket();
                    }
                    // m_web_panel.updateShoppingHtml();
                    m_web_panel.updateListOfPackages();
                    if (m_first_pass == true) {
                        m_first_pass = false;
                        if (Utilities.appCustomization().equals("ywesee"))
                            med_search = m_sqldb.searchAuth("ibsa");
                        else if (Utilities.appCustomization().equals("desitin"))
                            med_search = m_sqldb.searchAuth("desitin");
                        sAuth();
                        cardl.show(p_results, final_author);
                    }
                }
            } else {
                selectShoppingCartButton.setSelected(false);
                settingsPage.display();
            }
        }
    });
    selectComparisonCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectComparisonCartButton);
            // Set state 'comparison'
            if (!m_curr_uistate.getUseMode().equals("comparison")) {
                m_curr_uistate.setUseMode("comparison");
                // Hide middle pane
                m_section_titles.setVisible(false);
                split_pane_right.setDividerLocation(0);
                split_pane_right.setDividerSize(0);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // Set right panel title
                        m_web_panel.setTitle(getTitle("priceComp"));
                        if (med_index >= 0) {
                            if (med_id != null && med_index < med_id.size()) {
                                Medication m = m_sqldb.getMediWithId(med_id.get(med_index));
                                String atc_code = m.getAtcCode();
                                if (atc_code != null) {
                                    String atc = atc_code.split(";")[0];
                                    m_web_panel.fillComparisonBasket(atc);
                                    m_web_panel.updateComparisonCartHtml();
                                    // Update pane on the left
                                    retrieveAipsSearchResults(false);
                                }
                            }
                        }

                        m_status_label.setText(rose_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });

    // ------ Add keylistener to text field (type as you go feature) ------
    searchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e)
            // invokeLater potentially in the wrong place... more testing
            // required
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (m_curr_uistate.isLoadCart())
                        m_curr_uistate.restoreUseMode();
                    m_start_time = System.currentTimeMillis();
                    m_query_str = searchField.getText();
                    // Queries for SQLite DB
                    if (!m_query_str.isEmpty()) {
                        if (m_query_type == 0) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTitle(m_query_str);
                            } else {
                                med_search = m_sqldb.searchTitle(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTitle();
                            cardl.show(p_results, final_title);
                        } else if (m_query_type == 1) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchSupplier(m_query_str);
                            } else {
                                med_search = m_sqldb.searchAuth(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sAuth();
                            cardl.show(p_results, final_author);
                        } else if (m_query_type == 2) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchATC(m_query_str);
                            } else {
                                med_search = m_sqldb.searchATC(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sATC();
                            cardl.show(p_results, final_atccode);
                        } else if (m_query_type == 3) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchEan(m_query_str);
                            } else {
                                med_search = m_sqldb.searchRegNr(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sRegNr();
                            cardl.show(p_results, final_regnr);
                        } else if (m_query_type == 4) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTherapy(m_query_str);
                            } else {
                                med_search = m_sqldb.searchApplication(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTherapy();
                            cardl.show(p_results, final_therapy);
                        } else {
                            // do nothing
                        }
                        int num_hits = 0;
                        if (m_curr_uistate.isComparisonMode())
                            num_hits = rose_search.size();
                        else
                            num_hits = med_search.size();
                        m_status_label.setText(num_hits + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");

                    }
                }
            });
        }
    });

    // Add actionlisteners
    but_title.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_title);
            m_curr_uistate.setQueryType(m_query_type = 0);
            sTitle();
            cardl.show(p_results, final_title);
        }
    });
    but_auth.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_author);
            m_curr_uistate.setQueryType(m_query_type = 1);
            sAuth();
            cardl.show(p_results, final_author);
        }
    });
    but_atccode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_atccode);
            m_curr_uistate.setQueryType(m_query_type = 2);
            sATC();
            cardl.show(p_results, final_atccode);
        }
    });
    but_regnr.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_regnr);
            m_curr_uistate.setQueryType(m_query_type = 3);
            sRegNr();
            cardl.show(p_results, final_regnr);
        }
    });
    but_therapy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_therapy);
            m_curr_uistate.setQueryType(m_query_type = 4);
            sTherapy();
            cardl.show(p_results, final_therapy);
        }
    });

    // Display window
    jframe.pack();
    // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // jframe.setAlwaysOnTop(true);
    jframe.setVisible(true);

    // Check if user has selected an alternative database
    /*
     * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution
     * where the database selected by the user is saved in a default folder
     * (see variable "m_application_data_folder")
     */
    /*
     * try { WindowSaver.loadSettings(jframe); String database_path =
     * WindowSaver.getDbPath(); if (database_path!=null)
     * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) {
     * e.printStackTrace(); }
     */
    // Load AIPS database
    selectAipsButton.setSelected(true);
    selectFavoritesButton.setSelected(false);
    m_curr_uistate.setUseMode("aips");
    med_search = m_sqldb.searchTitle("");
    sTitle(); // Used instead of sTitle (which is slow)
    cardl.show(p_results, final_title);

    // Add menu item listeners
    updatedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (m_mutex_update == false) {
                m_mutex_update = true;
                String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(),
                        Utilities.appCustomization(), m_application_data_folder, m_full_db_update);
                // ... and update time
                if (m_full_db_update == true) {
                    DateTime dT = new DateTime();
                    m_prefs.put("updateTime", dT.now().toString());
                }
                //
                if (!db_file.isEmpty()) {
                    // Save db path (can't hurt)
                    WindowSaver.setDbPath(db_file);
                }
            }
        }
    });

    choosedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(),
                    Utilities.appCustomization(), m_application_data_folder);
            // ... and update time
            DateTime dT = new DateTime();
            m_prefs.put("updateTime", dT.now().toString());
            //
            if (!db_file.isEmpty()) {
                // Save db path (can't hurt)
                WindowSaver.setDbPath(db_file);
            }
        }
    });

    /**
     * Observers
     */
    // Attach observer to 'm_update'
    m_maindb_update.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Reset flag
            m_full_db_update = true;
            m_mutex_update = false;
            // Refresh some stuff after update
            loadAuthors();
            m_emailer.loadMap();
            settingsPage.load_gln_codes();
            if (m_shopping_cart != null) {
                m_shopping_cart.load_conditions();
                m_shopping_cart.load_glns();
            }
            // Empty shopping basket
            if (m_curr_uistate.isShoppingMode()) {
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
            if (m_curr_uistate.isComparisonMode())
                m_web_panel.setTitle(getTitle("priceComp"));
        }
    });

    // Attach observer to 'm_emailer'
    m_emailer.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Empty shopping basket
            m_shopping_basket.clear();
            int index = m_shopping_cart.getCartIndex();
            if (index > 0)
                m_web_panel.saveShoppingCartWithIndex(index);
            m_web_panel.updateShoppingHtml();
        }
    });

    // Attach observer to "m_comparison_cart"
    m_comparison_cart.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            m_web_panel.setTitle(getTitle("priceComp"));
            m_comparison_cart.clearUploadList();
            m_web_panel.updateComparisonCartHtml();
            new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg);
        }
    });

    // If command line options are provided start app with a particular title or eancode
    if (commandLineOptionsProvided()) {
        if (!CML_OPT_TITLE.isEmpty())
            startAppWithTitle(but_title);
        else if (!CML_OPT_EANCODE.isEmpty())
            startAppWithEancode(but_regnr);
        else if (!CML_OPT_REGNR.isEmpty())
            startAppWithRegnr(but_regnr);
    }

    // Start timer
    Timer global_timer = new Timer();
    // Time checks all 2 minutes (120'000 milliseconds)
    global_timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            checkIfUpdateRequired(updatedb_item);
        }
    }, 2 * 60 * 1000, 2 * 60 * 1000);
}

From source file:de.huxhorn.lilith.swing.MainFrame.java

public MainFrame(ApplicationPreferences applicationPreferences, SplashScreen splashScreen, String appName,
        boolean enableBonjour) {
    super(appName);
    this.applicationPreferences = applicationPreferences;
    this.coloringWholeRow = this.applicationPreferences.isColoringWholeRow();
    this.splashScreen = splashScreen;
    setSplashStatusText("Creating main frame.");

    groovyFormatter = new GroovyEventWrapperHtmlFormatter(applicationPreferences);
    thymeleafFormatter = new ThymeleafEventWrapperHtmlFormatter(applicationPreferences);

    smallProgressIcon = new ImageIcon(MainFrame.class.getResource("/otherGraphics/Progress16.gif"));
    ImageIcon frameIcon = new ImageIcon(MainFrame.class.getResource("/otherGraphics/Lilith16.jpg"));
    setIconImage(frameIcon.getImage());
    //colorsReferenceQueue=new ReferenceQueue<Colors>();
    //colorsCache=new ConcurrentHashMap<EventIdentifier, SoftColorsReference>();
    application = new DefaultApplication();
    autostartProcesses = new ArrayList<AutostartRunnable>();

    addWindowListener(new MainWindowListener());
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // fixes ticket #79 
    Runtime runtime = Runtime.getRuntime();
    Thread shutdownHook = new Thread(new ShutdownRunnable());
    runtime.addShutdownHook(shutdownHook);

    senderService = new SenderService(this);
    this.enableBonjour = enableBonjour;
    /*//from   w  w w  .j a v  a  2s . com
    if(application.isMac())
    {
       setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    }
    else
    {
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
      */

    longTaskManager = new TaskManager<Long>();
    longTaskManager.setUsingEventQueue(true);
    longTaskManager.startUp();
    longTaskManager.addTaskListener(new MainTaskListener());

    startupApplicationPath = this.applicationPreferences.getStartupApplicationPath();

    loggingFileFactory = new LogFileFactoryImpl(new File(startupApplicationPath, LOGGING_FILE_SUBDIRECTORY));
    accessFileFactory = new LogFileFactoryImpl(new File(startupApplicationPath, ACCESS_FILE_SUBDIRECTORY));

    Map<String, String> loggingMetaData = new HashMap<String, String>();
    loggingMetaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_LOGGING);
    loggingMetaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF);
    loggingMetaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP);
    // TODO: configurable format and compressed

    loggingFileBufferFactory = new LoggingFileBufferFactory(loggingFileFactory, loggingMetaData);

    Map<String, String> accessMetaData = new HashMap<String, String>();
    accessMetaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_ACCESS);
    accessMetaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF);
    accessMetaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP);
    // TODO: configurable format and compressed

    accessFileBufferFactory = new AccessFileBufferFactory(accessFileFactory, accessMetaData);

    rrdFileFilter = new RrdFileFilter();

    loggingEventViewManager = new LoggingEventViewManager(this);
    accessEventViewManager = new AccessEventViewManager(this);
    this.applicationPreferences.addPropertyChangeListener(new PreferencesChangeListener());
    loggingSourceListener = new LoggingEventSourceListener();
    accessSourceListener = new AccessEventSourceListener();
    // this.cleanupWindowChangeListener = new CleanupWindowChangeListener();
    desktop = new JDesktopPane();
    statusBar = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    statusLabel = new JLabel();
    statusLabel.setText("Starting...");

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(0, 5, 0, 0);

    statusBar.add(statusLabel, gbc);

    taskStatusLabel = new JLabel();
    taskStatusLabel.setText("");
    taskStatusLabel.setForeground(Color.BLUE);
    taskStatusLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            showTaskManager();
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            taskStatusLabel.setForeground(Color.RED);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            taskStatusLabel.setForeground(Color.BLUE);
        }
    });
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(0, 5, 0, 0);
    statusBar.add(taskStatusLabel, gbc);

    MemoryStatus memoryStatus = new MemoryStatus();
    memoryStatus.setBackground(Color.WHITE);
    memoryStatus.setOpaque(true);
    memoryStatus.setUsingBinaryUnits(true);
    memoryStatus.setUsingTotal(false);
    memoryStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));

    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(0, 0, 0, 0);

    statusBar.add(memoryStatus, gbc);
    add(desktop, BorderLayout.CENTER);
    add(statusBar, BorderLayout.SOUTH);

    if (SystemUtils.IS_JAVA_1_6) {
        setSplashStatusText("Creating statistics dialog.");
        if (logger.isDebugEnabled())
            logger.debug("Before creation of statistics-dialog...");
        statisticsDialog = new StatisticsDialog(this);
        if (logger.isDebugEnabled())
            logger.debug("After creation of statistics-dialog...");
    }

    setSplashStatusText("Creating about dialog.");
    aboutDialog = new AboutDialog(this, "About " + appName + "...", appName);

    setSplashStatusText("Creating update dialog.");
    checkForUpdateDialog = new CheckForUpdateDialog(this);

    setSplashStatusText("Creating debug dialog.");
    debugDialog = new DebugDialog(this, this);

    setSplashStatusText("Creating preferences dialog.");
    if (logger.isDebugEnabled())
        logger.debug("Before creation of preferences-dialog...");
    preferencesDialog = new PreferencesDialog(this);
    if (logger.isDebugEnabled())
        logger.debug("After creation of preferences-dialog...");

    setSplashStatusText("Creating \"Open inactive\" dialog.");
    openInactiveLogsDialog = new OpenPreviousDialog(MainFrame.this);

    setSplashStatusText("Creating help frame.");
    helpFrame = new HelpFrame(this);
    helpFrame.setTitle("Help Topics");

    openFileChooser = new JFileChooser();
    openFileChooser.setFileFilter(new LilithFileFilter());
    openFileChooser.setFileHidingEnabled(false);
    openFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousOpenPath());

    importFileChooser = new JFileChooser();
    importFileChooser.setFileFilter(new XmlImportFileFilter());
    importFileChooser.setFileHidingEnabled(false);
    importFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousImportPath());

    exportFileChooser = new JFileChooser();
    exportFileChooser.setFileFilter(new LilithFileFilter());
    exportFileChooser.setFileHidingEnabled(false);
    exportFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousExportPath());

    setSplashStatusText("Creating task manager frame.");
    taskManagerFrame = new TaskManagerInternalFrame(this);
    taskManagerFrame.setTitle("Task Manager");
    taskManagerFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
    taskManagerFrame.setBounds(0, 0, 320, 240);

    desktop.add(taskManagerFrame);
    desktop.validate();

    // the following code must be executed after desktop has been initialized...
    try {
        // try to use the 1.6 transfer handler...
        new MainFrameTransferHandler16(this).attach();
    } catch (Throwable t) {
        // ... and use the basic 1.5 transfer handler if this fails.
        new MainFrameTransferHandler(this).attach();
    }

    setSplashStatusText("Creating Tip of the Day dialog.");
    tipOfTheDayDialog = new TipOfTheDayDialog(this);

    setSplashStatusText("Creating actions and menus.");
    viewActions = new ViewActions(this, null);
    viewActions.getPopupMenu(); // initialize popup once in main frame only.

    JMenuBar menuBar = viewActions.getMenuBar();
    toolbar = viewActions.getToolbar();
    add(toolbar, BorderLayout.NORTH);
    setJMenuBar(menuBar);

    setShowingToolbar(applicationPreferences.isShowingToolbar());
    setShowingStatusbar(applicationPreferences.isShowingStatusbar());
}

From source file:net.sf.dvstar.transmission.TransmissionView.java

private void setAdditionalButtons() {
    ResizableIcon ri = new ArrowResizableIcon(9, SwingConstants.SOUTH);
    JCommandButton dropDownButton = new JCommandButton("Text Button", ri);

    ImageIcon imco = globalResourceMap.getImageIcon("btExit.icon");
    Dimension idim = new Dimension(imco.getIconWidth(), imco.getIconHeight());
    idim = new Dimension(40, 40);
    Image im = imco.getImage();

    ImageWrapperResizableIcon iwri = ImageWrapperResizableIcon.getIcon(im, idim);

    JCommandButton taskbarButtonPaste = new JCommandButton("", iwri);

    taskbarButtonPaste.setHorizontalAlignment(SwingConstants.LEFT);
    taskbarButtonPaste.setCommandButtonKind(CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP);
    //taskbarButtonPaste.setPopupOrientationKind(CommandButtonPopupOrientationKind.DOWNWARD);
    taskbarButtonPaste.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    taskbarButtonPaste.setDisplayState(TILE_36); // !!!!
    //taskbarButtonPaste.setPreferredSize(new Dimension(80, 48));
    System.out.println("Pref " + taskbarButtonPaste.getPreferredSize());
    System.out.println("Maxi " + taskbarButtonPaste.getMaximumSize());
    System.out.println("Mini " + taskbarButtonPaste.getMinimumSize());
    System.out.println("Size " + taskbarButtonPaste.getSize());
    Dimension d = new Dimension(taskbarButtonPaste.getPreferredSize().width, 48);
    taskbarButtonPaste.setMaximumSize(d);

    taskbarButtonPaste.addActionListener(new ActionListener() {

        @Override//w ww .  j  av  a 2s . co  m
        public void actionPerformed(ActionEvent e) {
            System.out.println("Taskbar Paste activated");
        }
    });
    taskbarButtonPaste.setPopupCallback(new PopupPanelCallback() {

        @Override
        public JPopupPanel getPopupPanel(JCommandButton commandButton) {
            return new SamplePopupMenu();
        }
    });

    taskbarButtonPaste.setActionRichTooltip(new RichTooltip("Paste", "Paste the contents of the Clipboard"));
    taskbarButtonPaste.setPopupRichTooltip(new RichTooltip("Paste",
            "Click here for more options such as pasting only the values or formatting"));
    taskbarButtonPaste.setActionKeyTip("1");

    //maiToolBar.add( rb );

    /*
    JRibbonBand rb = new JRibbonBand("", new EmptyResizableIcon(1));
    rb.addCommandButton(dropDownButton, RibbonElementPriority.MEDIUM);
     *
    JButton dropDownButton = DropDownButtonFactory.createDropDownButton(
    resourceMap.getIcon("btConnect.icon"),
    popup);
     */
    //dropDownButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(2,2,2,2));
    //dropDownButton.setBorderPainted( false );

    //btConnect = taskbarButtonPaste;
    maiToolBar.add(taskbarButtonPaste);

}

From source file:course_generator.frmMain.java

private void btTestActionPerformed(java.awt.event.ActionEvent evt) {
    // Bouge la carte de 100 pixel
    // MapViewer.moveMap(100, 100);

    // Essai lecture ressource image
    ImageIcon icon = createImageIcon("images/save.png", "a pretty but meaningless splat");
    // jLabelFooterTotalTime1.setIcon(icon);
    // jLabelFooterTotalTime1.setText("");
    // Fin essai lecture ressource image

    // Met un marqueur au coordonne indiqu
    Coordinate paris = new Coordinate(48.8567, 2.3508);
    MapViewer.addMapMarker(new MapMarkerImg(paris, icon.getImage()));

    // Coordinate one = new Coordinate(48.8567, 2.3508);
    // Coordinate two = new Coordinate(48.8567, 2.4508);
    // Coordinate three = new Coordinate(48.9567, 2.4508);
    // List<Coordinate> route = new ArrayList<Coordinate>(Arrays.asList(one,
    // two, two));
    List<Coordinate> route = new ArrayList<Coordinate>();
    route.add(new Coordinate(48.8567, 2.3508));
    route.add(new Coordinate(48.8567, 2.4508));
    route.add(new Coordinate(48.9567, 2.4508));
    route.add(new Coordinate(48.9668, 2.4518));
    MapPolyLine polyLine = new MapPolyLine(route);
    polyLine.setColor(Color.red);
    MapViewer.addMapPolygon(polyLine);//from w ww.  j  a  v a 2s  .co m

    List<Coordinate> route1 = new ArrayList<Coordinate>();
    route1.add(new Coordinate(48.9668, 2.4518));
    route1.add(new Coordinate(48.9669, 2.4510));
    route1.add(new Coordinate(48.9670, 2.4508));
    route1.add(new Coordinate(48.9668, 2.4518));
    MapPolyLine polyLine1 = new MapPolyLine(route1);
    polyLine1.setColor(Color.green);
    MapViewer.addMapPolygon(polyLine1);

    // MapPolygonImpl polyLine = new MapPolygonImpl(route);

    // MapViewer.setTileSource(new Thunderforest_Landscape());

    //MapViewer.setTileSource(new Thunderforest_Outdoors());
    MapViewer.setTileSource(new OpenTopoMap());

    // MapViewer.setTileSource(new Thunderforest_Transport());

    // MapViewer.setTileSource(new OsmTileSource.Mapnik());
    // MapViewer.setTileSource(new OsmTileSource.CycleMap());
    // MapViewer.setTileSource(new BingAerialTileSource());
    // MapViewer.setTileSource(new MapQuestOsmTileSource());
    // MapViewer.setTileSource(new MapQuestOpenAerialTileSource());

}

From source file:homenetapp.HomeNetAppGui.java

/** Creates new form HomeNetAppGui */
public HomeNetAppGui() {
    this.setLocationRelativeTo(null);

    //        try {
    //          javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
    //        } catch (Exception e) {e.printStackTrace();}

    homenetapp = new HomeNetApp();

    initComponents();/*from  w w w . jav a  2  s .  com*/

    ImageIcon ImageIcon = new ImageIcon(getClass().getResource("/HomeNetIcon.gif"));
    java.awt.Image Image = ImageIcon.getImage();
    this.setIconImage(Image);
    SendPacketFrame.setIconImage(Image);

    //redirectSystemStreams();//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    System.err.println("test");
    SettingsDialog.setLocationRelativeTo(null);

    //if not configured
    //if(true){
    if (homenetapp.configDone == false) {
        System.out.println("HomeNet App Not Setup");
        System.out.println("Launching Setup Wizard");
        javax.swing.JPanel wizardPanel = new SetupWizardGui(this);
        cardPanel.add(wizardPanel, "wizard");
        //validate();

        pack();
        wizardPanel.setVisible(true);

        ((java.awt.CardLayout) cardPanel.getLayout()).next(cardPanel);
        // ((java.awt.CardLayout) cardPanel.getLayout()).show(cardPanel,"wizard");

    } else {
        startMainGui();
    }

    //redirect console to gui

}