本文整理汇总了Java中java.awt.Font.getFamily方法的典型用法代码示例。如果您正苦于以下问题:Java Font.getFamily方法的具体用法?Java Font.getFamily怎么用?Java Font.getFamily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Font
的用法示例。
在下文中一共展示了Font.getFamily方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MissingClientPanel
import java.awt.Font; //导入方法依赖的package包/类
/** Creates new form MissingClientPanel */
public MissingClientPanel() {
initComponents();
if(Utilities.isWindows()) {
tipLabel.setText(org.openide.util.NbBundle.getMessage(MissingClientPanel.class, "MissingSvnClientPanel.jLabel1.windows.text")); // NOI18N
} else {
tipLabel.setText(org.openide.util.NbBundle.getMessage(MissingClientPanel.class, "MissingSvnClientPanel.jLabel1.unix.text")); // NOI18N
}
String text = org.openide.util.NbBundle.getMessage(MissingClientPanel.class, "MissingClientPanel.textPane.text"); // NOI18N
textPane.setText(text);
Document doc = textPane.getDocument();
if (doc instanceof HTMLDocument) { // Issue 185505
HTMLDocument htmlDoc = (HTMLDocument)doc;
Font font = UIManager.getFont("Label.font"); // NOI18N
String bodyRule = "body { font-family: " + font.getFamily() + "; " // NOI18N
+ "color: " + SvnUtils.getColorString(textPane.getForeground()) + "; " //NOI18N
+ "font-size: " + font.getSize() + "pt; }"; // NOI18N
htmlDoc.getStyleSheet().addRule(bodyRule);
}
textPane.setOpaque(false);
textPane.setBackground(new Color(0,0,0,0)); // windows and nimbus workaround see issue 145826
}
示例2: styleListValueChanged
import java.awt.Font; //导入方法依赖的package包/类
private void styleListValueChanged(ListSelectionEvent e) {
int style = -1;
String selectedStyle = (String) styleList.getSelectedValue();
if (selectedStyle == PLAIN) {
style = Font.PLAIN;
}
if (selectedStyle == BOLD) {
style = Font.BOLD;
}
if (selectedStyle == ITALIC) {
style = Font.ITALIC;
}
if (selectedStyle == BOLD_ITALIC) {
style = Font.BOLD + Font.ITALIC;
}
font = new Font(font.getFamily(), style, font.getSize());
previewLabel.setFont(font);
}
示例3: JTextPaneTableCellRenderer
import java.awt.Font; //导入方法依赖的package包/类
public JTextPaneTableCellRenderer() {
textPane.setContentType("text/html");
textPane.setEditable(false);
textPane.setOpaque(true);
textPane.setBorder(null);
textPane.setForeground(UIManager.getColor("Table.selectionForeground"));
textPane.setBackground(UIManager.getColor("Table.selectionBackground"));
Font font = UIManager.getFont("Label.font");
String bodyRule =
"body { font-family: " + font.getFamily() + "; " + "font-size: "
+ font.getSize() + "pt; "
+ (font.isBold() ? "font-weight: bold;" : "") + "}";
((HTMLDocument)textPane.getDocument()).getStyleSheet().addRule(bodyRule);
textPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
MainFrame.getInstance().showHelpFrame(e.getURL().toString(), "CREOLE Plugin Manager");
}
});
}
示例4: main
import java.awt.Font; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String os = System.getProperty("os.name");
if (!(os.startsWith("Mac"))) {
return;
}
File fontFile = new File(file);
if (!fontFile.exists()) {
return;
}
Font[] fonts = Font.createFonts(new File(file));
System.out.println("createFont from file returned " + fonts);
if (fonts == null || fonts.length == 0) {
throw new RuntimeException("No fonts");
}
for (Font f : fonts) {
System.out.println(f);
if (!f.getFamily().equals("Menlo"))
throw new RuntimeException("Expected Menlo, got " + f.getFamily());
}
}
示例5: NotifyHtmlPanel
import java.awt.Font; //导入方法依赖的package包/类
/**
* Creates new form SwitchToCliPanel
*/
public NotifyHtmlPanel () {
initComponents();
Document doc = msgPanel.getDocument();
if (doc instanceof HTMLDocument) { // Issue 185505
HTMLDocument htmlDoc = (HTMLDocument)doc;
Font font = UIManager.getFont("Label.font"); // NOI18N
String bodyRule = "body { font-family: " + font.getFamily() + "; " // NOI18N
+ "color: " + SvnUtils.getColorString(msgPanel.getForeground()) + "; " //NOI18N
+ "font-size: " + font.getSize() + "pt; }"; // NOI18N
htmlDoc.getStyleSheet().addRule(bodyRule);
}
msgPanel.setOpaque(false);
msgPanel.setBackground(new Color(0,0,0,0)); // windows and nimbus workaround see issue 145826
}
示例6: setFontSize
import java.awt.Font; //导入方法依赖的package包/类
public void setFontSize(int fontSize) {
this.fontSize = fontSize;
// recalculate font as well.
font = new Font(font.getFamily(),
font.getStyle(),
this.fontSize);
markDirty();
}
示例7: getFontMetrics
import java.awt.Font; //导入方法依赖的package包/类
/**
* 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;
}
示例8: getFontTag
import java.awt.Font; //导入方法依赖的package包/类
private static HTMLTag getFontTag() {
if (fontTag == null) {
Font font = Options.getLabelFont();
String face = font.getFamily();
int size = font.getSize() - 2;
// actually a slightly smaller font is more in line with
// the edge font size, but then the forall symbol is not
// available
String argument = String.format("font-family:%s; font-size:%dpx", face, size);
fontTag = createSpanTag(argument);
}
return fontTag;
}
示例9: put
import java.awt.Font; //导入方法依赖的package包/类
/**
* Converts the value to string using {@link Strings#toString(Object)}
* method and then stores it.
* There is get methods for values that are a String, an Integer, a Boolean,
* a Font, a List of String and a Map of String*String.
*/
@Override
public Object put(Object key, Object value) {
if(value instanceof Font){
Font font = (Font)value;
String family = font.getFamily();
int size = font.getSize();
boolean italic = font.isItalic();
boolean bold = font.isBold();
value = family + "#" + size + "#" + italic + "#" + bold;
}
return super.put(key.toString(), Strings.toString(value));
}
示例10: getFontTableRtf
import java.awt.Font; //导入方法依赖的package包/类
private String getFontTableRtf() {
// Example:
// "{\\fonttbl{\\f0\\fmodern\\fcharset0 Courier;}}"
StringBuilder sb = new StringBuilder();
// Workaround for text areas using the Java logical font "Monospaced"
// by default. There's no way to know what it's mapped to, so we
// just search for a monospaced font on the system.
String monoFamilyName = getMonospacedFontFamily();
sb.append("{\\fonttbl{\\f0\\fnil\\fcharset0 " + monoFamilyName + ";}");
for (int i=0; i<fontList.size(); i++) {
Font f = fontList.get(i);
String familyName = f.getFamily();
if (familyName.equals("Monospaced")) {
familyName = monoFamilyName;
}
sb.append("{\\f").append(i+1).append("\\fnil\\fcharset0 ");
sb.append(familyName).append(";}");
}
sb.append('}');
return sb.toString();
}
示例11: main
import java.awt.Font; //导入方法依赖的package包/类
public static void main(String [] args) {
System.setProperty("sun.java2d.debugfonts", "true");
Font font = new Font("dialog", Font.PLAIN, 14);
System.out.println(font);
String s1 = font.getFamily();
String s2 = font.getFontName();
}
示例12: lstStyleValueChanged
import java.awt.Font; //导入方法依赖的package包/类
private void lstStyleValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstStyleValueChanged
int style = -1;
String selStyle = (String)lstStyle.getSelectedValue();
if(selStyle=="Plain")
style = Font.PLAIN;
if(selStyle=="Bold")
style = Font.BOLD;
if(selStyle=="Italic")
style = Font.ITALIC;
if(selStyle=="Bold Italic")
style = Font.BOLD + Font.ITALIC;
font = new Font(font.getFamily(),style,font.getSize());
lblPreview.setFont(font);
}
示例13: makeEditorPane
import java.awt.Font; //导入方法依赖的package包/类
/**
* Create a JEditorPane that will convert the text into html with working hyperlinks.
* This can be included in a messageDialog with, e.g.
* JOptionPane.showMessageDialog(null, ep)
* @param text
* @return
*/
public static JEditorPane makeEditorPane(String text) {
// for copying style
JLabel label = new JLabel();
Font font = label.getFont();
// create some css from the label's font
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
style.append("font-size:" + font.getSize() + "pt;");
//need to use editor pane and hyperlink listener so that we can include hyperlinks in help text
JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
+ text //
+ "</body></html>");
ep.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
BrowseURL.browseURL(e.getURL().toString());
}
});
ep.setEditable(false);
ep.setBackground(label.getBackground());
return ep;
}
示例14: toStandardString
import java.awt.Font; //导入方法依赖的package包/类
@Override
public String toStandardString(Font f) {
return f.getFamily() + " " + FontUtil.toStyleStandardString(f.getStyle()) + " " + f.getSize();
}
示例15: showErrorMessage
import java.awt.Font; //导入方法依赖的package包/类
private void showErrorMessage() {
// for copying style
JLabel label = new JLabel();
Font font = label.getFont();
// create some css from the label's font
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
style.append("font-size:" + font.getSize() + "pt;");
JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">"//
+ "TextToSpeech executable not found."
+ "<br>Please make sure that the path variable leads to the espeak executable!"
+ "<br>If you do not have espeak installed yet, please download it from <a href=http://espeak.sourceforge.net\">http://espeak.sourceforge.net</a>."
+ "<br>Linux users can use the following command: 'sudo apt-get install espeak' " //
+ "</body></html>");
// handle link events
ep.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(e.getURL().toURI());
} catch (IOException f) {
JOptionPane.showMessageDialog(null,
"Failed to launch the link, your computer is likely misconfigured.",
"Cannot Launch Link",JOptionPane.WARNING_MESSAGE);
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(null,
"Java is not able to launch links on your computer.",
"Cannot Launch Link", JOptionPane.WARNING_MESSAGE);
}
// ProcessHandler.launchUrl(e.getURL().toString()); // roll your own link launcher or use Desktop if J6+
}
});
ep.setEditable(false);
ep.setBackground(label.getBackground());
//
// JOptionPane.showMessageDialog(PlayRelease.startGui, "TextToSpeech executable not found.\nPlease make sure that the path variable leads to the espeak executable!\nIf you do not have espeak installed yet, please downlaod it from '<HTML>http://espeak.sourceforge.net/</HTML>'."
// + "\n Linux users can use the following command: sudo apt-get install espeak","Error occurred",JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(PlayRelease.startGui, ep,"Error occurred",JOptionPane.ERROR_MESSAGE);
}