Example usage for javax.swing BorderFactory createLineBorder

List of usage examples for javax.swing BorderFactory createLineBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createLineBorder.

Prototype

public static Border createLineBorder(Color color) 

Source Link

Document

Creates a line border with the specified color.

Usage

From source file:org.geopublishing.atlasViewer.swing.AtlasViewerGUI.java

/**
 * Called via SingleInstanceListener / SingleInstanceService. Shows a
 * splashscreen and bring the existing instance to the front.
 *//*from ww w .  j ava  2  s. c om*/
@Override
public void newActivation(String[] arg0) {
    LOGGER.info(
            "A second instance of AtlasViewer has been started.. The single instance if requesting focus now...");

    /*
     * Showing the Spalshscreen for one secong
     */
    try {
        final URL splashscreenUrl = atlasConfig.getResource(AtlasConfig.SPLASHSCREEN_RESOURCE_NAME);
        if (splashscreenUrl != null) {
            JWindow splashWindow = new JWindow(atlasJFrame);
            JPanel panel = new JPanel(new BorderLayout());
            ImageIcon icon = new ImageIcon(splashscreenUrl);
            panel.add(new JLabel(icon), BorderLayout.CENTER);
            panel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            splashWindow.getContentPane().add(panel);
            splashWindow.getRootPane().setOpaque(true);
            splashWindow.pack();
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            splashWindow.setLocation((int) (d.getWidth() - splashWindow.getWidth()) / 2,
                    (int) (d.getHeight() - splashWindow.getHeight()) / 2);
            splashWindow.setVisible(true);
            Thread.sleep(1500);
            splashWindow.dispose();
            splashWindow = null;
        }
    } catch (Exception e) {
        LOGGER.warn("Singleinstance.newActivation had problems while showing the splashscreen:", e);
    }

    if (getJFrame() != null) {
        if (!getJFrame().isShowing())
            getJFrame().setVisible(true);

        /* In case that it has been iconified */
        getJFrame().setExtendedState(Frame.NORMAL);

        getJFrame().requestFocus();
        getJFrame().toFront();
    }
}

From source file:SuitaDetails.java

public ParamPanel() {
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153)),
            "Parameters", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null,
            new Color(0, 0, 0)));
    setBackground(Color.WHITE);//w  w w  .jav a  2 s .c o m
    jPanel2 = new JPanel();
    jPanel2.setBackground(Color.WHITE);
    JScrollPane jScrollPane3 = new JScrollPane(jPanel2);
    jScrollPane3.setBackground(Color.WHITE);
    jScrollPane3.setBorder(null);
    jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS));

    addpanel = new JPanel();
    addpanel.setMaximumSize(new Dimension(32767, 25));
    addpanel.setMinimumSize(new Dimension(0, 25));
    addpanel.setPreferredSize(new Dimension(50, 25));
    addpanel.setLayout(new BorderLayout());
    JButton add = new JButton("Add");
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            ArrayList<Integer> indexpos3 = (ArrayList<Integer>) parent.getPos().clone();
            indexpos3.add(new Integer(parent.getSubItemsNr()));
            Item property = new Item("param", 0, -1, -1, 10, 20, indexpos3);
            property.setSubItemVisible(false);
            property.setValue("");
            parent.addSubItem(property);
            Param prop = new Param(parent, property);
            jPanel2.remove(addpanel);
            jPanel2.add(prop);
            jPanel2.add(addpanel);
            jPanel2.revalidate();
            jPanel2.repaint();
        }
    });
    addpanel.add(add, BorderLayout.EAST);
    addpanel.setBackground(Color.WHITE);
    GroupLayout paramLayout = new GroupLayout(this);
    this.setLayout(paramLayout);
    paramLayout.setHorizontalGroup(
            paramLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane3));
    paramLayout.setVerticalGroup(
            paramLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane3));
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.util.FileImportComponent.java

/** 
 * Lays out the entries./*from w ww.  j  a va  2 s .  c  o  m*/
 * 
 * @param failure Pass <code>true</code> to display the failed import only,
 * <code>false</code> to display all the entries.
 */
