Example usage for java.awt GridBagConstraints REMAINDER

List of usage examples for java.awt GridBagConstraints REMAINDER

Introduction

In this page you can find the example usage for java.awt GridBagConstraints REMAINDER.

Prototype

int REMAINDER

To view the source code for java.awt GridBagConstraints REMAINDER.

Click Source Link

Document

Specifies that this component is the last component in its column or row.

Usage

From source file:net.sf.jabref.gui.JabRefFrame.java

private void initLayout() {
    tabbedPane.putClientProperty(Options.NO_CONTENT_BORDER_KEY, Boolean.TRUE);

    setProgressBarVisible(false);//w w w  .jav a 2s .  c  o m

    pushExternalButton = new PushToApplicationButton(this, PushToApplications.getApplications());
    fillMenu();
    createToolBar();
    getContentPane().setLayout(gbl);
    splitPane.setDividerSize(2);
    splitPane.setBorder(null);
    //getContentPane().setBackground(GUIGlobals.lightGray);
    con.fill = GridBagConstraints.HORIZONTAL;
    con.anchor = GridBagConstraints.WEST;
    con.weightx = 1;
    con.weighty = 0;
    con.gridwidth = GridBagConstraints.REMAINDER;

    //gbl.setConstraints(mb, con);
    //getContentPane().add(mb);
    setJMenuBar(mb);
    con.anchor = GridBagConstraints.NORTH;
    //con.gridwidth = 1;//GridBagConstraints.REMAINDER;;
    gbl.setConstraints(tlb, con);
    getContentPane().add(tlb);

    Component lim = Box.createGlue();
    gbl.setConstraints(lim, con);
    //getContentPane().add(lim);
    /*
      JPanel empt = new JPanel();
      empt.setBackground(GUIGlobals.lightGray);
      gbl.setConstraints(empt, con);
       getContentPane().add(empt);
            
      con.insets = new Insets(1,0,1,1);
      con.anchor = GridBagConstraints.EAST;
      con.weightx = 0;
      gbl.setConstraints(searchManager, con);
      getContentPane().add(searchManager);*/
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 1;
    con.weighty = 0;
    con.fill = GridBagConstraints.BOTH;
    con.anchor = GridBagConstraints.WEST;
    con.insets = new Insets(0, 0, 0, 0);
    lim = Box.createGlue();
    gbl.setConstraints(lim, con);
    getContentPane().add(lim);
    //tabbedPane.setVisible(false);
    //tabbedPane.setForeground(GUIGlobals.lightGray);
    con.weighty = 1;
    gbl.setConstraints(splitPane, con);
    getContentPane().add(splitPane);

    UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));

    splitPane.setRightComponent(tabbedPane);
    splitPane.setLeftComponent(sidePaneManager.getPanel());
    sidePaneManager.updateView();

    JPanel status = new JPanel();
    status.setLayout(gbl);
    con.weighty = 0;
    con.weightx = 0;
    con.gridwidth = 1;
    con.insets = new Insets(0, 2, 0, 0);
    gbl.setConstraints(statusLabel, con);
    status.add(statusLabel);
    con.weightx = 1;
    con.insets = new Insets(0, 4, 0, 0);
    con.gridwidth = 1;
    gbl.setConstraints(statusLine, con);
    status.add(statusLine);
    con.weightx = 0;
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.insets = new Insets(2, 4, 2, 2);
    gbl.setConstraints(progressBar, con);
    status.add(progressBar);
    con.weightx = 1;
    con.gridwidth = GridBagConstraints.REMAINDER;
    statusLabel.setForeground(GUIGlobals.ENTRY_EDITOR_LABEL_COLOR.darker());
    con.insets = new Insets(0, 0, 0, 0);
    gbl.setConstraints(status, con);
    getContentPane().add(status);

    // Drag and drop for tabbedPane:
    TransferHandler xfer = new EntryTableTransferHandler(null, this, null);
    tabbedPane.setTransferHandler(xfer);
    tlb.setTransferHandler(xfer);
    mb.setTransferHandler(xfer);
    sidePaneManager.getPanel().setTransferHandler(xfer);
}

