Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

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 . ja  v  a2 s .  c om*/
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.optaconf.benchmark.examples.common.swingui.SolverAndPersistenceFrame.java

private JComponent createQuickOpenPanel() {
    JPanel quickOpenPanel = new JPanel(new BorderLayout());
    JLabel quickOpenLabel = new JLabel("Quick open");
    quickOpenLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    quickOpenPanel.add(quickOpenLabel, BorderLayout.NORTH);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createQuickOpenUnsolvedPanel(),
            createQuickOpenSolvedPanel());
    splitPane.setResizeWeight(0.8);//  w w  w  .j av a 2 s  .  c om
    splitPane.setBorder(null);
    quickOpenPanel.add(splitPane, BorderLayout.CENTER);
    return quickOpenPanel;
}

From source file:org.owasp.jbrofuzz.update.StartUpdateChecker.java

/**
 * <p>/*from  ww  w.jav a2  s . co  m*/
 * Main constructor that displays a JDialog if a new version is identified
 * on the website.</p.
 * 
 * @param parent
 *            JBroFuzzwindow the main window
 * 
 * @author subere@uncon.org
 * @version 1.7
 * @since 1.3
 */
protected StartUpdateChecker(final JBroFuzzWindow parent) {

    super(parent, " JBroFuzz - New Version Available ", true);

    // Version comparison to see if we will display or dispose
    final double latest = StartUpdateChecker.getWebsiteVersion();
    if (latest == StartUpdateChecker.ZERO_VERSION) {
        StartUpdateChecker.this.dispose();
        return;
    }

    double current;
    try {
        current = Double.parseDouble(JBroFuzzFormat.VERSION);
    } catch (final NumberFormatException e1) {
        current = StartUpdateChecker.ZERO_VERSION;
    }
    if (latest <= current) {
        StartUpdateChecker.this.dispose();
        return;
    }

    final String text = "<html><b>A new version of JBroFuzz is available:&nbsp;" + latest
            + "<br><br>You are currently running version:&nbsp;" + current
            + "<br><br>Do you wish to download the <br>new version now?" + "</b></html>";

    setIconImage(ImageCreator.IMG_FRAME.getImage());

    setLayout(new BorderLayout());
    setFont(new Font("Verdana", Font.PLAIN, 12));

    final JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 15));
    final JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 15));

    // The about editor label
    final JLabel mainLabel = new JLabel(text, ImageCreator.IMG_OWASP, SwingConstants.LEFT);
    mainLabel.setIconTextGap(20);
    mainLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));

    centerPanel.add(mainLabel);

    // Bottom buttons
    final JButton download = new JButton("Download");
    final JButton close = new JButton("Close");
    southPanel.add(download);
    southPanel.add(close);

    // Action Listeners

    download.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent even) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    Browser.init();
                    try {
                        Browser.displayURL(JBroFuzzFormat.URL_WEBSITE);
                    } catch (final IOException e) {
                        System.out.println("An IOException occurred.");
                    }
                    StartUpdateChecker.this.dispose();
                }
            });

        }
    });

    close.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent even) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    StartUpdateChecker.this.dispose();
                }
            });

        }
    });

    // Add the panels to the dialog

    getContentPane().add(centerPanel, BorderLayout.CENTER);
    getContentPane().add(southPanel, BorderLayout.SOUTH);

    // Global frame issues
    final int xLocation = parent.getLocationOnScreen().x - (StartUpdateChecker.SIZE_X / 2)
            + (parent.getWidth() / 2);
    final int yLocation = parent.getLocationOnScreen().y - (StartUpdateChecker.SIZE_Y / 2)
            + (parent.getHeight() / 2);

    setSize(StartUpdateChecker.SIZE_X, StartUpdateChecker.SIZE_Y);
    setLocation(xLocation, yLocation);

    setMinimumSize(new Dimension(StartUpdateChecker.SIZE_X, StartUpdateChecker.SIZE_Y));
    setResizable(true);
    setVisible(true);

}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.dialogs.RepositoryTreeDialog.java

/**
 * @noinspection ReuseOfLocalVariable//from www .  ja v a2  s  .co  m
 */
protected Component createContentPane() {
    final JScrollPane treeView = new JScrollPane(repositoryBrowser);
    final JPanel newFolderButtonPanel = new JPanel(new BorderLayout());

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    if (addNewButtonPanel) {
        final JButton newFolder = new JButton(new NewFolderAction());
        newFolder.setBorder(BorderFactory.createEmptyBorder());
        final JLabel label = new JLabel(
                Messages.getInstance().getString("SolutionRepositoryTreeDialog.SelectLocation"));
        label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
        newFolderButtonPanel.add(label, BorderLayout.CENTER);
        newFolderButtonPanel.add(newFolder, BorderLayout.EAST);

        c.insets = new Insets(2, 10, 0, 10);
        c.anchor = GridBagConstraints.WEST;
        c.gridx = 0;
        c.gridy = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        panel.add(newFolderButtonPanel, c);
    }

    c = new GridBagConstraints();
    c.insets = new Insets(0, 10, 5, 10);
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    panel.add(treeView, c);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 10, 5, 10);
    c.gridx = 0;
    c.gridy = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    panel.add(new JCheckBox(new ShowHiddenFilesAction()));
    return panel;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.commonswing.ExceptionDialog.java

private void init() {
    messages = new Messages(getLocale(), SwingCommonModule.BUNDLE_NAME,
            ObjectUtilities.getClassLoader(SwingCommonModule.class));
    setModal(true);/*from  w  w  w.jav  a2s  .  com*/
    detailsAction = new DetailsAction();

    messageLabel = new JLabel();
    backtraceArea = new JTextArea();

    scroller = new JScrollPane(backtraceArea);
    scroller.setVisible(false);

    final JPanel detailPane = new JPanel();
    detailPane.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    final JLabel icon = new JLabel(UIManager.getDefaults().getIcon("OptionPane.errorIcon")); //$NON-NLS-1$
    icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    detailPane.add(icon, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.gridx = 1;
    gbc.gridy = 0;
    detailPane.add(messageLabel);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    detailPane.add(createButtonPane(), gbc);

    filler = new JPanel();
    filler.setPreferredSize(new Dimension(0, 0));
    filler.setBackground(Color.green);
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.weighty = 5;
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 2;
    detailPane.add(filler, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.weighty = 5;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    detailPane.add(scroller, gbc);

    setContentPane(detailPane);
}

From source file:org.rdv.datapanel.AbstractDataPanel.java

JComponent getDescriptionComponent() {
    JLabel descriptionLabel = new JLabel(description);
    descriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(Font.BOLD));
    descriptionLabel.setForeground(Color.white);
    return descriptionLabel;
}

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 .  ja 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 ava  2  s.  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  www .  j a  v a 2 s .c  om

    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 .  ja  va 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);
}