Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:59:09+00:00 2026-05-28T01:59:09+00:00

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

  • 0

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

public void Paint (Graphics g)
{
    if(g instanceof Graphics2D)
    {
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }
    g.drawString("This is gona be awesome", 200, 200);
}

With the above code, I want to write a sentence on the window but it never writes. What am I doing wrong?

Edit: Never mind – Paint must be paint. I apologize profusely.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:59:09+00:00Added an answer on May 28, 2026 at 1:59 am

    In the given code, what you want is

     g2d.drawString("This is gona be awesome", 200, 200);
      ^
    

    A working example for your reference :

    package Experiments;
    import java.awt.Container;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    
    public class MainClass{
      public static void main(String[] args) {
        JFrame jf = new JFrame("Demo");
        Container cp = jf.getContentPane();
        MyCanvas tl = new MyCanvas();
        cp.add(tl);
        jf.setSize(300, 200);
        jf.setVisible(true);
      }
    }
    
    class MyCanvas extends JComponent {
    
      @Override
      public void paintComponent(Graphics g) {
          if(g instanceof Graphics2D)
          {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    
            g2.drawString("This is gona be awesome",70,20); 
           }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been an avid fan of lazy loading but yesterday I was talking
I am an avid fan of the Spring framework for Java (by Rod Johnson).
This is my first question on this site. I'm new to php but i've
I'm an avid vim user and have started to write some SQL code recently.
I'm an Avid Javascript developer, and am wondering if there's any to use Open
I'm probably going to take some heat for this question. But I'd like to
G'day everybody, As an avid firefox user, I use plugins like stylish and Greasemonkey
I am an avid user of the YUI framework ( http://developer.yahoo.com/yui/ ). It has
Is it possible to write a user interface in Java for an application written
I have a task I am trying to complete, but cant think how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.