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

The following are Jave code examples for showing how to use getClientProperty() 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: incubator-netbeans   File: QueryTableCellRenderer.java   View Source Code Vote up 6 votes
public static void processText(JLabel label) {
    MessageFormat format = (MessageFormat) label.getClientProperty(PROPERTY_FORMAT);     // NOI18N
    Pattern pattern = (Pattern) label.getClientProperty(PROPERTY_HIGHLIGHT_PATTERN);     // NOI18N
    String s = computeFitText(label);
    if(format != null || pattern != null) {
        StringBuffer sb = new StringBuffer();
        sb.append("<html>");                                                // NOI18N
        s = TextUtils.escapeForHTMLLabel(s);
        if(format != null) {
            format.format(new Object[] {s}, sb, null);
        }
        if(pattern != null) {
            sb.append(highLight(s, pattern));
        }
        sb.append("</html>");                                               // NOI18N
        s = sb.toString();
    } 
    label.setText(s);
}
 
Example 2
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 3
Project: openjdk-jdk10   File: bug6302464.java   View Source Code Vote up 6 votes
private static void testCustomLAF(boolean useAAHints) throws Exception {
    CustomLookAndFeel customLAF = new CustomLookAndFeel(useAAHints);
    UIManager.setLookAndFeel(customLAF);

    JLabel label = new JLabel();
    Object aaHint = label.getClientProperty(KEY_TEXT_ANTIALIASING);
    Object lcdContrastHint = label.getClientProperty(KEY_TEXT_LCD_CONTRAST);

    if (aaHint != customLAF.getAAHint()) {
        throw new RuntimeException("AA hint from custom L&F is not set");
    }

    if (lcdContrastHint != customLAF.getLCDContarstHint()) {
        throw new RuntimeException("AA hint from custom L&F is not set");
    }
}
 
Example 4
Project: Progetto-B   File: CardListener.java   View Source Code Vote up 5 votes
/**
 * When the cursor hovers over a card, the card is moved to the front.
 *
 * @param e
 */
@Override
public void mouseEntered(MouseEvent e) {
    if (game.getPhase().equals(PLAY_CARDS)) {
        JLabel label = (JLabel) e.getComponent();
        cardPanel.getCardsPane().setLayer(label, 1);
        String card = (String) label.getClientProperty("name");
        label.setIcon(new ImageIcon("src/resources/images/" + card + "_BLACK.png"));
        Point p = label.getLocation();
        Point p1 = new Point(p.x, HIGH_Y);
        label.setLocation(p1);
        cardPanel.updateUI();
    }
}
 
Example 5
Project: Progetto-B   File: CardListener.java   View Source Code Vote up 5 votes
/**
 * When the cursor exits a card, the card is moved back to its original
 * depth.
 *
 * @param e
 */
@Override
public void mouseExited(MouseEvent e) {
    if (game.getPhase().equals(PLAY_CARDS)) {
        JLabel label = (JLabel) e.getComponent();
        cardPanel.getCardsPane().setLayer(label, cardPanel.getLabelLayer(label));
        String card = (String) label.getClientProperty("name");
        label.setIcon(new ImageIcon("src/resources/images/" + card + ".png"));
        Point p = label.getLocation();
        Point p1 = new Point(p.x, LOW_Y);
        label.setLocation(p1);
        cardPanel.updateUI();
    }
}
 
Example 6
Project: Progetto-B   File: CardListener.java   View Source Code Vote up 5 votes
/**
 * Returns the final position for the movement of a card.
 *
 * @param label
 * @return
 */
private int getToX(JLabel label) {
    if ((boolean) label.getClientProperty("chosen")) {
        return X_OFFSET + HOR_OVERLAP * cardPanel.getNrCards();
    }
    return CHOSEN_OFFSET + cardPanel.getNrChosenCards() * HOR_OVERLAP;

}
 
Example 7
Project: Progetto-B   File: CardPanel.java   View Source Code Vote up 5 votes
/**
 * Returns the layer in which the JLabel is.
 *
 * @param label
 * @return
 */
public int getLabelLayer(JLabel label) {
    if ((boolean) label.getClientProperty("chosen")) {
        return -chosenCards.indexOf(label);
    }
    return -cards.indexOf(label);
}
 
Example 8
Project: ramus   File: HTMLTableHeader.java   View Source Code Vote up 3 votes
public static java.awt.Dimension getPreferredSize(String text,
                                                  boolean width, int prefSize) {

    JLabel resizer = new JLabel(text);

    View view = (View) resizer
            .getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);

    view.setSize(width ? prefSize : 0, width ? 0 : prefSize);

    float w = view.getPreferredSpan(View.X_AXIS);
    float h = view.getPreferredSpan(View.Y_AXIS) + 2;

    return new java.awt.Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}