From source file:pcgen.gui2.PCGenFrame.java

/**
 * Builds a JPanel containing the supplied message, split at each new
 * line and an optional checkbox, suitable for use in a showMessageDialog
 * call. This is generally useful for showing messges which can turned
 * off either in preferences or when they are displayed.
 *
 * @param message The message to be displayed.
 * @param checkbox The optional checkbox to be added - may be null.
 * @return JPanel A panel containing the message and the checkbox.
 *///  w w w . j  a  v a 2s . c o m
public static JPanel buildMessageLabelPanel(String message, JCheckBox checkbox) {
    JPanel panel = new JPanel();
    JLabel label;
    String part;

    panel.setLayout(new GridBagLayout());

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor = GridBagConstraints.WEST;
    cons.insets = new Insets(0, 0, 3, 0);
    cons.weightx = 1;
    cons.weighty = 0;
    cons.fill = GridBagConstraints.NONE;

    int start = 0;
    int sepPos = -1;

    do {
        sepPos = message.indexOf("\n", start); //$NON-NLS-1$

        if (sepPos >= 0) {
            part = message.substring(start, sepPos);
            start = sepPos + 1;
        } else {
            part = message.substring(start);
            start = -1;
        }

        label = new JLabel(part, SwingConstants.LEADING);

        panel.add(label, cons);
        cons.gridy++;
    } while (start >= 0);

    if (checkbox != null) {
        label = new JLabel("", SwingConstants.LEADING); //$NON-NLS-1$
        panel.add(label, cons);
        cons.gridy++;
        panel.add(checkbox, cons);
        cons.gridy++;
    }

    return panel;
}

From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java

private final JPanel createPanel() {
    disableDocumentListener(); // necessary because setting colors on editor pane triggers document change listeners (is considered a style change...)

    try {// ww w  .  j a  va 2  s . co  m
        editorPane.setEditable(editable);
        editorPane.getDocument().addUndoableEditListener(undoListener);
        editorPane.setCaretColor(Color.WHITE);
        setupKeyBindings(editorPane);
        setColors(editorPane);
        editorScrollPane = new JScrollPane(editorPane);
        setColors(editorScrollPane);
        editorPane.addCaretListener(listener);
        editorPane.addMouseListener(mouseListener);
        editorPane.addMouseMotionListener(new MouseMotionAdapter() {

            @Override
            public void mouseMoved(MouseEvent e) {
                if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) // ctrl pressed
                {
                    final ASTNode node = getASTNodeForLocation(e.getPoint());
                    if (node instanceof SymbolReferenceNode) {
                        maybeUnderlineIdentifierAt(e.getPoint());
                    } else {
                        clearUnderlineHighlight();
                    }
                } else if (compilationUnit != null) {
                    String tooltipText = null;
                    if (compilationUnit != null) {
                        final ASTNode node = getASTNodeForLocation(e.getPoint());
                        if (node instanceof InvokeMacroNode) {
                            tooltipText = ExpandMacrosPhase.expandInvocation((InvokeMacroNode) node,
                                    compilationUnit);
                            if (tooltipText != null) {
                                tooltipText = "<html>" + tooltipText.replace("\n", "<br>") + "</html>";
                            }
                        }
                    }
                    if (!StringUtils.equals(editorPane.getToolTipText(), tooltipText)) {
                        editorPane.setToolTipText(tooltipText);
                    }
                }
            }
        });
        editorPane.addMouseListener(popupListener);
    } finally {
        enableDocumentListener();
    }

    EditorContainer.addEditorCloseKeyListener(editorPane, this);

    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 600));
    editorScrollPane.setMinimumSize(new Dimension(100, 100));

    final AdjustmentListener adjustmentListener = new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (compilationUnit != null) {
                    doHighlighting(compilationUnit, false);
                }
            }
        }
    };
    editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener);
    editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener);

    // button panel
    final JPanel topPanel = new JPanel();

    final JToolBar toolbar = new JToolBar();

    setColors(toolbar);

    cursorPosition.setSize(new Dimension(400, 15));
    cursorPosition.setEditable(false);
    setColors(cursorPosition);

    /**
     * TOOLBAR
     * SOURCE
     * cursor position
     * status area 
     */
    topPanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(toolbar, cnstrs);

    cnstrs = constraints(0, 1, GridBagConstraints.BOTH);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    topPanel.add(editorScrollPane, cnstrs);

    cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(cursorPosition, cnstrs);

    cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;

    // setup result panel
    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    setColors(panel);
    cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    panel.add(topPanel, cnstrs);
    return panel;
}

