Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: GUI Drawing shapes (The shape doesn't appear in the window.)

  1. #1
    Junior Member
    Join Date
    Jan 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation GUI Drawing shapes (The shape doesn't appear in the window.)

    import javax.swing.*;
    import java.awt.*;



    public class ColorPanel extends JPanel {

    public ColorPanel(Color backColor) {

    setBackground(backColor);

    }

    public void paintComponent(Graphics g)
    {

    super.paintComponent(g);
    g.setColor(Color.blue);
    g.drawString("hello", 100, 45);

  2. #2
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: GUI Drawing shapes (The shape doesn't appear in the window.)

    I think you're missing some code. And please put the code between code tags. See BBCodes below.

    Regards,
    Jim

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: GUI Drawing shapes (The shape doesn't appear in the window.)

    Also posted here: http://www.javaprogrammingforums.com...tml#post164540
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Drawing a shape
    By jason3460 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 4th, 2013, 07:00 PM
  2. Drawing a square in a window
    By kinkita in forum AWT / Java Swing
    Replies: 1
    Last Post: March 29th, 2013, 07:18 AM
  3. Drawing on a JFrame that has a Shape
    By tim8w in forum AWT / Java Swing
    Replies: 4
    Last Post: February 14th, 2013, 05:25 PM
  4. Creating Callout shape window
    By vrof in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 25th, 2012, 05:13 AM
  5. Adding an array of shapes to a GUI window
    By cslx99 in forum AWT / Java Swing
    Replies: 3
    Last Post: December 8th, 2011, 06:03 AM

Tags for this Thread