Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

In this page you can find the example usage for javax.swing JPanel setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:org.revager.gui.findings_list.FindingsListFrame.java

private void createAttPanel() {
    GridLayout grid = new GridLayout(4, 1);
    grid.setVgap(8);/*from   w  w  w  .j a v  a  2  s .c  o  m*/

    JPanel attendeeButtons = new JPanel(grid);

    addResiAtt = GUITools.newImageButton();
    addResiAtt.setIcon(Data.getInstance().getIcon("addResiAtt_25x25_0.png"));
    addResiAtt.setRolloverIcon(Data.getInstance().getIcon("addResiAtt_25x25.png"));
    addResiAtt.setToolTipText(translate("Add Attendee from the Attendee Pool"));
    addResiAtt.addActionListener(ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()));
    attendeeButtons.add(addResiAtt);

    JButton addAttendee = GUITools.newImageButton();
    addAttendee.setIcon(Data.getInstance().getIcon("addAttendee_25x25_0.png"));
    addAttendee.setRolloverIcon(Data.getInstance().getIcon("addAttendee_25x25.png"));
    addAttendee.setToolTipText(translate("Add Attendee"));
    addAttendee.addActionListener(ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()));
    attendeeButtons.add(addAttendee);

    removeAttendee = GUITools.newImageButton();
    removeAttendee.setIcon(Data.getInstance().getIcon("removeAttendee_25x25_0.png"));
    removeAttendee.setRolloverIcon(Data.getInstance().getIcon("removeAttendee_25x25.png"));
    removeAttendee.setToolTipText(translate("Remove Attendee"));
    removeAttendee.addActionListener(ActionRegistry.getInstance().get(RemAttFromProtAction.class.getName()));
    attendeeButtons.add(removeAttendee);

    editAttendee = GUITools.newImageButton();
    editAttendee.setIcon(Data.getInstance().getIcon("editAttendee_25x25_0.png"));
    editAttendee.setRolloverIcon(Data.getInstance().getIcon("editAttendee_25x25.png"));
    editAttendee.setToolTipText(translate("Edit Attendee"));
    editAttendee.addActionListener(ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()));
    attendeeButtons.add(editAttendee);

    editAttendee.setEnabled(false);
    removeAttendee.setEnabled(false);

    presentAttTable.setRowHeight(55);
    presentAttTable.getColumnModel().getColumn(0).setMaxWidth(55);
    presentAttTable.setShowHorizontalLines(false);
    presentAttTable.setShowVerticalLines(true);
    presentAttTable.setShowGrid(true);
    presentAttTable.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()).actionPerformed(null);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    TableCellRenderer renderer = (table, value, isSelected, hasFocus, row, column) -> {
        JLabel label = new JLabel((String) value);
        label.setOpaque(true);
        label.setBorder(new EmptyBorder(5, 5, 5, 5));

        label.setFont(UI.VERY_LARGE_FONT);

        if (isSelected) {
            label.setBackground(presentAttTable.getSelectionBackground());
        } else {
            if (row % 2 == 0) {
                label.setBackground(UI.TABLE_ALT_COLOR);
            } else {
                label.setBackground(presentAttTable.getBackground());
            }
        }
        return label;
    };

    for (int i = 1; i <= 4; i++) {
        presentAttTable.getColumnModel().getColumn(i).setCellRenderer(renderer);
    }

    TableColumn col = presentAttTable.getColumnModel().getColumn(0);
    col.setCellRenderer((table, value, isSelected, hasFocus, row, column) -> {
        JPanel localPnl = new JPanel();
        localPnl.add(new JLabel(Data.getInstance().getIcon("attendee_40x40.png")));
        if (isSelected) {
            localPnl.setBackground(presentAttTable.getSelectionBackground());
        } else {
            if (row % 2 == 0) {
                localPnl.setBackground(UI.TABLE_ALT_COLOR);
            } else {
                localPnl.setBackground(presentAttTable.getBackground());
            }
        }
        return localPnl;
    });
    presentAttTable.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            updateAttButtons();
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    scrllP = GUITools.setIntoScrollPane(presentAttTable);
    scrllP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    scrllP.setToolTipText(translate("Add Attendee to Meeting"));
    scrllP.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (isAddResiAttPossible()) {
                ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()).actionPerformed(null);
            } else {
                ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()).actionPerformed(null);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    JLabel labelAttendees = new JLabel(translate("Attendees of the current meeting:"));
    labelAttendees.setFont(UI.HUGE_FONT_BOLD);

    GUITools.addComponent(attPanel, gbl, labelAttendees, 0, 0, 2, 1, 1.0, 0.0, 20, 20, 0, 20,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(attPanel, gbl, scrllP, 0, 1, 1, 1, 1.0, 1.0, 20, 20, 0, 20, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST);
    GUITools.addComponent(attPanel, gbl, attendeeButtons, 1, 1, 1, 1, 0, 0, 20, 0, 20, 20,
            GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new base panel for popup windows.
 * /* w  ww. ja  v a 2s  .c  om*/
 * @return the newly created base panel
 */
public static JPanel newPopupBasePanel() {
    JPanel panelBase = new JPanel();
    panelBase.setLayout(new BorderLayout());
    panelBase.setBackground(UI.POPUP_BACKGROUND);
    return panelBase;
}

From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java

private AbstractWizardPage getReferencePage() throws SQLException, RemoteException {
    //setup page//from  w  w w.j av a 2  s  . com
    final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_REF) {
        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK);
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
        }
    };
    page.addText("Choose reference genome(s) to add to this project, along\n"
            + "with corresponding annotations. Annotations will be\n"
            + "applied to all variants added to these tables.");

    //setup list
    JScrollPane scrollpane = new JScrollPane();
    scrollpane.setPreferredSize(new Dimension(300, 220));
    scrollpane.getViewport().setBackground(Color.white);

    final JPanel p = new JPanel();
    p.setBackground(Color.white);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    refreshReferencePanel(p);
    scrollpane.getViewport().add(p);

    page.addComponent(scrollpane);

    JButton addRefButton = new JButton("New Reference");
    addRefButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                new NewReferenceDialog().setVisible(true);
                refreshReferencePanel(p);
            } catch (Exception ex) {
                ClientMiscUtils.reportError("Unable to retrieve references and annotations: %s", ex);
            }
        }
    });
    page.addComponent(addRefButton);

    return page;
}

