当前位置: 首页>>代码示例>>Java>>正文


Java JLabel.getClientProperty方法代码示例

本文整理汇总了Java中javax.swing.JLabel.getClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.getClientProperty方法的具体用法?Java JLabel.getClientProperty怎么用?Java JLabel.getClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JLabel的用法示例。


在下文中一共展示了JLabel.getClientProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processText

import javax.swing.JLabel; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:QueryTableCellRenderer.java

示例2: switchCard

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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);

}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:35,代码来源:CardPanel.java

示例3: testCustomLAF

import javax.swing.JLabel; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:bug6302464.java

示例4: mouseEntered

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:19,代码来源:CardListener.java

示例5: mouseExited

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:20,代码来源:CardListener.java

示例6: getToX

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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;

}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:14,代码来源:CardListener.java

示例7: getLabelLayer

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:13,代码来源:CardPanel.java

示例8: getPreferredSize

import javax.swing.JLabel; //导入方法依赖的package包/类
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));
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:16,代码来源:HTMLTableHeader.java


注:本文中的javax.swing.JLabel.getClientProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。