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:components.LayeredPaneDemo2.java

private JLabel createColoredLabel(String text, Color color) {
    JLabel label = new JLabel(text);
    label.setVerticalAlignment(JLabel.TOP);
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setOpaque(true);//  w  w w.  j  av a2s  .  c  o m
    label.setBackground(color);
    label.setForeground(Color.black);
    label.setBorder(BorderFactory.createLineBorder(Color.black));
    label.setPreferredSize(new Dimension(140, 140));
    return label;
}

From source file:net.nosleep.superanalyzer.analysis.views.SummaryView.java

private void addStatTriple(JPanel panel, StringTriple triple) {

    JLabel wordLabel = new JLabel(triple.Name + ": ");
    wordLabel.setOpaque(false);/*from ww w.  j a v  a 2  s.co  m*/
    wordLabel.setFont(Theme.getFont(12));
    wordLabel.setHorizontalAlignment(JLabel.RIGHT);
    panel.add(wordLabel);

    JLabel wordField = new JLabel();
    wordField.setOpaque(false);
    wordField.setFont(Theme.getBoldFont(12));
    wordField.setBorder(new javax.swing.border.EmptyBorder(1, 1, 1, 1));
    wordField.setForeground(Theme.getColorSet()[0]);
    panel.add(wordField);

    wordField.setText(triple.Value);
    wordField.setToolTipText(Misc.getTooltip(triple.Info));
}

From source file:de.codesourcery.eve.skills.ui.utils.CalendarWidget.java

protected void setup() {

    // draw heading
    for (int x = 0; x < 7; x++) {
        final String day = getWeekDayName(getDateFor(x, 0));
        final JLabel label = new JLabel(day, JLabel.CENTER);
        label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        label.setOpaque(true);//from  w  w  w. ja  va2  s  .co  m
        add(label, new ConstraintsBuilder(x, 0).resizeHorizontally().weightY(0).end());
    }

    // draw 4x7 buttons
    for (int y = 0; y < 4; y++) {
        for (int x = 0; x < 7; x++) {
            buttons[y][x] = new MyButton(x, y);
            add(buttons[y][x], new ConstraintsBuilder(x, 1 + y).end());
        }
    }
}

From source file:MatteExample.java

public MatteExample() {
    super(true);//from   ww  w. j av  a  2  s .  c o  m
    this.setLayout(new GridLayout(1, 2, 5, 5));

    JLabel label1 = new JLabel("Matte Border");
    JLabel label2 = new JLabel("Matte Border (Icon)");

    label1.setHorizontalAlignment(JLabel.CENTER);
    label2.setHorizontalAlignment(JLabel.CENTER);

    Icon icon = new ImageIcon("yourFile.gif");
    MatteBorder matte = new MatteBorder(35, 35, 35, 35, Color.blue);
    MatteBorder matteicon = new MatteBorder(35, 35, 35, 35, icon);
    label1.setBorder(matte);
    label2.setBorder(matteicon);

    add(label1);
    add(label2);
}

From source file:de.iew.imageupload.widgets.ContentPane.java

