本文整理汇总了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);
}
示例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);
}
示例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");
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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));
}