Font « Graphics « Java Swing Q&A





1. Setting font color on DefaultStyledDocument    stackoverflow.com

I know that I can set the font size on a javax.swing.text.DefaultStyledDocument like this:

public void apply(DefaultStyledDocument document) {
    final MutableAttributeSet attributeSet = new SimpleAttributeSet();
    StyleConstants.setFontSize(attributeSet, ...

2. Adding Color to Font's attributes java swing    stackoverflow.com

I tried to add Color to java.awt.Font's attributes like this: font.getAttributes().put(TextAttribute.FOREGROUND, jColorChooser.getColor()); But I get the error

The method put(TextAttribute, capture#12-of ?) in the type Map is ...

3. Changing defaults (color,font,..) in SWING in a cross platfrom way    stackoverflow.com

I'm writing a Swing application in which I want to change the look and feel defaults before setting the look and feel. It seems that I can do it by calling ...

4. Changing font color --- URGENT    coderanch.com

I understand that you want to have a text with a certain kind of font. The most important is where do you want to use this text; If , for example you want a label, with font and color, you should set the font and the color for the label, not for the text af the label; I guess that all ...

5. Font Color of Disabled Components    coderanch.com

6. font help (printing through a browser)    coderanch.com

I'm trying to change stuff like oCanvas.setFont(new Font("SansSerif", Font.PLAIN, 25)); to oCanvas.setFont(new Font("Arial", Font.TRUETYPE_FONT, 25)); but it doesn't seem to be working. I'm calling drawString() and other Graphics 2D methods to draw a label image and printing it to a thermal printer. This plain logical font that I'm getting instead is almost illegible at point size 8 (which is what I ...

7. Font color for disabled components    coderanch.com

Thanks Michael, understood. My problem here is that we're using a third party Look & Feel API which overrides the default UIxxx classes, and these all appear to have been marked final (and my company isn't happy to pay for a source code license). Not important enough to spend more time on right now, but I really appreciate your suggestion. John ...

8. Font Problem in Java Print API    coderanch.com

I'm trying to print contents of notepad file. For this I have filled the JTextArea with the contents of File. The font type of both JtextArea and notepad file is Courier New and Size Font Size is 14.I am passing the JTextArea to the printComponent method. My problem is that when I try to print the notepad files which I receive ...

9. A conundrum with seting Graphics font size    coderanch.com

Setting the font size is not working. This is the code: private void drawUserData(Graphics graphics) { graphics = (Graphics2D)graphics; Font drawingFont = new Font("Hello, world", Font.BOLD, 16); Font font = new Font("Serif", Font.BOLD | Font.ITALIC, 24); graphics.setFont(font); int numberOfStrings = enteredStrings.size(); if (numberOfStrings == 0) { return; } graphics.setColor(Color.RED); EnteredString lastEnteredString = enteredStrings.get(numberOfStrings - 1); drawLastEnteredString(lastEnteredString, graphics); for (int i = ...