1

私の問題は、Font コンストラクターが表示される場所です。最後の項はフォント サイズの整数であり、12 と 100 のどちらを指定しても (現在のように)、テキストは同じサイズで出力されます。私は何を間違っていますか。

@Override
    protected void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g;
        Font font = new Font(Font.SERIF, Font.PLAIN, 100);

        if(setTextAttributes){
            setTextAttributes();
            setTextAttributes = false;
        }

        c.paintCursor( g2d );

        font = font.deriveFont(map);
        g2d.setFont(font);
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                             RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
        g2d.drawString(text, lineX, lineY);

    }
4

1 に答える 1

5

ドキュメントで述べられているように、この行font.deriveFont(map)は新しいフォントを作成します

于 2013-08-21T06:12:12.073 に答える