Java Code Examples for javax.swing.JLabel.putClientProperty()

The following are Jave code examples for showing how to use putClientProperty() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: bug6302464.java   View Source Code Vote up 7 votes
private static HashSet getAntialiasedColors(Object aaHint, int lcdContrast) {

        JLabel label = new JLabel("ABCD");
        label.setSize(label.getPreferredSize());
        label.putClientProperty(KEY_TEXT_ANTIALIASING, aaHint);
        label.putClientProperty(KEY_TEXT_LCD_CONTRAST, lcdContrast);

        int w = label.getWidth();
        int h = label.getHeight();

        BufferedImage buffImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = buffImage.createGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, w, h);
        label.paint(g);
        g.dispose();

        HashSet<Color> colors = new HashSet<>();

        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                Color color = new Color(buffImage.getRGB(i, j));
                colors.add(color);
            }
        }

        return colors;
    }
 
Example 2
Project: rapidminer   File: OnboardingDialog.java   View Source Code Vote up 6 votes
static JPanel createSimpleHeader(String caption) {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setOpaque(false);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0D;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.anchor = 17;
    JLabel lbHeadLine = new JLabel(caption);
    lbHeadLine.putClientProperty("com.rapidminer.ui.label.type", "header");
    panel.add(lbHeadLine, gbc);
    ++gbc.gridx;
    gbc.weightx = 0.0D;
    JLabel lbLogoIcon = new JLabel(HEADER_ICON);
    panel.add(lbLogoIcon, gbc);
    return panel;
}
 
Example 3
Project: Progetto-B   File: CardPanel.java   View Source Code Vote up 6 votes
/**
 * If a card has the choosen attribute(so it is among the choosen ones) it
 * removes it from the list of the choosen cards and it adds it to the
 * selectable one. If the card hasn't that attribute it removes it from the
 * selectable ones and ot adds it to the choosen one; if the choosen cards
 * form a tris it is a valid one, it sets true the visibility of the button
 * <code>playTris</code>.
 *
 * @param label
 */
public void switchCard(JLabel label) {
    boolean chosen = (boolean) label.getClientProperty("chosen");
    if (chosen) {
        chosenCards.remove(label);
        cards.add(label);
        cardsPane.setLayer(label, -(getNrCards() - 1));

    } else {

        chosenCards.add(label);
        cards.remove(label);
        cardsPane.setLayer(label, -(getNrChosenCards() - 1));
    }
    if (checkOnTris(chosenCards)) {
        int bonus = game.getBonusForTris(getTrisAsString(chosenCards));
        playTris.setText("Gioca il tris. (" + bonus + ")");
        playTris.setVisible(true);
    } else {
        playTris.setVisible(false);
    }

    label.putClientProperty("chosen", !chosen);

}
 
Example 4
Project: incubator-netbeans   File: StatusBar.java   View Source Code Vote up 5 votes
public void setText(String cellName, String text, Coloring extraColoring, int importance) {
    JLabel cell = getCellByName(cellName);
    if (cell != null) {
        cell.setText(text);
        if (visible) {
            JTextComponent jtc = editorUI.getComponent();
            Coloring c = jtc != null ? getColoring(
                org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(jtc),
                FontColorNames.STATUS_BAR_COLORING
            ) : null;

            if (c != null && extraColoring != null) {
                c = extraColoring.apply(c);
            } else if (c == null) {
                c = extraColoring;
            }
            if (CELL_POSITION.equals(cellName)){
                cell.setToolTipText(caretPositionLocaleString);
            } else if (CELL_TYPING_MODE.equals(cellName)) {
                cell.setToolTipText(insText.equals(text)? insertModeLocaleString : overwriteModeLocaleString);
            } else {
                cell.setToolTipText(text == null || text.length() == 0 ? null : text);
            }

            if (c != null && cell instanceof Cell) {
                applyColoring((Cell) cell, c);
            }
        } else { // Status bar not visible => use global status bar if possible
            JLabel globalCell = cellName2GlobalCell.get(cellName);
            if (globalCell != null) {
                if (CELL_MAIN.equals(cellName)) {
                    globalCell.putClientProperty("importance", importance);
                }
                globalCell.setText(text);
            }
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: QueryTableCellRenderer.java   View Source Code Vote up 5 votes
public void setStyleProperties(JLabel renderer, TableCellStyle style) {
    if (style != null) {
        renderer.putClientProperty(PROPERTY_FORMAT, style.format); // NOI18N
        renderer.putClientProperty(PROPERTY_HIGHLIGHT_PATTERN, style.highlightPattern); // NOI18N
        ((JComponent) renderer).setToolTipText(style.tooltip);
        setRowColors(style, renderer);
    }
}
 
Example 6
Project: openjdk-jdk10   File: bug6302464.java   View Source Code Vote up 5 votes
private static void testFontRenderingContext(Object aaHint) {

        JLabel label = new JLabel("Test");
        label.putClientProperty(KEY_TEXT_ANTIALIASING, aaHint);
        FontRenderContext frc = label.getFontMetrics(
                label.getFont()).getFontRenderContext();

        if (!aaHint.equals(frc.getAntiAliasingHint())) {
            throw new RuntimeException("Wrong aa hint in FontRenderContext");
        }
    }
 
Example 7
Project: incubator-netbeans   File: EditableDisplayerTest.java   View Source Code Vote up 4 votes
public Component getCustomEditor() {
    JLabel result = new JLabel("Everything is exactly as it should be.  Relax.");
    result.putClientProperty("title","Don't panic");
    return result;
}