Draw text with graphics object on JFrame

前端 未结 3 1331
面向向阳花
面向向阳花 2020-12-20 15:36

I am an avid programmer but today is my first Java lesson.

public void Paint (Graphics g)
{
    if(g instanceof Graphics2D)
    {
        Graphics2D g2d = (G         


        
3条回答
  •  温柔的废话
    2020-12-20 16:01

    1) not possible directly paint to the JFrame, you can painting:

    • put there JPanel

    • getContentPane from JFrame

    2) for Swing JComponents is there paintComponent() instead of paint(), otherwise your painting couldn't be drawed corretly

    3) another options are:

    • paint to the JFrame's RootPane

    • paint to the JFrame's GlassPane

    4) more in 2D Graphics tutorial

提交回复
热议问题