public void layoutEntries(boolean failure) {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    if (!hasComponents())
        return;
    Entry<File, FileImportComponent> e;
    Iterator<Entry<File, FileImportComponent>> i = components.entrySet().iterator();
    int index = 0;
    FileImportComponent fc;
    if (failure) {
        while (i.hasNext()) {
            e = i.next();
            fc = e.getValue();
            if (fc.hasImportFailed()) {
                if (index % 2 == 0)
                    fc.setBackground(UIUtilities.BACKGROUND_COLOUR_EVEN);
                else
                    fc.setBackground(UIUtilities.BACKGROUND_COLOUR_ODD);
                p.add(fc);
                index++;
            }
        }
    } else {
        while (i.hasNext()) {
            e = i.next();
            fc = e.getValue();
            if (index % 2 == 0)
                fc.setBackground(UIUtilities.BACKGROUND_COLOUR_EVEN);
            else
                fc.setBackground(UIUtilities.BACKGROUND_COLOUR_ODD);
            p.add(fc);
            index++;
        }
    }

    pane.removeAll();
    pane.add(p);
    pane.revalidate();
    pane.repaint();
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Sets the Border style and color to black for the interface
 * // w  ww .j a  va2  s .co  m
 * @return Border A line border of black lines
 */
private Border getStandardBorder() {
    return BorderFactory.createLineBorder(Color.black);
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JPanel buildCabecera(final String label_cabecera, final int textfieldSize, final Icon icono,
        final String titulo, final String icono_seleccionado) {
    JLabel title = new JLabel(titulo, icono, SwingConstants.LEFT);
    title.setFont(LogicConstants.deriveBoldFont(12f));
    JPanel resultado = new JPanel(new BorderLayout(2, 2));
    resultado.setOpaque(false);/*ww  w.  j a  v  a2  s.c  om*/
    resultado.add(title, BorderLayout.NORTH);
    JPanel cabecera = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    cabecera.setOpaque(false);

    JLabel nombre = new JLabel(label_cabecera, JLabel.RIGHT);
    gbc.gridx = 0;
    gbc.gridy = 0;
    cabecera.add(nombre, gbc);
    textfieldCabecera.setColumns(textfieldSize);
    textfieldCabecera.getDocument().addDocumentListener(changeListener);
    nombre.setLabelFor(textfieldCabecera);
    gbc.gridx++;
    cabecera.add(textfieldCabecera, gbc);

    if (icono_seleccionado != null) {
        JLabel nombre2 = new JLabel("Icono:", JLabel.RIGHT);
        gbc.gridx = 0;
        gbc.gridy++;
        cabecera.add(nombre2, gbc);
        ((DefaultComboBoxModel) iconos.getModel()).removeAllElements();
        for (String icon : FlotaConsultas.getAllIcons("/images/" + LogicConstants.DIRECTORIO_ICONOS_FLOTAS)) {
            ((DefaultComboBoxModel) iconos.getModel()).addElement(icon);
        }
        for (ActionListener l : iconos.getActionListeners()) {
            iconos.removeActionListener(l);
        }
        iconos.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cambios = true;
                if (iconos.getSelectedItem() != null) {
                    i.setIcon(LogicConstants.getIcon(LogicConstants.DIRECTORIO_ICONOS_FLOTAS
                            + iconos.getSelectedItem().toString() + "_flota_preview"));
                }
                i.updateUI();
            }
        });
        iconos.setSelectedItem(icono_seleccionado);
        if (iconos.getSelectedIndex() == -1 || i.getIcon() == null) {
            if (iconos.getModel().getSize() > 0)
                iconos.setSelectedIndex(0);
        }
        cambios = false;
        nombre2.setLabelFor(iconos);
        gbc.gridx++;
        gbc.anchor = GridBagConstraints.WEST;
        cabecera.add(iconos, gbc);

        gbc.gridheight = 2;
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.insets = new Insets(2, 10, 2, 10);
        gbc.ipadx = 5;
        gbc.ipady = 5;
        i.setBorder(BorderFactory.createLineBorder(Color.black));
        cabecera.add(i, gbc);
    }

    resultado.add(cabecera, BorderLayout.CENTER);
    resultado.setBorder(new EmptyBorder(15, 15, 15, 15));
    return resultado;
}

From source file:SuitaDetails.java

public PropPanel() {
    jPanel1 = new JPanel();
    addpanel = new JPanel();
    addpanel.setMaximumSize(new Dimension(32767, 25));
    addpanel.setMinimumSize(new Dimension(0, 25));
    addpanel.setPreferredSize(new Dimension(50, 25));
    addpanel.setLayout(new BorderLayout());
    JButton add = new JButton("Add");
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            ArrayList<Integer> indexpos3 = (ArrayList<Integer>) parent.getPos().clone();
            indexpos3.add(new Integer(parent.getSubItemsNr()));
            Item property = new Item("", 0, -1, -1, 10, 20, indexpos3);
            property.setSubItemVisible(false);
            property.setValue("");
            parent.addSubItem(property);
            Prop prop = new Prop(parent, property);
            jPanel1.remove(addpanel);/*from  w  ww  . ja  va2 s . c  o m*/
            jPanel1.add(prop);
            jPanel1.add(addpanel);
            jPanel1.revalidate();
            jPanel1.repaint();
        }
    });
    addpanel.add(add, BorderLayout.EAST);
    addpanel.setBackground(Color.WHITE);
    JScrollPane jScrollPane1 = new JScrollPane(jPanel1);
    jPanel1.setBackground(Color.WHITE);
    jScrollPane1.setBackground(Color.WHITE);
    jScrollPane1.setBorder(null);
    jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153)),
            "Properties", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null,
            new Color(0, 0, 0)));
    setBackground(Color.WHITE);
    GroupLayout propLayout = new GroupLayout(this);
    setLayout(propLayout);
    propLayout.setHorizontalGroup(
            propLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1));
    propLayout.setVerticalGroup(
            propLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1));
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

