Example usage for javax.swing JLabel setOpaque

List of usage examples for javax.swing JLabel setOpaque

Introduction

In this page you can find the example usage for javax.swing JLabel setOpaque.

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

/**
 * Cre le panel d'un onglet associ  une classe
 * // www  . j a va2 s  . com
 * @param cc ClasseCompte la classe des comptes
 * @return JPanel le JPanel associ
 */
private JPanel initClassePanel(ClasseCompte cc) {

    final JPanel panelTmp = new JPanel();
    long totalDebitClasse = 0;
    long totalCreditClasse = 0;

    panelTmp.setLayout(new GridBagLayout());
    panelTmp.setOpaque(false);
    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    // Rcupration des comptes de la classe avec le total
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable compteTable = base.getTable("COMPTE_PCE");
    SQLTable ecritureTable = base.getTable("ECRITURE");

    SQLSelect sel = new SQLSelect(base);
    sel.addSelect(compteTable.getKey());
    sel.addSelect(compteTable.getField("NUMERO"));
    sel.addSelect(compteTable.getField("NOM"));
    sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
    sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");

    String function = "REGEXP";
    String match = cc.getTypeNumeroCompte();
    if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
        // function = "SIMILAR TO";
        function = "~";
        // match = cc.getTypeNumeroCompte().replace(".*", "%");
    }

    Where w = new Where(compteTable.getField("NUMERO"), function, match);
    Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey());

    if (!UserManager.getInstance().getCurrentUser().getRights()
            .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
        // TODO Show Restricted acces in UI
        w = w.and(new Where(ecritureTable.getField("COMPTE_NUMERO"), "LIKE", "411%"));
    }

    sel.setWhere(w.and(w2));

    String req = sel.asString()
            + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\",\"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    JLabel labelTotalClasse = new JLabel();
    labelTotalClasse.setOpaque(false);
    if (myList.size() != 0) {

        /***************************************************************************************
         * Cration des Panels de chaque compte
         **************************************************************************************/
        // c.weighty = 1;
        for (int i = 0; i < myList.size(); i++) {

            Object[] objTmp = (Object[]) myList.get(i);

            final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(),
                    objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(),
                    ((Number) objTmp[4]).longValue());

            c.fill = GridBagConstraints.HORIZONTAL;
            c.weightx = 1;
            c.weighty = 0;
            c.gridx = 0;
            c.gridy++;
            panelTmp.add(creerComptePanel(compteTmp), c);

            // calcul du total de la classe
            totalDebitClasse += compteTmp.getTotalDebit();
            totalCreditClasse += compteTmp.getTotalCredit();
        }

        // Total de la classe
        labelTotalClasse.setText(
                "Total Classe " + cc.getNom() + " Dbit : " + GestionDevise.currencyToString(totalDebitClasse)
                        + " Crdit : " + GestionDevise.currencyToString(totalCreditClasse));

    } else {
        labelTotalClasse.setHorizontalAlignment(SwingConstants.CENTER);
        labelTotalClasse.setText("Aucune criture pour la classe " + cc.getNom());
    }
    c.gridy++;
    c.weighty = 1;
    panelTmp.add(labelTotalClasse, c);

    return panelTmp;
}

From source file:org.openmicroscopy.shoola.agents.measurement.util.ui.ResultsCellRenderer.java