From source file:org.ut.biolab.medsavant.client.view.app.builtin.settings.AddRemoveDatabaseDialog.java

/** This method is called from within the constructor to
 * initialize the form.//  ww w  . j  a  v a2  s . c o  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    okButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    javax.swing.JPanel detailsPanel = new javax.swing.JPanel();
    javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
    hostField = new javax.swing.JTextField();
    javax.swing.JLabel jLabel4 = new javax.swing.JLabel();
    portField = new javax.swing.JTextField();
    javax.swing.JLabel jLabel5 = new javax.swing.JLabel();
    databaseField = new javax.swing.JTextField();
    javax.swing.JLabel jLabel6 = new javax.swing.JLabel();
    passwordField = new javax.swing.JPasswordField();
    javax.swing.JLabel jLabel7 = new javax.swing.JLabel();
    userField = new javax.swing.JTextField();

    setTitle("Create Database");
    setBackground(new java.awt.Color(217, 222, 229));

    okButton.setText("Create");
    okButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            okButtonActionPerformed(evt);
        }
    });

    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
        }
    });

    detailsPanel.setBackground(getBackground());
    detailsPanel.setOpaque(false);

    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("SERVER ADDRESS");

    hostField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N
    hostField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

    jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel4.setText("SERVER PORT");

    portField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N
    portField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

    jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel5.setText("DATABASE NAME");

    databaseField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N
    databaseField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

    jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel6.setText("ADMIN USERNAME");

    passwordField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N
    passwordField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

    jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel7.setText("ADMIN PASSWORD");

    userField.setFont(new java.awt.Font("Lucida Grande", 0, 15)); // NOI18N
    userField.setHorizontalAlignment(javax.swing.JTextField.CENTER);

    org.jdesktop.layout.GroupLayout detailsPanelLayout = new org.jdesktop.layout.GroupLayout(detailsPanel);
    detailsPanel.setLayout(detailsPanelLayout);
    detailsPanelLayout.setHorizontalGroup(detailsPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(detailsPanelLayout.createSequentialGroup().addContainerGap().add(detailsPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, hostField,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, portField,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(databaseField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(passwordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, userField,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE))
                    .addContainerGap()));
    detailsPanelLayout
            .setVerticalGroup(detailsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(detailsPanelLayout.createSequentialGroup().addContainerGap().add(jLabel3)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(hostField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel4)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(portField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel5)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(databaseField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel6)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(userField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel7)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(passwordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING,
                    layout.createSequentialGroup().addContainerGap(285, Short.MAX_VALUE).add(okButton)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(cancelButton)
                            .addContainerGap())
            .add(detailsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));

    layout.linkSize(new java.awt.Component[] { cancelButton, okButton },
            org.jdesktop.layout.GroupLayout.HORIZONTAL);

    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                    .add(detailsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(18, 18, 18).add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(cancelButton).add(okButton))
                    .addContainerGap()));

    getRootPane().setDefaultButton(okButton);

    pack();
}

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

public void addKey(final String key, boolean showExpand) {

    Color rowColor = Color.WHITE;
    if (keyKeyComponentMap.size() % 2 == 0) {
        rowColor = ViewUtil.getAlternateRowColor();
    }//from  w  w w. j  a v  a2  s . com

    if (newRowsGoIntoMoreSection) {
        keysInMoreSection.add(key);
    }

    rowColor = Color.white;

    String layoutConstraints = "insets 3 3 3 3, filly";

    JPanel valuePanel = ViewUtil.getClearPanel();
    valuePanel.setLayout(new MigLayout(layoutConstraints));
    valuePanel.setBackground(rowColor);

    int i = 0;

    JPanel keyPanel = ViewUtil.getClearPanel();
    keyPanel.setLayout(new MigLayout(layoutConstraints + ", alignx right, hmin 30"));

    keyPanel.setBackground(rowColor);

    final JLabel keyLabel = getKeyLabel(key);

    //keyLabel.setBorder(ViewUtil.getMediumBorder());
    keyKeyComponentMap.put(key, keyLabel);

    if (showExpand) {

        keyLabel.setText("? " + key.toUpperCase());

        keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        keyLabel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent me) {
                toggleMoreVisibility();

                if (keyLabel.getText().startsWith("?")) {
                    keyLabel.setText("? " + key.toUpperCase());
                } else {
                    keyLabel.setText("? " + key.toUpperCase());
                }
            }
        });
    }

    keyPanel.add(keyLabel);

    keyLabel.setVisible(keysVisible);

    kvpPanel.add(keyPanel, incrementConstraintRow(i++));
    kvpPanel.add(valuePanel, incrementConstraintRow(i++));

    JPanel[] extraComponents = new JPanel[additionalColumns];
    for (int j = 0; j < additionalColumns; j++) {
        JPanel panel = ViewUtil.getClearPanel();
        panel.setBackground(rowColor);
        ViewUtil.applyHorizontalBoxLayout(panel);
        //panel.setBorder(border);
        //panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        extraComponents[j] = panel;//ViewUtil.getClearPanel();
        kvpPanel.add(extraComponents[j], incrementConstraintRow(i++));
    }

    // add hidden panel
    keyDetailConstraints.gridy++;
    keyDetailConstraints.gridy++;

    JPanel detailPanel = ViewUtil.getClearPanel();
    detailPanel.setBackground(rowColor);
    //detailPanel.setBorder(ViewUtil.getTinyLineBorder());
    detailPanel.setVisible(false);
    keyDetailComponentMap.put(key, detailPanel);

    kvpPanel.add(detailPanel, keyDetailConstraints);

    // update all constraints to skip a line
    for (int k = 0; k < 2 + additionalColumns; k++) {
        incrementConstraintRow(k);
    }

    keyValueComponentMap.put(key, valuePanel);
    keyExtraComponentsMap.put(key, extraComponents);

    setMoreVisibility(showingMore);
}

From source file:org.ut.biolab.medsavant.client.view.list.ListView.java

private void updateShowCard() {
    showCard.removeAll();//from w w  w. j a v a2 s .  c  o m

    showCard.setLayout(new BorderLayout());

    String[] columnNames = detailedModel.getColumnNames();
    Class[] columnClasses = detailedModel.getColumnClasses();
    int[] columnVisibility = detailedModel.getHiddenColumns();

    int firstVisibleColumn = 0;
    while (columnVisibility.length > 0 && firstVisibleColumn == columnVisibility[firstVisibleColumn]) {
        firstVisibleColumn++;
    }

    Set<NiceListItem> selectedItems;
    if (list != null) {
        selectedItems = new HashSet<NiceListItem>(list.getSelectedItems());
    } else {
        selectedItems = new HashSet<NiceListItem>(); // empty set, for simplicity of not having to null check later on
    }

    list = new NiceList();
    if (listColorScheme != null) {
        list.setColorScheme(listColorScheme);
    }
    list.startTransaction();

    List<Integer> selectedIndicies = new ArrayList<Integer>();

    int counter = 0;
    for (Object[] row : data) {
        NiceListItem nli = new NiceListItem(row[firstVisibleColumn].toString(), row);
        list.addItem(nli);

        if (selectedItems.contains(nli)) {
            selectedIndicies.add(counter);
        }
        counter++;
    }

    /*
     int[] selectedIndiciesArray = new int[selectedIndicies.size()];
            
     System.out.println("Reselecting "  + selectedIndicies.size() + " items");
     for (int i = 0; i < selectedIndicies.size();i++) {
     System.out.println("Reselecting "  + list.getItem(selectedIndicies.get(i)).toString() + " at index " + selectedIndicies.get(i));
     selectedIndiciesArray[i] = selectedIndicies.get(i);
     }*/
    list.endTransaction();

    wp.setBackground(list.getColorScheme().getBackgroundColor());

    if (detailedView != null) {
        list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {

                if (!e.getValueIsAdjusting()) {
                    List<Object[]> selectedItems = getSelectedRows();
                    if (selectedItems.size() == 1) {
                        detailedView.setSelectedItem(selectedItems.get(0));
                    } else {
                        detailedView.setMultipleSelections(selectedItems);
                    }
                }
            }
        });

        list.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if (SwingUtilities.isRightMouseButton(e)) {
                    JPopupMenu popup = detailedView.createPopup();
                    if (popup != null) {
                        popup.show(e.getComponent(), e.getX(), e.getY());
                    }
                }
            }
        });
    }

    if (selectedIndicies.isEmpty()) {
        list.selectItemAtIndex(0);
    } else {
        list.selectItemsAtIndicies(selectedIndicies);
    }

    JScrollPane jsp = ViewUtil.getClearBorderlessScrollPane(list);
    jsp.setHorizontalScrollBar(null);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new MigLayout("wrap, fillx"));

    topPanel.add(ViewUtil.getEmphasizedLabel(pageName.toUpperCase()));
    topPanel.setBackground(list.getColorScheme().getBackgroundColor());

    if (searchBarEnabled) {
        topPanel.add(list.getSearchBar(), "growx 1.0");
    }
    showCard.add(topPanel, BorderLayout.NORTH);

    showCard.add(jsp, BorderLayout.CENTER);

    showCard.add(controlBar.getComponent(), BorderLayout.SOUTH);

}