private void quit(boolean log, boolean export) {
    mTimer.stop(); // disable the update timer to avoid new update events
    if (log && downloadingThread != null && downloadingThread.isAlive()) {
        final JDialog info = new JDialog(UiUtilities.getLastModalChildOf(this));
        info.setModal(true);// w w  w . j ava 2 s . co  m
        info.setUndecorated(true);
        info.toFront();

        JPanel main = new JPanel(new FormLayout("5dlu,pref,5dlu", "5dlu,pref,5dlu"));
        main.setBorder(BorderFactory.createLineBorder(Color.black));
        main.add(
                new JLabel(mLocalizer.msg("downloadinfo",
                        "A data update is running. TV-Browser will be closed when the update is done.")),
                new CellConstraints().xy(2, 2));

        info.setContentPane(main);
        info.pack();
        info.setLocationRelativeTo(this);

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                if (downloadingThread != null && downloadingThread.isAlive()) {
                    try {
                        downloadingThread.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                info.setVisible(false);
                info.dispose();
            }
        });

        info.setVisible(true);
    }
    if (log && this.isUndecorated()) {
        switchFullscreenMode();
    }
    if (mShuttingDown) {
        return;
    }
    mShuttingDown = true;

    if (log) {
        FavoritesPlugin.getInstance().handleTvBrowserIsShuttingDown();
    }

    if (log) {
        mLog.info("Finishing plugins");
    }
    PluginProxyManager.getInstance().shutdownAllPlugins(log);

    if (log) {
        mLog.info("Storing dataservice settings");
    }
    TvDataServiceProxyManager.getInstance().shutDown();

    FavoritesPlugin.getInstance().store();
    ReminderPlugin.getInstance().store();

    TVBrowser.shutdown(log);

    if (log) {
        mLog.info("Closing TV data base");
    }

    try {
        TvDataBase.getInstance().close();
    } catch (Exception exc) {
        if (log) {
            mLog.log(Level.WARNING, "Closing database failed", exc);
        }
    }

    if (export) {
        Settings.propTVDataDirectory.resetToDefault();
        Settings.copyToSystem();
    }

    if (log) {
        mLog.info("Quitting");
        System.exit(0);
    }
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected void showNotificationPopup(String popupText, NotificationType type) {
    JPanel panel = new JPanel(new MigLayout("flowy"));
    panel.setBorder(BorderFactory.createLineBorder(Color.gray));

    switch (type) {
    case WARNING:
    case WARNING_HTML:
        panel.setBackground(Color.yellow);
        break;/*from w  w w  . j a v a 2s  .  c om*/
    case ERROR:
    case ERROR_HTML:
        panel.setBackground(Color.orange);
        break;
    default:
        panel.setBackground(Color.cyan);
    }

    JLabel label = new JLabel(popupText);
    panel.add(label);

    Dimension labelSize = DesktopComponentsHelper.measureHtmlText(popupText);

    int x = frame.getX() + frame.getWidth() - (50 + labelSize.getSize().width);
    int y = frame.getY() + frame.getHeight() - (50 + labelSize.getSize().height);

    PopupFactory factory = PopupFactory.getSharedInstance();
    final Popup popup = factory.getPopup(frame, panel, x, y);
    popup.show();

    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            popup.hide();
        }
    });

    PointerInfo pointerInfo = MouseInfo.getPointerInfo();
    if (pointerInfo != null) {
        final Point location = pointerInfo.getLocation();
        final Timer timer = new Timer(3000, null);
        timer.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                PointerInfo currentPointer = MouseInfo.getPointerInfo();
                if (currentPointer == null) {
                    timer.stop();
                } else if (!currentPointer.getLocation().equals(location)) {
                    popup.hide();
                    timer.stop();
                }
            }
        });
        timer.start();
    }
}

From source file:base.BasePlayer.Main.java