public void registerImageFile(File file) {
    try {/*w  w  w  . j  a v  a 2  s  .co  m*/
        ImageIcon imageIcon = new ImageIcon(file.getAbsolutePath());
        JLabel imageLabel = new JLabel(imageIcon, JLabel.CENTER);
        imageLabel.setPreferredSize(new Dimension(100, 100));
        imageLabel.setSize(new Dimension(100, 100));
        imageLabel.addMouseListener(this.imageMouseClickHandler);
        imageLabel.setBackground(Color.WHITE);
        imageLabel.setBorder(new EmptyBorder(10, 10, 10, 10));
        imageLabel.putClientProperty("Image File", file);

        this.imageGridPane.add(imageLabel);
        this.imageGridPane.revalidate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * Create the panel./*from  ww  w .j  av  a2  s  .  c  om*/
 * 
 * @param title the title of the message panel
 * @param routeMessage the request message
 * @param routeChanges the route changes
 * @param the index of the message with 0 being the latest
 */
public StrategicNotificationMessageView(String title, StrategicRouteMessage routeMessage, String routeChanges,
        int index) {

    super(new GridBagLayout());

    boolean isLatest = index == 0;
    if (!isLatest) {
        setBackground(Color.darkGray);
    }

    Insets insets0 = new Insets(0, 0, 0, 0);
    Insets insets1 = new Insets(5, 5, 5, 5);

    // *************************
    // Create the title panel
    // *************************
    JPanel titlePanel = new JPanel(new GridBagLayout());
    add(titlePanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets0, 0, 0));

    // Title
    if (isLatest) {
        titlePanel.setBackground(titlePanel.getBackground().darker());
    }
    titlePanel.add(bold(new JLabel(title)),
            new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0));
    titlePanel.add(new JLabel(Formatter.formatLongDateTime(routeMessage.getSentDate())),
            new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, EAST, NONE, insets1, 0, 0));

    // Type
    CloudMessageStatus cloudStatus = isLatest ? routeMessage.getCloudMessageStatus() : null;
    add(new JLabel("Status:"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));
    add(new JLabel(StrategicRouteNotificationDetailPanelCommon.getStatusType(routeMessage.getStatus(),
            cloudStatus, false)), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));

    // Message label
    if (!StringUtils.isBlank(routeMessage.getMessage())) {
        JLabel msgLabel = new JLabel("<html>" + Formatter.formatHtml(routeMessage.getMessage()) + "</html>");
        msgLabel.setBorder(new TitledBorder("Message"));
        add(msgLabel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0));
    }

    // Route changes
    if (!StringUtils.isBlank(routeChanges)) {
        JLabel routeLabel = new JLabel("<html>" + Formatter.formatHtml(routeChanges) + "</html>");
        routeLabel.setBorder(new TitledBorder("Route changes"));
        add(routeLabel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0));
    }
}

From source file:JXButtonPanel.java

private JPanel createButtonJXButtonPanel() {
    JPanel ret = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Does JXButtonPanel support arrow keys ?");
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    JPanel temp = new JPanel();
    temp.add(label);/*from ww w.jav a2  s  .c o  m*/
    ret.add(temp);

    JXButtonPanel panel = new JXButtonPanel();
    panel.setCyclic(true);
    panel.add(new JButton("Yes"));
    panel.add(new JButton("Sure"));
    panel.add(new JButton("Absolutely !"));
    panel.setBorder(BorderFactory.createTitledBorder(null, "JXButtonPanel.setCyclic(true)", TitledBorder.CENTER,
            TitledBorder.BOTTOM));
    ret.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));

    ret.add(panel, BorderLayout.SOUTH);
    return ret;
}

From source file:org.eobjects.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java

