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 2 of 2

Thread: Java Graphics

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java Graphics

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

    public class Rect1{
    //constructer
    public Rect1(){
    frame();

    }
    //frame() method
    //to draw JFrame

    public void frame(){
    JFrame f=new JFrame();
    f.setSize(600,600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);

    }

    //draw graphics
    public void paintComponent(Graphics g){

    g.setColor(Color.RED);
    g.fillRect(20,20,40,50);

    g.setColor(Color.BLUE);
    g.drawString("This is a Hello World Program",50,50);


    }
    //main method
    public static void main(String args[]){
    new Rect1();

    }

    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Java Graphics

    Did you have a question?

    Recommended reading: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Java Traffic Applet and Graphics
    By samadams1314 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 21st, 2014, 08:17 PM
  2. Java Graphics Question
    By Europa in forum Java Theory & Questions
    Replies: 2
    Last Post: December 20th, 2011, 11:15 AM
  3. [SOLVED] Java Graphics: Drawing one object into another
    By zaxahmed in forum Object Oriented Programming
    Replies: 5
    Last Post: August 22nd, 2011, 08:06 AM
  4. Java Graphics help
    By Stockholm Syndrome in forum AWT / Java Swing
    Replies: 9
    Last Post: November 4th, 2010, 05:23 PM
  5. How do i use graphics with Java?
    By DarrenReeder in forum Java Theory & Questions
    Replies: 4
    Last Post: December 27th, 2009, 05:16 PM

Tags for this Thread