本文整理汇总了Java中java.awt.Font.BOLD属性的典型用法代码示例。如果您正苦于以下问题:Java Font.BOLD属性的具体用法?Java Font.BOLD怎么用?Java Font.BOLD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.Font
的用法示例。
在下文中一共展示了Font.BOLD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: infoErrata
private void infoErrata() {
Font font = new Font("InfoErrataMsg", Font.BOLD, 60);
messInfoCorretta = new JLabel("<html> Nessuna corrispondenza,"
+ "<br>       riprova per favore</html>");
messInfoCorretta.setFont(font);
messInfoCorretta.setForeground(Color.black);
messInfoCorretta.setBounds(this.getWidth() / 2 - 350, 50, 800, 400);
recupero.setText("");
sfondo.add(messInfoCorretta);
sfondo.add(riprova);
sfondo.remove(richiediRecupero);
sfondo.remove(invia);
sfondo.remove(recupero);
sfondo.remove(indietro);
sfondo.repaint();
}
示例2: updateValue
protected void updateValue() {
final int style = Font.PLAIN |
(bold.booleanValue().booleanValue() ? Font.BOLD : 0) |
(italic.booleanValue().booleanValue() ? Font.ITALIC : 0);
final OutlineFont font = new OutlineFont(
(String) family.getSelectedItem(),
style,
Integer.parseInt(size.getValueString()),
outline.booleanValue().booleanValue()
);
setValue(font);
demo.setFont(font);
final Window w = SwingUtilities.getWindowAncestor(getControls());
if (w != null) {
w.pack();
}
}
示例3: MultiplePiePlot
/**
* Creates a new plot.
*
* @param dataset the dataset (<code>null</code> permitted).
*/
public MultiplePiePlot(CategoryDataset dataset) {
super();
this.dataset = dataset;
PiePlot piePlot = new PiePlot(null);
this.pieChart = new JFreeChart(piePlot);
this.pieChart.removeLegend();
this.dataExtractOrder = TableOrder.BY_COLUMN;
this.pieChart.setBackgroundPaint(null);
TextTitle seriesTitle = new TextTitle("Series Title",
new Font("SansSerif", Font.BOLD, 12));
seriesTitle.setPosition(RectangleEdge.BOTTOM);
this.pieChart.setTitle(seriesTitle);
this.aggregatedItemsKey = "Other";
this.aggregatedItemsPaint = Color.lightGray;
this.sectionPaints = new HashMap();
}
示例4: setStyle
protected void setStyle() {
String fName = fullName.toLowerCase();
for (int i=0; i < boldItalicNames.length; i++) {
if (fName.indexOf(boldItalicNames[i]) != -1) {
style = Font.BOLD|Font.ITALIC;
return;
}
}
for (int i=0; i < italicNames.length; i++) {
if (fName.indexOf(italicNames[i]) != -1) {
style = Font.ITALIC;
return;
}
}
for (int i=0; i < boldNames.length; i++) {
if (fName.indexOf(boldNames[i]) != -1 ) {
style = Font.BOLD;
return;
}
}
}
示例5: setFontName
/** Set the font name. */
public void setFontName(String fontName) {
if (log==null) return;
this.fontName = fontName;
log.setFont(new Font(fontName, Font.PLAIN, fontSize));
StyleConstants.setFontFamily(styleRegular, fontName);
StyleConstants.setFontFamily(styleBold, fontName);
StyleConstants.setFontFamily(styleRed, fontName);
StyleConstants.setFontSize(styleRegular, fontSize);
StyleConstants.setFontSize(styleBold, fontSize);
StyleConstants.setFontSize(styleRed, fontSize);
// Changes all existing text
StyledDocument doc=log.getStyledDocument();
Style temp=doc.addStyle("temp", null);
StyleConstants.setFontFamily(temp, fontName);
StyleConstants.setFontSize(temp, fontSize);
doc.setCharacterAttributes(0, doc.getLength(), temp, false);
// Changes all existing hyperlinks
Font newFont = new Font(fontName, Font.BOLD, fontSize);
for(JLabel link: links) { link.setFont(newFont); }
}
示例6: RangeMenu
public RangeMenu( Font2DTest demo, JFrame f ) {
super();
parent = demo;
for ( int i = 0; i < UNICODE_RANGE_NAMES.length; i++ )
addItem( UNICODE_RANGE_NAMES[i] );
setSelectedIndex( 0 );
addActionListener( this );
/// Set up custom range dialog...
customRangeDialog = new JDialog( f, "Custom Unicode Range", true );
customRangeDialog.setResizable( false );
JPanel dialogTop = new JPanel();
JPanel dialogBottom = new JPanel();
JButton okButton = new JButton("OK");
JLabel from = new JLabel( "From:" );
JLabel to = new JLabel("To:");
Font labelFont = new Font( "dialog", Font.BOLD, 12 );
from.setFont( labelFont );
to.setFont( labelFont );
okButton.setFont( labelFont );
dialogTop.add( from );
dialogTop.add( customRangeStart );
dialogTop.add( to );
dialogTop.add( customRangeEnd );
dialogBottom.add( okButton );
okButton.addActionListener( this );
customRangeDialog.getContentPane().setLayout( new BorderLayout() );
customRangeDialog.getContentPane().add( "North", dialogTop );
customRangeDialog.getContentPane().add( "South", dialogBottom );
customRangeDialog.pack();
}
示例7: toStyleDisplayString
public static String toStyleDisplayString(int style) {
switch (style) {
case Font.PLAIN:
return Strings.get("fontPlainStyle");
case Font.ITALIC:
return Strings.get("fontItalicStyle");
case Font.BOLD:
return Strings.get("fontBoldStyle");
case Font.BOLD | Font.ITALIC:
return Strings.get("fontBoldItalicStyle");
default:
return "??";
}
}
示例8: SelectionBar
public SelectionBar()
{
super();
Messenger.register(MT.SERIES_CHANGED, this);
setLayout(new MigLayout("ins 2, center, gap 4"));
setBorder(new BevelBorder(0));
Font f = new Font(Font.DIALOG, Font.BOLD, 14);
eventSelect = new JComboBox<Event>();
eventSelect.setActionCommand("eventChange");
eventSelect.addActionListener(this);
lock = new JCheckBox("Lock");
lock.setActionCommand("lockEvent");
lock.addActionListener(this);
JLabel dl = new JLabel("Series:");
dl.setFont(f);
JLabel el = new JLabel("Event:");
el.setFont(f);
add(dl, "");
add(new CurrentSeriesLabel(), "");
add(el, "gap left 25");
add(eventSelect, "");
add(lock, "");
}
示例9: stampaMsg
private void stampaMsg(String msg, int dimensione) {
Font font = new Font("MsgDaStampare", Font.BOLD, dimensione);
msgDaStampare = new JLabel(msg);
msgDaStampare.setFont(font);
msgDaStampare.setForeground(Color.black);
int strWidth = msgDaStampare.getFontMetrics(font).stringWidth(msg);
msgDaStampare.setBounds(this.getWidth() / 2 - strWidth / 2, this.getHeight() / 2 - 60, strWidth, 90);
sfondo.add(msgDaStampare);
sfondo.repaint();
}
示例10: getFontMetrics
/**
* Returns the font metrics for the styled font.
*/
@SuppressWarnings("deprecation")
public FontMetrics getFontMetrics(Font font) {
if (font == null) {
throw new NullPointerException("font param must not" + " be null");
}
if (font.equals(lastFont) && fontMetrics != null) {
return fontMetrics;
}
lastFont = font;
lastStyledFont = new Font(font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize());
fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont);
return fontMetrics;
}
示例11: createText
public static Element createText(Document doc, Text text) {
Element elt = doc.createElement("text");
Location loc = text.getLocation();
Font font = text.getValue(DrawAttr.FONT);
Color fill = text.getValue(DrawAttr.FILL_COLOR);
Object halign = text.getValue(DrawAttr.ALIGNMENT);
elt.setAttribute("x", "" + loc.getX());
elt.setAttribute("y", "" + loc.getY());
if (!colorMatches(fill, Color.BLACK)) {
elt.setAttribute("fill", getColorString(fill));
}
if (showOpacity(fill)) {
elt.setAttribute("fill-opacity", getOpacityString(fill));
}
elt.setAttribute("font-family", font.getFamily());
elt.setAttribute("font-size", "" + font.getSize());
int style = font.getStyle();
if ((style & Font.ITALIC) != 0) {
elt.setAttribute("font-style", "italic");
}
if ((style & Font.BOLD) != 0) {
elt.setAttribute("font-weight", "bold");
}
if (halign == DrawAttr.ALIGN_LEFT) {
elt.setAttribute("text-anchor", "start");
} else if (halign == DrawAttr.ALIGN_RIGHT) {
elt.setAttribute("text-anchor", "end");
} else {
elt.setAttribute("text-anchor", "middle");
}
elt.appendChild(doc.createTextNode(text.getText()));
return elt;
}
示例12: dotStyleStr
private static String dotStyleStr(int num) {
switch(num){
case Font.BOLD:
return ".bold";
case Font.ITALIC:
return ".italic";
case Font.ITALIC | Font.BOLD:
return ".bolditalic";
default:
return ".plain";
}
}
示例13: getFont
public Font2D getFont(int style) {
switch (style) {
case Font.PLAIN:
return plain;
case Font.BOLD:
if (bold != null) {
return bold;
} else if (plain != null && plain.canDoStyle(style)) {
return plain;
} else {
return null;
}
case Font.ITALIC:
if (italic != null) {
return italic;
} else if (plain != null && plain.canDoStyle(style)) {
return plain;
} else {
return null;
}
case Font.BOLD|Font.ITALIC:
if (bolditalic != null) {
return bolditalic;
} else if (bold != null && bold.canDoStyle(style)) {
return bold;
} else if (italic != null && italic.canDoStyle(style)) {
return italic;
} else if (plain != null && plain.canDoStyle(style)) {
return plain;
} else {
return null;
}
default:
return null;
}
}
示例14: getClosestStyle
Font2D getClosestStyle(int style) {
switch (style) {
/* if you ask for a plain font try to return a non-italic one,
* then a italic one, finally a bold italic one */
case Font.PLAIN:
if (bold != null) {
return bold;
} else if (italic != null) {
return italic;
} else {
return bolditalic;
}
/* if you ask for a bold font try to return a non-italic one,
* then a bold italic one, finally an italic one */
case Font.BOLD:
if (plain != null) {
return plain;
} else if (bolditalic != null) {
return bolditalic;
} else {
return italic;
}
/* if you ask for a italic font try to return a bold italic one,
* then a plain one, finally an bold one */
case Font.ITALIC:
if (bolditalic != null) {
return bolditalic;
} else if (plain != null) {
return plain;
} else {
return bold;
}
case Font.BOLD|Font.ITALIC:
if (italic != null) {
return italic;
} else if (bold != null) {
return bold;
} else {
return plain;
}
}
return null;
}
示例15: paintComponent
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if(this.code == null || this.code.length() != this.codeLength) {
this.code = generateCode();
}
width = this.codeLength * 16 + (this.codeLength - 1) * 10;
super.setSize(width, height);
super.setPreferredSize(new Dimension(width, height));
Font mFont = new Font("Arial", Font.BOLD | Font.ITALIC, 25);
g.setFont(mFont);
//���Ƴ���֤��ı����ľ�������
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(getRandColor(200, 250));
g2d.fillRect(0, 0, width, height);
g2d.setColor(getRandColor(180, 200));
g2d.drawRect(0, 0, width - 1, height - 1);
//���Ƴ���֤�뱳������
int i = 0, len = 150;
for (; i < len; i++) {
int x = random.nextInt(width - 1);
int y = random.nextInt(height - 1);
int x1 = random.nextInt(width - 10) + 10;
int y1 = random.nextInt(height - 4) + 4;
g2d.setColor(getRandColor(180, 200));
g2d.drawLine(x, y, x1, y1);
}
/*i = 0; len = 300;
for (; i < len; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
g2d.setColor(getRandColor(150, 180));
g2d.drawRect(x, y, 0, 0);
}*/
//���Ƴ���֤��ľ�����ĸ
i = 0; len = this.codeLength;
FontMetrics fm = g2d.getFontMetrics();
int base = (height - fm.getHeight())/2 + fm.getAscent();
for(;i<len;i++) {
int b = random.nextBoolean() ? 1 : -1;
g2d.rotate(random.nextInt(10)*0.01*b);
g2d.setColor(getRandColor(20, 130));
g2d.drawString(code.charAt(i)+"", 16 * i + 10, base);
}
}