@Override
public JComponent render(DateGapAnalyzerResult result) {

    final TaskSeriesCollection dataset = new TaskSeriesCollection();
    final Set<String> groupNames = result.getGroupNames();
    final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION);
    final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS);
    final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS);
    for (final String groupName : groupNames) {
        final String groupDisplayName;

        if (groupName == null) {
            if (groupNames.size() == 1) {
                groupDisplayName = "All";
            } else {
                groupDisplayName = LabelUtils.NULL_LABEL;
            }/*  ww  w.j a v a2  s . c  o m*/
        } else {
            groupDisplayName = groupName;
        }

        final TimeInterval completeDuration = result.getCompleteDuration(groupName);
        final Task completeDurationTask = new Task(groupDisplayName,
                createTimePeriod(completeDuration.getFrom(), completeDuration.getTo()));
        completeDurationTaskSeries.add(completeDurationTask);

        // plot gaps
        {
            final SortedSet<TimeInterval> gaps = result.getGaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : gaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    gapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " gap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }

        // plot overlaps
        {
            final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : overlaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    overlapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " overlap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }
    }
    dataset.add(overlapsTaskSeries);
    dataset.add(gapsTaskSeries);
    dataset.add(completeDurationTaskSeries);

    final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0,
            GROUPS_VISIBLE);

    final JFreeChart chart = ChartFactory.createGanttChart(
            "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(),
            result.getGroupColumnName(), "Time", slidingDataset, true, true, false);
    ChartUtils.applyStyles(chart);

    // make sure the 3 timeline types have correct coloring
    {
        final CategoryPlot plot = (CategoryPlot) chart.getPlot();

        plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT,
                WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT));
    }

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            ChartEntity entity = event.getEntity();
            if (entity instanceof PlotEntity) {
                cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
            }
            chartPanel.setCursor(cursor);
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // do nothing
        }
    });

    final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size());

    chartPanel.setPreferredSize(new Dimension(0, visibleLines * 50 + 200));

    final JComponent decoratedChartPanel;

    StringBuilder chartDescription = new StringBuilder();
    chartDescription
            .append("<html><p>The chart displays the recorded timeline based on FROM and TO dates.<br/><br/>");
    chartDescription.append(
            "The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.<br/><br/>");
    chartDescription.append(
            "You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail.");

    if (groupNames.size() > GROUPS_VISIBLE) {
        final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL);
        scroll.setMinimum(0);
        scroll.setMaximum(groupNames.size());
        scroll.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                int value = e.getAdjustable().getValue();
                slidingDataset.setFirstCategoryIndex(value);
            }
        });

        chartPanel.addMouseWheelListener(new MouseWheelListener() {

            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                int scrollType = e.getScrollType();
                if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                    int wheelRotation = e.getWheelRotation();
                    scroll.setValue(scroll.getValue() + wheelRotation);
                }
            }
        });

        final DCPanel outerPanel = new DCPanel();
        outerPanel.setLayout(new BorderLayout());
        outerPanel.add(chartPanel, BorderLayout.CENTER);
        outerPanel.add(scroll, BorderLayout.EAST);
        chartDescription.append("<br/><br/>Use the right <b>scrollbar</b> to scroll up and down on the chart.");
        decoratedChartPanel = outerPanel;

    } else {
        decoratedChartPanel = chartPanel;
    }

    chartDescription.append("</p></html>");

    final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString());

    chartDescriptionLabel.setBorder(new EmptyBorder(4, 10, 4, 10));

    final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(decoratedChartPanel);
    split.add(chartDescriptionLabel);
    split.setDividerLocation(550);

    return split;
}

From source file:components.ButtonTabComponent.java

public ButtonTabComponent(final JTabbedPane pane) {
    //unset default FlowLayout' gaps
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    if (pane == null) {
        throw new NullPointerException("TabbedPane is null");
    }// w w w .j  a  v  a2s . c om
    this.pane = pane;
    setOpaque(false);

    //make JLabel read titles from JTabbedPane
    JLabel label = new JLabel() {
        public String getText() {
            int i = pane.indexOfTabComponent(ButtonTabComponent.this);
            if (i != -1) {
                return pane.getTitleAt(i);
            }
            return null;
        }
    };

    add(label);
    //add more space between the label and the button
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    //tab button
    JButton button = new TabButton();
    add(button);
    //add more space to the top of the component
    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

private Component getNewServerServer(final JList list, final int index, final boolean isSelected) {
    final JPanel p = createServerPanel(null, list, index, isSelected);
    final JLabel label = new JLabel("Start a new server",
            new ImageIcon(getClass().getResource("/images/add.png")), SwingConstants.LEFT);
    label.setFont(new Font(label.getFont().getName(), Font.PLAIN, 16));
    // Border for better horizontal alignment
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 12));
    p.add(label);/*from   www. jav  a2  s . com*/

    return p;
}