/**
 * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, 
 *                               boolean, boolean, int, int)
 *//*from  w w  w.j a  v  a 2  s .  com*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component thisComponent = new JLabel();
    JLabel label = new JLabel();
    label.setOpaque(true);

    if (value instanceof Number) {
        MeasurementTableModel tm = (MeasurementTableModel) table.getModel();
        KeyDescription key = tm.getColumnNames().get(column);
        String k = key.getKey();
        MeasurementUnits units = tm.getUnitsType();
        Number n = (Number) value;
        String s;
        if (units.isInMicrons()) {
            UnitsObject object;
            StringBuffer buffer = new StringBuffer();
            object = UIUtilities.transformSize(n.doubleValue());
            s = twoDecimalPlaces(object.getValue());
            if (StringUtils.isNotBlank(s)) {
                buffer.append(s);
                if (!(AnnotationKeys.ANGLE.getKey().equals(k) || AnnotationDescription.ZSECTION_STRING.equals(k)
                        || AnnotationDescription.ROIID_STRING.equals(k)
                        || AnnotationDescription.TIME_STRING.equals(k))) {
                    buffer.append(object.getUnits());
                }
                if (AnnotationKeys.AREA.getKey().equals(k)) {
                    buffer = new StringBuffer();
                    object = UIUtilities.transformSquareSize(n.doubleValue());
                    s = twoDecimalPlaces(object.getValue());
                    buffer.append(s);
                    buffer.append(object.getUnits());
                }
                label.setText(buffer.toString());
            }
        } else {
            s = UIUtilities.twoDecimalPlaces(n.doubleValue());
            if (StringUtils.isNotBlank(s)) {
                label.setText(s);
            }
        }
        thisComponent = label;
    } else if (value instanceof FigureType || value instanceof String) {
        thisComponent = makeShapeIcon(label, "" + value);
    } else if (value instanceof Color) {
        label.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
        label.setBackground((Color) value);
        thisComponent = label;
    } else if (value instanceof Boolean) {
        JCheckBox checkBox = new JCheckBox();
        checkBox.setSelected((Boolean) value);
        thisComponent = checkBox;
    } else if (value instanceof ArrayList) {
        thisComponent = createList(value);
        //return list;
    }
    if (!(value instanceof Color)) {
        RendererUtils.setRowColor(thisComponent, table.getSelectedRow(), row);
        if (label != null)
            label.setBackground(thisComponent.getBackground());
    }
    return thisComponent;
}

From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java

/**
 * Builds and lays out the panel hosting the <code>comment</code> details.
 * //from  ww  w .ja  v a 2 s.  c o m
 * @param comment      The comment's text.
 * @param mnemonic       The key-code that indicates a mnemonic key.
 * @return See above.
 */
private JPanel buildCommentAreaPanel(String comment, int mnemonic) {
    JPanel panel = new JPanel();
    panel.setOpaque(false);

    double size[][] = { { TableLayout.FILL }, { 20, TableLayout.FILL } };
    TableLayout layout = new TableLayout(size);
    panel.setLayout(layout);
    JScrollPane areaScrollPane = new JScrollPane(commentArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JLabel label = new JLabel(comment);
    label.setOpaque(false);
    label.setDisplayedMnemonic(mnemonic);
    panel.add(label, "0, 0, LEFT, CENTER");
    panel.add(areaScrollPane, "0, 1");
    return panel;
}

From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java

/**
 * Builds and lays out the panel hosting the <code>email</code> details.
 * /*from ww  w.  ja v a  2  s  . c  o m*/
 * @param mnemonic The key-code that indicates a mnemonic key.
 * @return See above.
 */
private JPanel buildEmailAreaPanel(int mnemonic) {
    double[][] size = null;

    JPanel panel = new JPanel();
    panel.setOpaque(false);

    if (EMAIL_SUFFIX.length() == 0)
        size = new double[][] { { TableLayout.PREFERRED, TableLayout.FILL }, { 30 } };
    else
        size = new double[][] { { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }, { 30 } };

    TableLayout layout = new TableLayout(size);
    panel.setLayout(layout);

    JLabel label = new JLabel(EMAIL_FIELD);
    label.setDisplayedMnemonic(mnemonic);
    label.setLabelFor(emailArea);
    label.setOpaque(false);

    panel.add(label, "0, 0, RIGHT, CENTER");
    panel.add(emailArea, "1, 0, FULL, CENTER");

    if (EMAIL_SUFFIX.length() != 0)
        panel.add(new JLabel(EMAIL_SUFFIX), "2, 0, LEFT, CENTER");

    return panel;
}

From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java

private TableCellRenderer getCellRenderer(final SwingTreeCol col) {

    return new DefaultTableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {

            ColumnType colType = col.getColumnType();
            if (colType == ColumnType.DYNAMIC) {
                colType = ColumnType.valueOf(extractDynamicColType(elements.toArray()[row], column));
            }//from  w  w w  .j  a va 2s.  c  o m

            final XulTreeCell cell = getRootChildren().getItem(row).getRow().getCell(column);
            switch (colType) {
            case CHECKBOX:
                JCheckBox checkbox = new JCheckBox();
                if (value instanceof String) {
                    checkbox.setSelected(((String) value).equalsIgnoreCase("true")); //$NON-NLS-1$
                } else if (value instanceof Boolean) {
                    checkbox.setSelected((Boolean) value);
                } else if (value == null) {
                    checkbox.setSelected(false);
                }
                if (isSelected) {
                    checkbox.setBackground(Color.LIGHT_GRAY);
                }
                checkbox.setEnabled(!cell.isDisabled());
                return checkbox;
            case COMBOBOX:
            case EDITABLECOMBOBOX:
                Vector data;

                final JComboBox comboBox = new JComboBox();
                if (cell == null) {
                } else {
                    data = (cell.getValue() != null) ? (Vector) cell.getValue() : new Vector();

                    if (data == null) {
                        logger.debug("SwingTreeCell combobox data is null, passed in value: " + value); //$NON-NLS-1$
                        if (value instanceof Vector) {
                            data = (Vector) value;
                        }
                    }
                    if (data != null) {
                        comboBox.setModel(new DefaultComboBoxModel(data));
                        try {
                            comboBox.setSelectedIndex(cell.getSelectedIndex());
                        } catch (Exception e) {
                            logger.error("error setting selected index on the combobox editor"); //$NON-NLS-1$
                        }
                    }
                }

                if (colType == ColumnType.EDITABLECOMBOBOX) {
                    comboBox.setEditable(true);
                    ((JTextComponent) comboBox.getEditor().getEditorComponent()).setText(cell.getLabel());
                }

                if (isSelected) {
                    comboBox.setBackground(Color.LIGHT_GRAY);
                }
                comboBox.setEnabled(!cell.isDisabled());
                return comboBox;
            case CUSTOM:
                return new CustomCellEditorWrapper(cell, customEditors.get(col.getType()));
            default:
                JLabel label = new JLabel((String) value);

                if (isSelected) {
                    label.setOpaque(true);
                    label.setBackground(Color.LIGHT_GRAY);
                }
                return label;
            }

        }
    };

}