public Main() {

    super(new GridBagLayout());
    try {//  w  w  w.j a va 2 s  .com

        //UIManager.put("PopupMenu.border", BorderFactory.createMatteBorder(0, 20, 0, 0, new Color(230,230,230)));
        //URL fontUrl = new URL("http://www.webpagepublicity.com/" +
        //       "free-fonts/a/Airacobra%20Condensed.ttf");
        //      URL fontUrl = new URL("C:/HY-Data/RKATAINE/WinPython-64bit-3.5.3.1Qt5/python-3.5.3.amd64/share/numdifftools/docs/_build/html/_static/fonts/Inconsolata-Regular.ttf");
        //   URL fonturl = this.getClass().getResource("OpenSans-Regular.ttf");
        //   menuFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonturl.getFile()));
        //   C:\HY-Data\RKATAINE\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\Lib\site-packages\reportlab\fonts
        Launcher.fromMain = true;
        Launcher.main(args);
        VariantHandler.main(argsit);
        glass = Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/glass.jpg"));
        ToolTipManager.sharedInstance().setInitialDelay(100);
        // ToolTipManager.sharedInstance().setDismissDelay(2000);
        UIManager.put("ToolTip.background", new Color(255, 255, 214));
        UIManager.put("ToolTip.border", BorderFactory.createCompoundBorder(
                UIManager.getBorder("ToolTip.border"), BorderFactory.createEmptyBorder(4, 4, 4, 4)));
        lineseparator = System.getProperty("line.separator");

        proxysettings = new ProxySettings();
        panel = new JPanel(new GridBagLayout());
        //menuFont = menuFont.deriveFont(Font.PLAIN,12);
        Draw.defaultFont = menuFont;

        gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        width = gd.getDisplayMode().getWidth();
        height = gd.getDisplayMode().getHeight();
        if (Launcher.fontSize.equals("")) {
            if (width < 1500) {
                defaultFontSize = 11;

                buttonHeight = Main.defaultFontSize * 2;
                buttonWidth = Main.defaultFontSize * 6;

            } else if (width < 2000) {
                defaultFontSize = 12;

                buttonHeight = Main.defaultFontSize * 2 + 4;
                buttonWidth = Main.defaultFontSize * 6 + 4;

            } else if (width < 3000) {
                defaultFontSize = 15;
                buttonHeight = Main.defaultFontSize * 2 + 4;
                buttonWidth = Main.defaultFontSize * 6 + 4;
            } else {
                defaultFontSize = 19;
                buttonHeight = Main.defaultFontSize * 2 + 4;
                buttonWidth = Main.defaultFontSize * 6 + 4;
            }
        } else {
            try {
                defaultFontSize = Integer.parseInt(Launcher.fontSize);
            } catch (Exception e) {
                defaultFontSize = 12;
            }
        }

        menuFont = new Font("SansSerif", Font.PLAIN, Main.defaultFontSize);
        menuFontBold = new Font("SansSerif", Font.BOLD, Main.defaultFontSize);
        //   menuFont = new Font("SansSerif", Font.BOLD, Main.defaultFontSize);
    } catch (Exception e) {
        e.printStackTrace();
    }
    FileSystemView fsv = FileSystemView.getFileSystemView();
    File[] paths = File.listRoots();

    for (File path : paths) {
        if (fsv.getSystemDisplayName(path).contains("merit")) {
            pleiades = true;
        }
    }

    screenSize = new Dimension(width, height);

    drawHeight = (int) (screenSize.getHeight() * 0.6);
    sidebarWidth = (int) (screenSize.getWidth() * 0.1);
    drawWidth = (int) (screenSize.getWidth() - sidebarWidth);
    thisMainListener = this;
    try {
        htsjdk.samtools.util.Log.setGlobalLogLevel(htsjdk.samtools.util.Log.LogLevel.ERROR);
        /*   for(int i=0;i<snow.length; i++) {
              snow[i][0] = (height*Math.random());
              snow[i][1] = (4*Math.random() +1);
              snow[i][2] = (12*Math.random() -6);
              snow[i][3] = (2*Math.random() +1);
           }*/
        frame.addWindowListener(new java.awt.event.WindowAdapter() {
            @Override
            public void windowClosing(java.awt.event.WindowEvent windowEvent) {
                /*if (JOptionPane.showConfirmDialog(frame, "Are you sure to close this window?", "Really Closing?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){
                    System.exit(0);
                }*/
                if (configChanged) {

                    try {
                        BufferedWriter fileWriter = new BufferedWriter(new FileWriter(Launcher.configfile));
                        for (int i = 0; i < Launcher.config.size(); i++) {
                            fileWriter.write(Launcher.config.get(i) + lineseparator);
                        }
                        fileWriter.close();

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

            }
        });
        baseMap.put((byte) 'A', 1);
        baseMap.put((byte) 'C', 2);
        baseMap.put((byte) 'G', 3);
        baseMap.put((byte) 'T', 4);
        baseMap.put((byte) 'N', 5);
        baseMap.put((byte) 'I', 6);
        baseMap.put((byte) 'D', 7);
        mutTypes.put("TA", 0);
        mutTypes.put("AT", 0);
        mutTypes.put("TC", 1);
        mutTypes.put("AG", 1);
        mutTypes.put("TG", 2);
        mutTypes.put("AC", 2);
        mutTypes.put("CA", 3);
        mutTypes.put("GT", 3);
        mutTypes.put("CG", 4);
        mutTypes.put("GC", 4);
        mutTypes.put("CT", 5);
        mutTypes.put("GA", 5);

        getBase.put((byte) 'A', "A");
        getBase.put((byte) 'C', "C");
        getBase.put((byte) 'G', "G");
        getBase.put((byte) 'T', "T");
        getBase.put((byte) 'N', "N");
        getBase.put((byte) 'a', "A");
        getBase.put((byte) 'c', "C");
        getBase.put((byte) 'g', "G");
        getBase.put((byte) 't', "T");
        getBase.put((byte) 'n', "N");
        java.net.URL imgUrl = getClass().getResource("icons/save.gif");
        save = new ImageIcon(imgUrl);
        imgUrl = getClass().getResource("icons/open.gif");
        open = new ImageIcon(imgUrl);
        imgUrl = getClass().getResource("icons/settings.png");
        settingsIcon = new ImageIcon(imgUrl);
        userDir = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent()
                .replace("%20", " ");
        settings = new JMenuItem("Settings", settingsIcon);

        //   Average.frame.setVisible(false);

        try {

            savedir = Launcher.defaultSaveDir;
            path = Launcher.defaultDir;
            gerp = Launcher.gerpfile;
            defaultGenome = Launcher.defaultGenome;
            defaultAnnotation = Launcher.defaultAnnotation;
            isProxy = Launcher.isProxy;
            proxyHost = Launcher.proxyHost;
            proxyPort = Launcher.proxyPort;
            proxyType = Launcher.proxyType;
            if (isProxy) {
                ProxySettings.useProxy.setSelected(true);
            }
            if (!proxyHost.equals("")) {
                ProxySettings.hostField.setText(proxyHost);
            }
            if (!proxyPort.equals("")) {
                ProxySettings.portField.setText(proxyPort);
            }
            if (!Launcher.proxyType.equals("")) {
                ProxySettings.proxytypes.setSelectedItem(proxyType);
            }
            if (Launcher.backColor.equals("")) {
                Draw.backColor = new Color(90, 90, 90);
            }

            else {

                Draw.backColor = new Color(Integer.parseInt(Launcher.backColor),
                        Integer.parseInt(Launcher.backColor), Integer.parseInt(Launcher.backColor));
                Settings.graySlider.setValue(Integer.parseInt(Launcher.backColor));
            }

            if (Launcher.genomeDir.equals("")) {

                genomeDir = new File(userDir + "/genomes/");
            } else {
                if (new File(Launcher.genomeDir).exists()) {

                    genomeDir = new File(Launcher.genomeDir);
                } else {
                    genomeDir = new File(userDir + "/genomes/");
                }
            }

            annotationfile = defaultAnnotation;
            controlDir = Launcher.ctrldir;
            trackDir = Launcher.trackDir;
            projectDir = Launcher.projectDir;
            downloadDir = Launcher.downloadDir;
        } catch (Exception e) {
            e.printStackTrace();
        }
        File[] genomes = genomeDir.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return !name.contains(".txt") && !name.startsWith(".");
            }
        });
        chromHeight = (int) (drawHeight * 0.1);
        drawDimensions = new Dimension(drawWidth, drawHeight - chromHeight);
        bedDimensions = new Dimension(drawWidth, bedHeight);
        chromDimensions = new Dimension(drawWidth - Main.sidebarWidth - 1, drawHeight);
        drawCanvas = new Draw((int) drawDimensions.getWidth(), (int) drawDimensions.getHeight());
        controlDraw = new ControlCanvas((int) bedDimensions.getWidth(), (int) bedDimensions.getHeight());
        iconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/icon.png"));
        frame.setIconImage(iconImage);
        /*   if(args.length > 0) {
               for(int i = 0; i<args.length; i++) {
                  if(args[i].startsWith("-opendir")) {
                     path = args[i].substring(9).replace(" ", "");
                  }
                  else if(args[i].startsWith("-ctrldir")) {
                     Control.path = args[i].substring(9).replace(" ", "");
                  }             
               }       
            }*/

        //   BGZIPInputStream in = this.getClass().getResourceAsStream("SELEX_1505_representative_matrices.bedhead.gz");
        searchField.getDocument().addDocumentListener(new DocumentListener() {
            private String searchstring;

            public void changedUpdate(DocumentEvent e) {
                if (searchField.getText().contains(";")) {
                    searchList = searchField.getText().split(";");
                    for (int i = 0; i < searchList.length; i++) {
                        warn(searchList[i].replace(" ", ""));
                    }
                } else {
                    warn(searchField.getText().replace(" ", ""));
                }

            }

            public void removeUpdate(DocumentEvent e) {
                if (searchField.getText().contains(";")) {
                    searchList = searchField.getText().split(";");
                    for (int i = 0; i < searchList.length; i++) {
                        warn(searchList[i].replace(" ", ""));
                    }
                } else {
                    warn(searchField.getText().replace(" ", ""));
                }
            }

            public void insertUpdate(DocumentEvent e) {
                if (searchField.getText().contains(";")) {
                    searchList = searchField.getText().split(";");
                    for (int i = 0; i < searchList.length; i++) {
                        warn(searchList[i].replace(" ", ""));
                    }
                } else {
                    warn(searchField.getText().replace(" ", ""));
                }
            }

            public void warn(String searchtext) {

                if (searchTable.containsKey(searchtext.toUpperCase())) {
                    if (searchTable.get(searchtext.toUpperCase())[0]
                            .equals(Main.chromosomeDropdown.getSelectedItem())) {
                        searchChrom = searchTable.get(searchtext.toUpperCase())[0];
                        searchStart = Integer.parseInt(searchTable.get(searchtext.toUpperCase())[1]);
                        searchEnd = Integer.parseInt(searchTable.get(searchtext.toUpperCase())[2]);
                    } else {
                        chromDraw.repaint();
                        searchStart = -1;
                        searchEnd = -1;
                    }
                    chromDraw.repaint();
                    searchField.setForeground(Color.black);
                } else if (searchField.getText().toUpperCase().matches("CHR.{1,2}(?!:)")) {

                    if (Main.chromnamevector.contains(searchtext.toUpperCase().substring(3))) {
                        searchField.setForeground(Color.black);

                    } else {
                        chromDraw.repaint();
                        searchField.setForeground(Color.red);
                    }
                } else if (searchtext.toUpperCase().replace(",", "").matches("(CHR)?(.+:)?\\d+(-\\d+)?")) {

                    searchField.setForeground(Color.black);
                    if (searchtext.contains(":")) {
                        searchstring = searchtext.substring(searchtext.indexOf(":") + 1).replace(",", "");
                    } else {
                        chromDraw.repaint();
                        searchstring = searchtext.replace(",", "");
                    }

                    if (!searchstring.contains("-")) {
                        try {
                            searchStart = Integer.parseInt(searchstring);
                        } catch (Exception ex) {

                        }
                        searchEnd = -1;
                    } else {
                        try {
                            searchStart = Integer
                                    .parseInt(searchstring.substring(0, searchstring.indexOf("-")));
                            searchEnd = Integer.parseInt(searchstring.substring(searchstring.indexOf("-") + 1));
                        } catch (Exception ex) {

                        }
                    }
                    chromDraw.repaint();

                } else {
                    chromDraw.repaint();
                    searchField.setForeground(Color.red);
                    searchStart = -1;
                    searchEnd = -1;
                }
            }
        });

        try {

            A = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/A.png"));
            C = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/C.png"));
            G = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/G.png"));
            T = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/T.png"));

        } catch (Exception e) {
            e.printStackTrace();
        }
        ErrorLog.main(args);

        this.setBackground(Color.black);
        UIManager.put("FileChooser.readOnly", Boolean.TRUE);

        panel.setBackground(Draw.sidecolor);
        panel.setBorder(BorderFactory.createLineBorder(Color.white));
        searchField.addKeyListener(this);

        frame.addKeyListener(this);
        frame.getContentPane().setBackground(Color.black);

        glassPane.addMouseListener(this);
        glassPane.addMouseMotionListener(new MouseMotionListener() {

            @Override
            public void mouseDragged(MouseEvent arg0) {

            }

            @Override
            public void mouseMoved(MouseEvent event) {

                // g.drawRect(drawScroll.getWidth()/2-Main.canceltextwidth/2-Main.defaultFontSize/2, Main.drawScroll.getViewport().getHeight()*2/3+Draw.loadingFont.getSize()*3-Main.defaultFontSize/4, Main.canceltextwidth+Main.defaultFontSize, Draw.loadingFont.getSize()+Main.defaultFontSize/2);                

                if (drawCanvas.loading
                        && event.getX() > drawScroll.getWidth() / 2 - Main.canceltextwidth / 2
                                - Main.defaultFontSize / 2
                        && event.getX() < drawScroll.getWidth() / 2 + Main.canceltextwidth / 2
                                + Main.defaultFontSize / 2
                        && event.getY() > frame.getHeight() * 1 / 3 + Draw.loadingFont.getSize() * 3
                                - Main.defaultFontSize / 4
                        && event.getY() < frame.getHeight() * 1 / 3 + Draw.loadingFont.getSize() * 4
                                + Main.defaultFontSize / 2) {
                    if (!Main.cancelhover) {
                        Main.cancelhover = true;
                        Main.glassPane.requestFocus();
                    }
                } else {
                    if (Main.cancelhover) {
                        Main.cancelhover = false;
                        Main.glassPane.requestFocus(false);
                    }
                }
            }
        });

        background.put((byte) 'A', 0.3);
        background.put((byte) 'C', 0.2);
        background.put((byte) 'G', 0.2);
        background.put((byte) 'T', 0.3);

        bases = new Hashtable<String, String>();
        bases.put("A", "A");
        bases.put("C", "C");
        bases.put("G", "G");
        bases.put("T", "T");
        bases.put("N", "N");
        bases.put("delA", "delA");
        bases.put("delC", "delC");
        bases.put("delG", "delG");
        bases.put("delT", "delT");
        bases.put("insA", "insA");
        bases.put("insC", "insC");
        bases.put("insG", "insG");
        bases.put("insT", "insT");

        chromDraw = new ChromDraw(drawWidth, chromHeight);

        VariantCaller.main(argsit);
        PeakCaller.main(argsit);
        tablebrowser = new TableBrowser();
        bedconverter = new BEDconvert();

        try {

            File annodir;

            File[] annotations;
            addGenome.addMouseListener(this);
            genome = new JMenu("Genomes");
            genome.setName("genomeMenu");
            genome.add(addGenome);
            genome.addComponentListener(this);
            File[] fastadir;
            String[] empty = {};

            refModel = new DefaultComboBoxModel<String>(empty);

            refDropdown = new SteppedComboBox(refModel);
            refDropdown.addMouseListener(this);
            String[] emptygenes = {};
            refDropdown.addActionListener(refDropActionListener);

            geneModel = new DefaultComboBoxModel<String>(emptygenes);
            geneDropdown = new SteppedComboBox(geneModel);
            geneDropdown.addMouseListener(this);
            if (genomes != null) {
                for (int i = 0; i < genomes.length; i++) {
                    if (!genomes[i].isDirectory()) {
                        continue;
                    }
                    annodir = new File(genomes[i].getAbsolutePath() + "/annotation/");
                    if (genomes[i].isDirectory()) {
                        fastadir = genomes[i].listFiles();
                        for (int f = 0; f < fastadir.length; f++) {
                            if (fastadir[f].isDirectory()) {
                                continue;
                            }
                            if (fastadir[f].getName().contains(".fai")) {
                                continue;
                            } else if (fastadir[f].getName().contains(".fa")) {
                                fastahash.put(genomes[i].getName(), fastadir[f]);
                            }
                        }
                    }

                    annotations = annodir.listFiles();
                    genomehash.put(genomes[i].getName(), new ArrayList<File>());

                    refModel.addElement(genomes[i].getName());
                    if (genomes[i].getName().length() > reflength) {
                        reflength = genomes[i].getName().length();
                    }
                    JMenu addMenu = new JMenu(genomes[i].getName());
                    addMenu.addMouseListener(this);
                    addMenu.setName(genomes[i].getName());
                    JMenuItem addAnnotation = new JMenuItem("Add new annotation file...");
                    addAnnotation.addMouseListener(this);
                    addAnnotation.setName("add_annotation");
                    addMenu.add(addAnnotation);
                    JLabel addLabel = new JLabel("  Select annotation: ");
                    labels.add(addLabel);
                    addMenu.add(addLabel);
                    addMenu.add(new JSeparator());

                    genome.add(addMenu);
                    addMenu.addComponentListener(this);
                    if (annotations != null) {
                        for (int j = 0; j < annotations.length; j++) {
                            annofiles = annotations[j].listFiles();
                            for (int f = 0; f < annofiles.length; f++) {
                                if (annofiles[f].getName().endsWith(".bed.gz")) {
                                    if (annofiles[f].getName()
                                            .substring(0, annofiles[f].getName().indexOf(".bed.gz"))
                                            .length() > annolength) {
                                        annolength = annofiles[f].getName().length();
                                    }

                                    genomehash.get(genomes[i].getName()).add(annofiles[f].getAbsoluteFile());
                                    JMenuItem additem = new JMenuItem(annofiles[f].getName().substring(0,
                                            annofiles[f].getName().indexOf(".bed.gz")));
                                    additem.setName(annofiles[f].getName().substring(0,
                                            annofiles[f].getName().indexOf(".bed.gz")));
                                    additem.addMouseListener(this);
                                    addMenu.add(additem);
                                    additem.addComponentListener(this);
                                    break;
                                }
                            }
                        }
                    }
                }
                refModel.addElement("Add new reference...");

            }

            if (genomes.length == 0) {
                /*if(Launcher.firstStart) {
                   Main.writeToConfig("FirstStart=false");
                }*/
                AddGenome.createAndShowGUI();
                AddGenome.frame.setTitle("Add new genome");

                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);

                AddGenome.frame.setLocation((int) (screenSize.getWidth() / 2 - AddGenome.frame.getWidth() / 2),
                        (int) (screenSize.getHeight() / 6));

                AddGenome.frame.setState(JFrame.NORMAL);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setAlwaysOnTop(true);
                /*
                WelcomeScreen.main(args);
                WelcomeScreen.frame.setVisible(true);
                WelcomeScreen.frame.setLocation(frame.getLocationOnScreen().x+frame.getWidth()/2 - WelcomeScreen.frame.getWidth()/2, frame.getLocationOnScreen().y+frame.getHeight()/6);
                */
                if (genomes.length != 0) {
                    if (!genomehash.containsKey(defaultGenome)) {

                        setChromDrop(genomes[0].getName());
                        defaultGenome = genomes[0].getName();
                    } else {

                        setChromDrop(defaultGenome);
                    }
                    getBands();
                    getExons();
                } else {
                    setChromDrop(null);
                }
            } else {
                if (!genomehash.containsKey(defaultGenome)) {

                    setChromDrop(genomes[0].getName());
                    defaultGenome = genomes[0].getName();

                } else {

                    setChromDrop(defaultGenome);
                }
                getBands();
                getExons();
            }

            if (Launcher.firstStart) {

                WelcomeScreen.createAndShowGUI();
                WelcomeScreen.frame.setLocation(
                        (int) (screenSize.getWidth() / 2 - WelcomeScreen.frame.getWidth() / 2),
                        (int) (screenSize.getHeight() / 6));
                WelcomeScreen.frame.setVisible(true);
            }
            setMenuBar();
            setButtons();
            Settings.main(args);

            // Settings.main(args);
            frame.requestFocus();

            drawCanvas.addKeyListener(this);
            bedCanvas.addKeyListener(this);
            setFonts();
            chromLabel.setText("Chromosome " + chromosomeDropdown.getSelectedItem().toString());
            CheckUpdates check = new CheckUpdates();
            check.execute();
            //   Main.drawCanvas.loading("test");
            Main.drawCanvas.splits.get(0)
                    .setCytoImage(Main.chromDraw.createBands(Main.drawCanvas.splits.get(0)));
        } catch (Exception e) {
            e.printStackTrace();
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        Main.showError(ex.getMessage(), "Error");

    }

}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