From source file:org.zaproxy.zap.extension.quickstart.AttackPanel.java

@Override
public JPanel getDescriptionPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBackground(Color.WHITE);
    panel.add(QuickStartHelper.getWrappedLabel("quickstart.attack.panel.message1"),
            LayoutHelper.getGBC(0, 0, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
    panel.add(QuickStartHelper.getWrappedLabel("quickstart.attack.panel.message2"),
            LayoutHelper.getGBC(0, 1, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
    panel.add(new JLabel(" "), LayoutHelper.getGBC(0, 2, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5))); // Spacer
    return panel;
}

From source file:org.zaproxy.zap.extension.quickstart.launch.LaunchPanel.java

@Override
public JPanel getDescriptionPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBackground(Color.WHITE);
    panel.add(QuickStartHelper.getWrappedLabel("quickstart.launch.panel.message1"),
            LayoutHelper.getGBC(0, 0, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
    panel.add(QuickStartHelper.getWrappedLabel("quickstart.launch.panel.message2"),
            LayoutHelper.getGBC(0, 1, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
    panel.add(new JLabel(" "), LayoutHelper.getGBC(0, 2, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5))); // Spacer
    return panel;
}

From source file:org.zaproxy.zap.extension.quickstart.launch.LaunchPanel.java

@Override
public JPanel getFooterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBackground(Color.WHITE);
    panel.add(new JLabel(Constant.messages.getString("quickstart.panel.launch.manual")),
            LayoutHelper.getGBC(0, 0, 5, 1.0D, new Insets(5, 5, 5, 5)));
    return panel;
}

From source file:org.zaproxy.zap.extension.quickstart.QuickStartPanel.java

private void initialize() {
    this.setIcon(new ImageIcon(BreakPanel.class.getResource("/resource/icon/16/147.png"))); // 'lightning' icon
    this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | Event.SHIFT_MASK, false));
    this.setMnemonic(Constant.messages.getChar("quickstart.panel.mnemonic"));
    this.setLayout(new BorderLayout());

    JPanel panelContent = new JPanel(new GridBagLayout());
    JScrollPane jScrollPane = new JScrollPane();
    jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11));
    jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.setViewportView(panelContent);

    this.add(jScrollPane, BorderLayout.CENTER);

    panelContent.setBackground(Color.white);
    panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    /*/* w w  w . j a  v  a2s  . c  om*/
     * Layout:
     * Col            0                      1                      2                    3                       4
     * Row+----------------------+----------------------+----------------------+----------------------+----------------------+
     *  0 | Top welcome message                                                                       |    zap128x128.png    |
     *  1 | URL:                 | [ Url field                                                      ] |                      |
     *  2 |                      | [ Attack button ]    | [ Stop button ]      | padding              |                      |
     *  3 | Progress:            | Progress details                                                   |                      |
     *    | Bottom message                                                                                                   |
     *    | Show at start:       | [x]                  |                      |                      |                      |
     *    +----------------------+----------------------+----------------------+----------------------+----------------------+
     */

    panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.topmsg")),
            LayoutHelper.getGBC(0, 0, 4, 1.0D, new Insets(5, 5, 5, 5)));
    if (Constant.isDevBuild()) {
        panelContent.add(
                new JLabel(new ImageIcon(QuickStartPanel.class
                        .getResource("/org/zaproxy/zap/extension/quickstart/resources/zap128x128dark.png"))),
                LayoutHelper.getGBC(4, 0, 1, 0.0D, 0.0D, GridBagConstraints.NORTH));
    } else {
        panelContent.add(
                new JLabel(DisplayUtils.getScaledIcon(
                        new ImageIcon(SearchPanel.class.getResource("/resource/zap128x128.png")))),
                LayoutHelper.getGBC(4, 0, 1, 0.0D, 0.0D, GridBagConstraints.NORTH));
    }

    panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.url")),
            LayoutHelper.getGBC(0, 1, 1, 0.0D, new Insets(5, 5, 5, 5)));

    JPanel urlSelectPanel = new JPanel(new GridBagLayout());
    JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
    selectButton.setIcon(
            DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe icon
    selectButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame());
            SiteNode node = null;
            try {
                node = Model.getSingleton().getSession().getSiteTree()
                        .findNode(new URI(getUrlField().getText(), false));
            } catch (Exception e2) {
                // Ignore
            }
            node = nsd.showDialog(node);
            if (node != null && node.getHistoryReference() != null) {
                try {
                    getUrlField().setText(node.getHistoryReference().getURI().toString());
                } catch (Exception e1) {
                    // Ignore
                }
            }
        }
    });

    urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D));
    urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D));
    panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 1, 3, 0.25D));

    panelContent.add(this.getAttackButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D));
    panelContent.add(this.getStopButton(), LayoutHelper.getGBC(2, 2, 1, 0.0D));
    panelContent.add(new JLabel(""), LayoutHelper.getGBC(3, 2, 1, 0.75D, 0.0D)); // Padding to right of buttons

    progressLabel = new JLabel(
            Constant.messages.getString("quickstart.progress." + AttackThread.Progress.notstarted.name()));
    panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.progress")),
            LayoutHelper.getGBC(0, 3, 1, 0.0D, new Insets(5, 5, 5, 5)));
    panelContent.add(this.progressLabel, LayoutHelper.getGBC(1, 3, 3, 0.0D));

    panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.proxymsg")),
            LayoutHelper.getGBC(0, 4, 5, 1.0D, new Insets(5, 5, 5, 5)));

    if (Control.getSingleton().getExtensionLoader().getExtension("ExtensionPlugNHack") != null) {
        // Plug-n-Hack extension has been installed - this makes configuration much easier :)
        if (DesktopUtils.canOpenUrlInBrowser()) {
            panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitm")),
                    LayoutHelper.getGBC(0, 6, 1, 0.0D, new Insets(5, 5, 5, 5)));
            panelContent.add(this.getConfButton(), LayoutHelper.getGBC(1, 6, 1, 0.0D));

            panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitmalt")),
                    LayoutHelper.getGBC(0, 7, 1, 0.0D, new Insets(5, 5, 5, 5)));
        } else {
            panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitmurl")),
                    LayoutHelper.getGBC(0, 7, 1, 0.0D, new Insets(5, 5, 5, 5)));
        }
        panelContent.add(this.getConfField(), LayoutHelper.getGBC(1, 7, 3, 0.25D));

    } else {
        panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.helpmsg")),
                LayoutHelper.getGBC(0, 5, 5, 1.0D, new Insets(5, 5, 5, 5)));

    }

    panelContent.add(new JLabel(""), LayoutHelper.getGBC(0, 10, 4, 1.D, 1.0D)); // Padding at bottom

    this.setMode(Control.getSingleton().getMode());
}