From source file:org.rdv.ui.ExportDialog.java

private void initComponents(List<String> channels, List<String> fileFormats) {
    channelModel = new DefaultListModel();

    for (int i = 0; i < channels.size(); i++) {
        String channelName = (String) channels.get(i);
        Channel channel = RBNBController.getInstance().getChannel(channelName);

        String mime = channel.getMetadata("mime");

        if (mime.equals("application/octet-stream")) {
            channelModel.addElement(new ExportChannel(channelName));
        }/*from   w  ww .j  a v a 2s.c o m*/
    }

    JPanel container = new JPanel();
    setContentPane(container);

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Select the time range and data channels to export.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    JPanel timeButtonPanel = new JPanel();
    timeButtonPanel.setLayout(new BorderLayout());

    MouseListener hoverMouseListener = new MouseAdapter() {
        public void mouseEntered(MouseEvent e) {
            e.getComponent().setForeground(Color.red);
        }

        public void mouseExited(MouseEvent e) {
            e.getComponent().setForeground(Color.blue);
        }
    };

    startTimeButton = new JButton();
    startTimeButton.setBorder(null);
    startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    startTimeButton.setForeground(Color.blue);
    startTimeButton.addMouseListener(hoverMouseListener);
    startTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double startTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getStart(),
                    timeSlider.getMinimum(), timeSlider.getEnd());
            if (startTime >= 0) {
                timeSlider.setStart(startTime);
            }
        }
    });
    timeButtonPanel.add(startTimeButton, BorderLayout.WEST);

    durationLabel = new JLabel();
    durationLabel.setHorizontalAlignment(JLabel.CENTER);
    timeButtonPanel.add(durationLabel, BorderLayout.CENTER);

    endTimeButton = new JButton();
    endTimeButton.setBorder(null);
    endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    endTimeButton.setForeground(Color.blue);
    endTimeButton.addMouseListener(hoverMouseListener);
    endTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double endTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getEnd(),
                    timeSlider.getStart(), timeSlider.getMaximum());
            if (endTime >= 0) {
                timeSlider.setEnd(endTime);
            }
        }
    });
    timeButtonPanel.add(endTimeButton, BorderLayout.EAST);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 10);
    container.add(timeButtonPanel, c);

    timeSlider = new TimeSlider();
    timeSlider.setValueChangeable(false);
    timeSlider.setValueVisible(false);
    timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() {
        public void timeChanged(TimeEvent event) {
        }

        public void rangeChanged(TimeEvent event) {
            updateTimeRangeLabel();
        }

        public void boundsChanged(TimeEvent event) {
        }
    });
    updateTimeRangeLabel();
    updateTimeBounds();

    List<EventMarker> markers = RBNBController.getInstance().getMarkerManager().getMarkers();
    for (EventMarker marker : markers) {
        timeSlider.addMarker(marker);
    }

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(timeSlider, c);

    JLabel numericHeaderLabel = new JLabel("Data Channels:");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(numericHeaderLabel, c);

    numericChannelList = new JList(channelModel);
    numericChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    numericChannelList.setCellRenderer(new CheckListRenderer());
    numericChannelList.setVisibleRowCount(10);
    numericChannelList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            int index = numericChannelList.locationToIndex(e.getPoint());
            ExportChannel item = (ExportChannel) numericChannelList.getModel().getElementAt(index);
            item.setSelected(!item.isSelected());
            Rectangle rect = numericChannelList.getCellBounds(index, index);
            numericChannelList.repaint(rect);

            checkSelectedChannels();

            updateTimeBounds();
        }
    });
    JScrollPane scrollPane = new JScrollPane(numericChannelList);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    c.weighty = 1;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(scrollPane, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 10, 10, 5);
    container.add(new JLabel("Data file: "), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    dataFileTextField = new JTextField(20);
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(dataFileTextField, c);

    dataFileTextField
            .setText(UIUtilities.getCurrentDirectory().getAbsolutePath() + File.separator + "data.dat");
    dataFileButton = new JButton("Browse");
    dataFileButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            File selectedFile = new File(dataFileTextField.getText());
            selectedFile = UIUtilities.getFile("OK", "Select export file", selectedFile);
            if (selectedFile != null) {
                dataFileTextField.setText(selectedFile.getAbsolutePath());
            }
        }
    });
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 2;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(dataFileButton, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 10, 10, 5);
    container.add(new JLabel("File format: "), c);

    fileFormatComboBox = new JComboBox(fileFormats.toArray());
    fileFormatComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            fileFormatUpdated();
        }
    });
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(fileFormatComboBox, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action exportAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -5356258138620428023L;

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    };
    exportAction.putValue(Action.NAME, "Export");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export");
    actionMap.put("export", exportAction);
    exportButton = new JButton(exportAction);
    panel.add(exportButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -5868609501314154642L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();
    if (getWidth() < 600) {
        setSize(600, getHeight());
    }

    dataFileTextField.requestFocusInWindow();

    setLocationByPlatform(true);
}