From source file:net.jradius.client.gui.JRadiusSimulator.java

/**
 * This method initializes tlsOptionsPanel
 * /*  w  w w  .  j  a va 2s  .  co  m*/
 * @return javax.swing.JPanel
 */
private JPanel getKeysOptionsPanel() {
    if (keysOptionsPanel == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 5);

        GridBagConstraints gridBagConstraintsH = new GridBagConstraints();
        gridBagConstraintsH.insets = new java.awt.Insets(10, 10, 5, 10);
        gridBagConstraintsH.gridwidth = java.awt.GridBagConstraints.REMAINDER;

        GridBagConstraints gridBagConstraints0 = new GridBagConstraints();
        gridBagConstraints0.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints0.insets = new java.awt.Insets(0, 0, 0, 5);
        gridBagConstraints0.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints0.weightx = 1.0;

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 5);
        gridBagConstraints1.weightx = 1.0;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 10);

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 10);
        gridBagConstraints3.gridx = 1;

        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.insets = new java.awt.Insets(0, 0, 0, 5);

        GridBagLayout gridBagLayout = new GridBagLayout();

        keysOptionsPanel = new JPanel();
        keysOptionsPanel.setLayout(gridBagLayout);
        keysOptionsPanel.add(new JLabel("Client Certificate Java Keystore"), gridBagConstraintsH);
        keysOptionsPanel.add(new JLabel("File:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSKeyFileTextField(), gridBagConstraints0);
        keysOptionsPanel.add(new JLabel("Password:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSKeyPasswordTextField(), gridBagConstraints1);
        keysOptionsPanel.add(new JLabel("Type:"), gridBagConstraints4);
        keysOptionsPanel.add(getTLSKeyFileTypeComboBox(), gridBagConstraints2);
        keysOptionsPanel.add(new JLabel("Root CA Chain Java Keystore"), gridBagConstraintsH);
        keysOptionsPanel.add(new JLabel("File:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSCAFileTextField(), gridBagConstraints0);
        keysOptionsPanel.add(new JLabel("Password:"), gridBagConstraints);
        keysOptionsPanel.add(getTLSCAPasswordTextField(), gridBagConstraints1);
        keysOptionsPanel.add(new JLabel("Type:"), gridBagConstraints4);
        keysOptionsPanel.add(getTLSCAFileTypeComboBox(), gridBagConstraints2);
        keysOptionsPanel.add(getOptionsLabel(), gridBagConstraints);
        //tlsOptionsPanel.add(getUseJavaRootCAChainCheckBox(), gridBagConstraints2);
        keysOptionsPanel.add(getTLSTrustAllCheckBox(), gridBagConstraints2);
    }
    return keysOptionsPanel;
}

From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java

License:asdf

/**
 * Populate the table with the current quantEvents
 *///from w w w  . ja v  a2 s  . co  m
protected void displayEvents() {
    _log.debug("displayEvents 1, quant events: " + quantEvents.size());
    String proteinOrProteins = "Protein";
    if (proteinNames.size() > 1)
        proteinOrProteins = "Proteins";
    if (proteinNames.size() > 4)
        setTitle("Event Summary for " + proteinNames.size() + " Proteins");
    else
        setTitle("Event Summary for " + proteinOrProteins + " " + concatProteinNamesMax3(","));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.weighty = 1;
    gbc.weightx = 1;

    List<Integer> alreadySelectedEventIndices = new ArrayList<Integer>();
    if (existingQuantEvents != null) {
        for (int i = 0; i < quantEvents.size(); i++) {
            for (QuantEvent existingEvent : existingQuantEvents) {
                //check the events for identity with already-loaded events.  If we get it, grey out and
                //replace the new one with the old one (to pick up curation statuses
                if (quantEvents.get(i).isSameEvent(existingEvent)) {
                    alreadySelectedEventIndices.add(i);
                    quantEvents.set(i, existingEvent);

                    break;
                }
            }
        }
    }

    _log.debug("displayEvents 2");

    List<Float> eventLogRatios = new ArrayList<Float>();

    for (QuantEvent event : quantEvents)
        eventLogRatios.add((float) Math.log(event.getRatio()));
    eventsTable.displayEvents(quantEvents, alreadySelectedEventIndices);

    _log.debug("displayEvents 3");

    buttonSelectAllVisible.setEnabled(true);
    buttonDeselectAll.setEnabled(true);

    loadSelectedEventsButton.setEnabled(true);
    autoAssessSelectedEventsButton.setEnabled(true);

    buildTurkHITsButton.setEnabled(true);
    showPropertiesButton.setEnabled(true);
    showProteinRatiosButton.setEnabled(true);

    _log.debug("displayEvents 4");

    logRatioHistogramPanel.setMaxLowRatio(maxLowRatio);
    _log.debug("displayEvents a");

    logRatioHistogramPanel.setMinHighRatio(minHighRatio);
    _log.debug("displayEvents a, eventlogratios: " + eventLogRatios.size());

    logRatioHistogramPanel.setLogRatios(eventLogRatios);
    _log.debug("displayEvents a");

    logRatioHistogramPanel.setSize(width - 5, LOGRATIO_HISTOGRAM_PANEL_HEIGHT - 20);

    _log.debug("displayEvents 4.0.1");

    logRatioHistogramPanel.addRangeUpdateListener(new LogRatioHistogramListener());

    _log.debug("displayEvents 4.1");

    logRatioHistogramPanel.updateUI();

    _log.debug("displayEvents 4.2");

    contentPanel.updateUI();

    _log.debug("displayEvents 5");

    fullHeight = Math.min(800, Math.max(600, (quantEvents.size() + 1) * TABLEROW_HEIGHT) + SUMMARYPANEL_HEIGHT
            + LOGRATIO_HISTOGRAM_PANEL_HEIGHT + STATUSPANEL_HEIGHT + TITLEBAR_HEIGHT);
    setSize(fullWidth, fullHeight);

    _log.debug("displayEvents end");

}

From source file:tufts.vue.ui.InspectorPane.java

/** labels & values must be of same length */
private void addLabelTextRows(int starty, JLabel[] labels, JComponent[] values, Container gridBag,
        Font labelFace, Font fieldFace) {
    // Note that the resulting alignment ends up being somehow FONT dependent!
    // E.g., works great with Lucida Grand (MacOSX), but with system default,
    // if the field value is a wrapping JTextPane (thus gets taller as window
    // gets narrower), the first line of text rises slightly and is no longer
    // in line with it's label.

    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    c.weighty = 0;//from   w ww .j  a va2  s.co m
    c.gridheight = 1;

    for (int i = 0; i < labels.length; i++) {

        //out("ALTR[" + i + "] label=" + GUI.name(labels[i]) + " value=" + GUI.name(values[i]));

        boolean centerLabelVertically = false;
        final JLabel label = labels[i];
        final JComponent field = values[i];

        if (labelFace != null)
            GUI.apply(labelFace, label);

        if (field instanceof JTextComponent) {
            if (field instanceof JTextField)
                centerLabelVertically = true;
            //                 JTextComponent textField = (JTextComponent) field;
            //                 editable = textField.isEditable();
            //                 if (field instanceof JTextArea) {
            //                     JTextArea textArea = (JTextArea) field;
            //                     c.gridheight = textArea.getRows();
            //                     } else if (field instanceof JTextField)
        } else {
            if (fieldFace != null)
                GUI.apply(fieldFace, field);
        }

        //-------------------------------------------------------
        // Add the field label
        //-------------------------------------------------------

        c.gridx = 0;
        c.gridy = starty++;
        c.insets = labelInsets;
        c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last in row
        c.fill = GridBagConstraints.NONE; // the label never grows
        if (centerLabelVertically)
            c.anchor = GridBagConstraints.EAST;
        else
            c.anchor = GridBagConstraints.NORTHEAST;
        c.weightx = 0.0; // do not expand
        gridBag.add(label, c);

        //-------------------------------------------------------
        // Add the field value
        //-------------------------------------------------------

        c.gridx = 1;
        c.gridwidth = GridBagConstraints.REMAINDER; // last in row
        c.fill = GridBagConstraints.HORIZONTAL;
        c.anchor = GridBagConstraints.CENTER;
        //c.anchor = GridBagConstraints.NORTH;
        c.insets = fieldInsets;
        c.weightx = 1.0; // field value expands horizontally to use all space
        gridBag.add(field, c);

    }

    // add a default vertical expander to take up extra space
    // (so the above stack isn't vertically centered if it
    // doesn't fill the space).

    c.weighty = 1;
    c.weightx = 1;
    c.gridx = 0;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    JComponent defaultExpander = new JPanel();
    defaultExpander.setPreferredSize(new Dimension(Short.MAX_VALUE, 1));
    if (DEBUG.BOXES) {
        defaultExpander.setOpaque(true);
        defaultExpander.setBackground(Color.red);
    } else
        defaultExpander.setOpaque(false);
    gridBag.add(defaultExpander, c);
}

From source file:net.jradius.client.gui.JRadiusSimulator.java

/**
 * This method initializes openUrlContentPane   
 *    /*from w ww  .  j a v a 2s. com*/
 * @return javax.swing.JPanel   
 */
private JPanel getOpenUrlContentPane() {
    if (openUrlContentPane == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.insets = new java.awt.Insets(25, 25, 10, 25);

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.insets = new java.awt.Insets(0, 25, 0, 5);
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 25);
        gridBagConstraints2.weightx = 1.0;

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints3.insets = new java.awt.Insets(0, 25, 25, 25);

        JLabel openUrlLabel = new JLabel();
        openUrlLabel.setText("URL:");

        openUrlStatusLabel = new JLabel();

        GridBagLayout gridBagLayout = new GridBagLayout();

        openUrlContentPane = new JPanel();
        openUrlContentPane.setLayout(gridBagLayout);

        JPanel buttonPanel = new JPanel();
        buttonPanel.add(getOpenUrlButton(), null);
        buttonPanel.add(getCancelUrlButton(), null);

        openUrlContentPane.add(openUrlStatusLabel, gridBagConstraints);
        openUrlContentPane.add(openUrlLabel, gridBagConstraints1);
        openUrlContentPane.add(getOpenUrlTextField(), gridBagConstraints2);
        openUrlContentPane.add(buttonPanel, gridBagConstraints3);
    }
    return openUrlContentPane;
}

From source file:base.BasePlayer.Main.java

void setButtons() {
    try {//from   w  w  w .j a  va  2  s.  com

        //      filemenu.setFont(font);
        GridBagConstraints c = new GridBagConstraints();

        c.anchor = GridBagConstraints.NORTHWEST;
        c.insets = new Insets(1, 4, 4, 2);
        //c.insets = new Insets(5, 5, 2, 5);
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 1;
        /*   opensamples.setMargin(new Insets(0, 0, 0,0));
                   
           opensamples.setPreferredSize(buttonDimension);
           addtracks.setMargin(new Insets(0, 0, 0, 0));
           addtracks.setPreferredSize(buttonDimension);
           addcontrols.setMargin(new Insets(0, 0, 0, 0));
           addcontrols.setPreferredSize(buttonDimension);
           */

        menubar.setOpaque(true);
        panel.add(menubar, c);
        c.gridx = 1;

        setbut = new JButton("", settingsIcon);
        setbut.setToolTipText("Settings");

        setbut.setOpaque(false);
        setbut.setContentAreaFilled(false);
        setbut.setBackground(Main.panel.getBackground());
        setbut.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                Settings.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - Settings.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);
                Settings.frame.setState(JFrame.NORMAL);
                Settings.frame.setVisible(true);
            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {
                setbut.setOpaque(true);
                Main.setbut.setBackground(Color.white);
                Main.setbut.revalidate();
            }

            @Override
            public void mouseExited(MouseEvent e) {
                setbut.setOpaque(false);
                Main.setbut.revalidate();
            }

        });
        setbut.setBorder(null);
        c.insets = new Insets(0, 2, 0, 0);
        menubar.add(setbut, c);
        //   c.gridx = 1;
        //   c.gridx = 2;      
        //   c.gridx = 3;      

        //      zoomout.setMargin(new Insets(0, 0, 0, 0));
        //   panel.add(zoomout, c);      

        /*   JMenuItem empty2 = new JMenuItem("");
           empty2.setEnabled(false);      
           menubar.add(empty2);
                  
            c.gridx = 4;*/
        //  chromosomeDropdown.setPreferredSize(buttonDimension);

        // panel.add(chromosomeDropdown, c);
        //       c.gridx = 5;

        //  back.setMargin(new Insets(0, 0, 0, 0));
        // forward.setMargin(new Insets(0, 0, 0, 0));
        // back.setPreferredSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //    forward.setPreferredSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //back.setMinimumSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //    forward.setMinimumSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight()));
        //    panel.add(back, c);
        //       c.gridx = 7;
        //   panel.add(forward, c);

        chromosomeDropdown.setMaximumRowCount(25);
        chromosomeDropdown.setEnabled(true);
        chromosomeDropdown.addActionListener(ChromoDropActionListener);
        chromosomeDropdown.addMouseListener(this);

        c.gridwidth = 10;
        c.gridx = 0;
        c.gridy = 1;
        bedScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        bedScroll.getViewport().setPreferredSize(bedDimensions);

        drawScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        drawScroll.getViewport().setPreferredSize(drawDimensions);

        chromScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        chromScroll.getViewport().setPreferredSize(chromDimensions);

        drawScroll.getVerticalScrollBar().setAutoscrolls(false);
        //       chromScroll.getViewport().setPreferredSize(new Dimension(drawWidth,chromHeight-20));

        //    drawScroll.setBorder(BorderFactory.createEmptyBorder());
        //chromScroll.setBorder(BorderFactory.createLoweredBevelBorder());
        //    drawScroll.setBorder(BorderFactory.createLoweredBevelBorder());
        //    bedScroll.setBorder(BorderFactory.createLoweredBevelBorder());

        //   chromScroll.setBorder(BorderFactory.createEmptyBorder());

        //       bedScroll.setBorder(BorderFactory.createEmptyBorder());

        controlScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        controlScroll.getViewport().setPreferredSize(bedDimensions);
        controlScroll.getViewport().add(controlDraw);
        controlDraw.setVisible(false);
        controlScroll.setVisible(false);

        chromScroll.setBorder(BorderFactory.createEmptyBorder());
        drawScroll.setBorder(BorderFactory.createEmptyBorder());
        bedScroll.setBorder(BorderFactory.createLoweredBevelBorder());
        controlScroll.setBorder(BorderFactory.createLoweredBevelBorder());

        addSplit(chromosomeDropdown.getItemAt(0));

        chromScroll.getViewport().add(chromDraw);
        drawScroll.getViewport().add(drawCanvas);
        drawScroll.addMouseListener(this);
        bedCanvas = new BedCanvas(drawWidth, 200);

        bedScroll.getViewport().add(bedCanvas);

        frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);

        c.weightx = 1.0;
        c.weighty = 1.0;
        c.fill = GridBagConstraints.BOTH;

        trackPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, bedScroll, controlScroll);
        trackPane.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);
                        super.paint(g);
                    }
                };
            }
        });
        trackPane.setBorder(null);

        trackPane.setDividerSize(0);
        trackPane.setPreferredSize(drawDimensions);
        trackPane.setResizeWeight(0.0);
        trackPane.setContinuousLayout(true);
        trackPane.setVisible(false);

        varpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, trackPane, drawScroll);
        varpane.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);
                        super.paint(g);
                    }
                };
            }
        });
        varpane.setBorder(null);

        varpane.setDividerSize(0);
        varpane.setPreferredSize(drawDimensions);
        varpane.setResizeWeight(0.0);
        varpane.setContinuousLayout(true);
        bedScroll.setVisible(false);

        controlScroll.setVisible(false);

        chrompan = new JPanel() {
            private static final long serialVersionUID = 1L;

            protected void paintComponent(Graphics g) {

                super.paintComponent(g);
                g.setColor(Draw.sidecolor);
                g.fillRect(0, 0, this.getWidth(), this.getHeight());

                g.setColor(Color.gray);
                g.fillRect(0, 0, 3, this.getHeight());
                g.setColor(Color.lightGray);
                g.fillRect(2, 0, 2, this.getHeight());

            }

        };
        chrompan.setLayout(new GridBagLayout());
        GridBagConstraints gb = new GridBagConstraints();
        gb.anchor = GridBagConstraints.NORTHWEST;

        gb.insets = new Insets(2, 10, 2, 2);
        gb.gridx = 0;
        gb.gridy = 0;
        gb.gridwidth = 1;
        gb.fill = GridBagConstraints.HORIZONTAL;
        refDropdown.setBackground(Color.white);
        refDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
        refDropdown.setBorder(BorderFactory.createCompoundBorder(refDropdown.getBorder(),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));
        geneDropdown.setBackground(Color.white);
        geneDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
        geneDropdown.setBorder(BorderFactory.createCompoundBorder(geneDropdown.getBorder(),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));
        geneDropdown.addActionListener(annoDropActionListener);
        JLabel refLabel = new JLabel("Reference genome:");

        JLabel geneLabel = new JLabel("Gene annotation:");
        chromLabel.setName("header");
        chrompan.add(chromLabel, gb);
        gb.gridy++;
        chrompan.add(new JSeparator(), gb);
        gb.gridy++;
        gb.insets = new Insets(0, 10, 0, 2);
        chrompan.add(refLabel, gb);
        gb.gridy++;
        chrompan.add(refDropdown, gb);
        gb.gridy++;
        chrompan.add(geneLabel, gb);
        gb.gridy++;
        chrompan.add(geneDropdown, gb);
        gb.gridy++;
        gb.insets = new Insets(20, 10, 0, 2);
        JLabel memory = new JLabel("Memory usage:");
        memory.setName("header");
        chrompan.add(memory, gb);
        gb.insets = new Insets(0, 10, 0, 2);
        gb.gridy++;
        chrompan.add(memLabel, gb);
        gb.weightx = 1;
        gb.weighty = 1;
        gb.gridwidth = GridBagConstraints.REMAINDER;
        chrompan.add(new JLabel(), gb);
        chrompan.setMinimumSize(new Dimension(1, 1));
        chrompan.addComponentListener(this);
        upPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chrompan, chromScroll);
        drawScroll.addComponentListener(this);
        //upPanel.setBorder(BorderFactory.createLoweredBevelBorder());
        upPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white));
        upPanel.setDividerLocation(Main.sidebarWidth - 2);
        chrompan.setBackground(Draw.sidecolor);
        BasicSplitPaneUI chromPaneUI = (BasicSplitPaneUI) upPanel.getUI();
        chromPaneDivider = chromPaneUI.getDivider();
        chromPaneDivider.addMouseListener(this);

        upPanel.setDividerSize(3);

        upPanel.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);

                        super.paint(g);
                    }
                };
            }
        });

        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upPanel, varpane);

        splitPane.setUI(new BasicSplitPaneUI() {
            public BasicSplitPaneDivider createDefaultDivider() {
                return new BasicSplitPaneDivider(this) {

                    private static final long serialVersionUID = 1L;

                    public void setBorder(Border b) {
                    }

                    @Override
                    public void paint(Graphics g) {
                        g.setColor(Color.lightGray);
                        g.fillRect(0, 0, getSize().width, getSize().height);

                        super.paint(g);
                    }
                };
            }
        });

        BasicSplitPaneUI basicSplitPaneUI = (BasicSplitPaneUI) splitPane.getUI();
        splitPaneDivider = basicSplitPaneUI.getDivider();
        //    splitPaneDivider.addMouseListener(this);
        basicSplitPaneUI = (BasicSplitPaneUI) trackPane.getUI();
        trackPaneDivider = basicSplitPaneUI.getDivider();
        //    trackPaneDivider.addMouseListener(this);
        BasicSplitPaneUI splitPaneUI = (BasicSplitPaneUI) varpane.getUI();
        varPaneDivider = splitPaneUI.getDivider();
        //   varPaneDivider.addMouseListener(this);
        splitPane.setDividerSize(3);

        splitPane.setPreferredSize(drawDimensions);
        splitPane.setContinuousLayout(true);

        panel.add(splitPane, c);
        add(panel, c);

        openvcfs.addActionListener(this);
        openbams.addActionListener(this);
        addtracks.addActionListener(this);
        addcontrols.addActionListener(this);

        openProject.addActionListener(this);
        saveProject.addActionListener(this);
        saveProjectAs.addActionListener(this);
        dosomething.addActionListener(this);
        clear.addActionListener(this);
        //    drawScroll.getVerticalScrollBar().addMouseMotionListener(this);
        drawScroll.getVerticalScrollBar().addMouseListener(this);
        drawScroll.getVerticalScrollBar().addMouseMotionListener(this);
        drawScroll.getVerticalScrollBar().addMouseWheelListener(new MouseWheelListener() {
            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                Draw.setGlasspane(true);
                if (e.getWheelRotation() < 0) {
                    if (drawCanvas.drawVariables.visiblestart > 0) {
                        drawCanvas.drawVariables.visiblestart--;

                    }
                    Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart
                            * drawCanvas.drawVariables.sampleHeight));
                } else {
                    if (drawCanvas.drawVariables.visiblestart
                            + drawCanvas.drawVariables.visiblesamples < Main.samples) {
                        drawCanvas.drawVariables.visiblestart++;

                    }
                    Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart
                            * drawCanvas.drawVariables.sampleHeight));
                }

            }

        }

        );
        drawScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent event) {

                //System.out.println(drawCanvas.drawVariables.visiblestart +" " +(short)(Main.drawScroll.getVerticalScrollBar().getValue()/drawCanvas.drawVariables.sampleHeight));
                if (drawCanvas.drawVariables.visiblestart != (short) (Main.drawScroll.getVerticalScrollBar()
                        .getValue() / drawCanvas.drawVariables.sampleHeight)) {
                    if (!drawCanvas.sidebar) {
                        drawCanvas.drawVariables.visiblestart = (short) (Main.drawScroll.getVerticalScrollBar()
                                .getValue() / drawCanvas.drawVariables.sampleHeight);
                    }
                    if (drawCanvas.splits.size() > 1) {
                        for (int i = 0; i < drawCanvas.splits.size(); i++) {
                            drawCanvas.splits.get(i).updateReads = true;
                        }
                    } else {
                        Draw.updateReads = true;
                        Draw.updatevars = true;
                    }

                    Draw.updatevars = true;
                    Main.drawCanvas.repaint();
                }

            }

        });

        zoomout.addActionListener(this);

        FileRead.head = new VarNode(0, (byte) 0, "N", (short) 0, (short) 0, false, (float) 0, (float) 0, null,
                null, new Sample("", (short) 1, null), null, null);
        drawCanvas.current = FileRead.head;

        frame.addComponentListener(this);
        frame.addMouseListener(this);
        frame.setGlassPane(glassPane);
        glassPane.setOpaque(false);
        glassPane.setVisible(false);

        positionField.setText("chr1:1-" + MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd));
        positionField.setToolTipText("Current chromosomal region");
        widthLabel.setText(MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd) + "bp");
        widthLabel.setToolTipText("Current region width in base pairs");
    } catch (Exception e) {
        e.printStackTrace();
    }
}