private void updateOverlayPanel() {
    if (indicatorsListPanel == null)
        return;/*from   ww w  .  jav a2 s . co  m*/

    indicatorsListPanel.removeAll();

    for (final var virtualAxis : Input.VirtualAxis.values()) {
        final var indicatorPanel = new JPanel(new GridBagLayout());
        indicatorsListPanel.add(indicatorPanel,
                new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
                        GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 0, 0), 0, 5));

        final var virtualAxisLabel = new JLabel(virtualAxis.toString() + rb.getString("AXIS_LABEL_SUFFIX"));
        virtualAxisLabel.setPreferredSize(new Dimension(100, 15));
        indicatorPanel.add(virtualAxisLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var virtualAxisToOverlayAxisMap = input.getProfile().getVirtualAxisToOverlayAxisMap();
        final var overlayAxis = virtualAxisToOverlayAxisMap.get(virtualAxis);
        final var enabled = overlayAxis != null;

        final var colorLabel = new JLabel();
        if (enabled) {
            colorLabel.setOpaque(true);
            colorLabel.setBackground(overlayAxis.color);
        } else
            colorLabel.setText(rb.getString("INDICATOR_DISABLED_LABEL"));
        colorLabel.setHorizontalAlignment(SwingConstants.CENTER);

        colorLabel.setPreferredSize(new Dimension(100, 15));
        colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        indicatorPanel.add(colorLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BASELINE,
                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var colorButton = new JButton(new SelectIndicatorColorAction(virtualAxis));
        colorButton.setPreferredSize(BUTTON_DIMENSION);
        colorButton.setEnabled(enabled);
        indicatorPanel.add(colorButton, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var invertedCheckBox = new JCheckBox(new InvertIndicatorAction(virtualAxis));
        invertedCheckBox.setSelected(enabled && overlayAxis.inverted);
        invertedCheckBox.setEnabled(enabled);
        indicatorPanel.add(invertedCheckBox, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

        final var displayCheckBox = new JCheckBox(new DisplayIndicatorAction(virtualAxis));
        displayCheckBox.setSelected(enabled);
        indicatorPanel.add(displayCheckBox, new GridBagConstraints(4, GridBagConstraints.RELATIVE, 1, 1, 0.0,
                0.0, GridBagConstraints.BASELINE, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }

    indicatorsListPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0,
            1.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    indicatorsScrollPane.setViewportView(indicatorsListPanel);
}