From source file:org.rdv.ui.ExportVideoDialog.java

private void initComponents() {

    JPanel container = new JPanel();
    setContentPane(container);// w w  w. j a v a2s . c  o m

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Select the time range and video channels to export.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    JPanel timeButtonPanel = new JPanel();
    timeButtonPanel.setLayout(new BorderLayout());

    MouseListener hoverMouseListener = new MouseAdapter() {
        public void mouseEntered(MouseEvent e) {
            e.getComponent().setForeground(Color.red);
        }

        public void mouseExited(MouseEvent e) {
            e.getComponent().setForeground(Color.blue);
        }
    };

    startTimeButton = new JButton();
    startTimeButton.setBorder(null);
    startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    startTimeButton.setForeground(Color.blue);
    startTimeButton.addMouseListener(hoverMouseListener);
    startTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double startTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getStart(),
                    timeSlider.getMinimum(), timeSlider.getEnd());
            if (startTime >= 0) {
                timeSlider.setStart(startTime);
            }
        }
    });
    timeButtonPanel.add(startTimeButton, BorderLayout.WEST);

    durationLabel = new JLabel();
    durationLabel.setHorizontalAlignment(JLabel.CENTER);
    timeButtonPanel.add(durationLabel, BorderLayout.CENTER);

    endTimeButton = new JButton();
    endTimeButton.setBorder(null);
    endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    endTimeButton.setForeground(Color.blue);
    endTimeButton.addMouseListener(hoverMouseListener);
    endTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double endTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getEnd(),
                    timeSlider.getStart(), timeSlider.getMaximum());
            if (endTime >= 0) {
                timeSlider.setEnd(endTime);
            }
        }
    });
    timeButtonPanel.add(endTimeButton, BorderLayout.EAST);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 10);
    container.add(timeButtonPanel, c);

    timeSlider = new TimeSlider();
    timeSlider.setValueChangeable(false);
    timeSlider.setValueVisible(false);
    timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() {
        public void timeChanged(TimeEvent event) {
        }

        public void rangeChanged(TimeEvent event) {
            updateTimeRangeLabel();
        }

        public void boundsChanged(TimeEvent event) {
        }
    });
    updateTimeRangeLabel();
    updateTimeBounds();

    List<EventMarker> markers = rbnb.getMarkerManager().getMarkers();
    for (EventMarker marker : markers) {
        timeSlider.addMarker(marker);
    }

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(timeSlider, c);

    JLabel numericHeaderLabel = new JLabel("Video Channels:");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(numericHeaderLabel, c);

    videoChannelList = new JList(videoChannelModel);
    videoChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    videoChannelList.setCellRenderer(new CheckListRenderer());
    videoChannelList.setVisibleRowCount(10);
    videoChannelList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            int index = videoChannelList.locationToIndex(e.getPoint());
            ExportChannel item = (ExportChannel) videoChannelList.getModel().getElementAt(index);
            item.setSelected(!item.isSelected());
            Rectangle rect = videoChannelList.getCellBounds(index, index);
            videoChannelList.repaint(rect);

            updateTimeBounds();
        }
    });
    JScrollPane scrollPane = new JScrollPane(videoChannelList);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    c.weighty = 1;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(scrollPane, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 10, 10, 5);
    container.add(new JLabel("Choose Directory: "), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    directoryTextField = new JTextField(20);
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(directoryTextField, c);

    directoryTextField.setText(UIUtilities.getCurrentDirectory().getAbsolutePath());
    directoryButton = new JButton("Browse");
    directoryButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            File selectedDirectory = UIUtilities.getDirectory("Select export directory");
            if (selectedDirectory != null) {
                directoryTextField.setText(selectedDirectory.getAbsolutePath());
            }
        }
    });
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 2;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(directoryButton, c);

    exportProgressBar = new JProgressBar(0, 100000);
    exportProgressBar.setStringPainted(true);
    exportProgressBar.setValue(0);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(exportProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action exportAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 1547500154252213911L;

        public void actionPerformed(ActionEvent e) {
            exportVideo();
        }
    };
    exportAction.putValue(Action.NAME, "Export");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export");
    actionMap.put("export", exportAction);
    exportButton = new JButton(exportAction);
    panel.add(exportButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -7440298547807878651L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();
    if (getWidth() < 600) {
        setSize(600, getHeight());
    }

    directoryTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

From source file:org.rdv.ui.ImportDialog.java

private void initComponents() {
    JPanel container = new JPanel();
    setContentPane(container);//from w w  w .  j a  va  2s. c  o m

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Please specify the desired source name for the data.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 5);
    container.add(new JLabel("Source name: "), c);

    sourceNameTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(10, 0, 10, 10);
    container.add(sourceNameTextField, c);

    importProgressBar = new JProgressBar(0, 100000);
    importProgressBar.setStringPainted(true);
    importProgressBar.setValue(0);
    importProgressBar.setVisible(false);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(importProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action importAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -4719316285523193555L;

        public void actionPerformed(ActionEvent e) {
            importData();
        }
    };
    importAction.putValue(Action.NAME, "Import");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "import");
    actionMap.put("export", importAction);
    importButton = new JButton(importAction);
    getRootPane().setDefaultButton(importButton);
    panel.add(importButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 7909429022904810958L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();

    sourceNameTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

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

private void createAttPanel() {
    GridLayout grid = new GridLayout(4, 1);
    grid.setVgap(8);/* w  w  w  .jav  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.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.java

private JPanel createServerStatus() {
    JPanel serverStatusPanel = new JPanel(new GridBagLayout());

    JLabel serverStatusLabel = new JLabel("Local update: ");
    updateServerButton = new JButton();
    serverStatus = new JLabel();

    final HyperlinkLabel link = new HyperlinkLabel("");
    link.setIcon(AllIcons.General.Help_small);
    link.setUseIconAsLink(true);/* ww w .j a  v  a  2  s  . co m*/
    link.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final JLabel label = new JLabel(
                    "<html>Click to fetch data from the selected SonarQube server, such as the list of projects,<br>"
                            + " rules, quality profiles, etc. This needs to be done before being able to select a project.");
            label.setBorder(HintUtil.createHintBorder());
            label.setBackground(HintUtil.INFORMATION_COLOR);
            label.setOpaque(true);
            HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link),
                    HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
        }
    });

    JPanel flow1 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    flow1.add(serverStatusLabel);
    flow1.add(serverStatus);

    JPanel flow2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    flow2.add(updateServerButton);
    flow2.add(link);

    serverStatusPanel.add(flow1, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0,
            new Insets(0, 0, 0, 0), 0, 0));
    serverStatusPanel.add(flow2, new GridBagConstraints(1, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0,
            new Insets(0, 0, 0, 0), 0, 0));

    updateServerButton.setAction(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            actionUpdateServerTask(false);
        }
    });
    updateServerButton.setText("Update binding");
    updateServerButton.setToolTipText("Update local data: quality profile, settings, ...");

    JPanel alignedPanel = new JPanel(new BorderLayout());
    alignedPanel.add(serverStatusPanel, BorderLayout.NORTH);
    return alignedPanel;
}