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: Inserting a video into graphics?

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

    Default Inserting a video into graphics?

    So I'm doing a project for my CS class where we have to create a snowman doing something. My picture is of Vince Young in the 2005 Rose Bowl. I'm trying to make the actual video clip from Youtube (do I need to download it? If so I can do that) appear on the scoreboard, but have no idea how. I'm completely open to suggestions. As of right now, this is my background file:

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Font.*;
    class snowBackground
    {
    public static void drawField(Graphics g, Color field)
    {
    Color sky = new Color(95,166,243);
    g.setColor(field);
    g.fillRect(0,300,1000,350);
    g.setColor(sky);
    g.fillRect(0,0,1000,300);
    g.setColor(Color.white);
    g.fillRect(50,300,15,350);
    g.fillRect(150,400,15,90);
    g.fillRect(250,400,15,90);
    g.fillRect(350,400,15,90);
    g.fillRect(450,400,15,90);
    g.fillRect(550,300,15,350);
    g.fillRect(530,540,15,70);
    g.fillRect(570,540,30,70);
    g.setColor(field);
    g.fillRect(580,557,10,30);
    g.setColor(Color.white);
    g.fillRect(650,400,15,90);
    g.fillRect(750,400,15,90);
    g.fillRect(850,400,15,90);
    g.fillRect(950,400,15,90);
    }
    public static void scoreboard(Graphics g)
    {
    Color numbers = new Color(224,199,52);
    Color gray = new Color(22,22,22);
    Color lightGray = new Color (131,131,131);
    g.setColor(gray);
    g.fillRect(320,250,20,50);
    g.fillRect(540,250,20,50);
    g.fillRect(315,50,250,200);
    g.setColor(lightGray);
    g.fillRect(345,210,25,25);
    g.fillRect(510,210,25,25);
    g.setColor(numbers);
    Font f = new Font("Dialog",Font.PLAIN, 18);
    g.setFont(f);
    g.drawString("33",347,230);
    g.drawString("38",512,230);
    Font h = new Font("Dialog",Font.PLAIN, 10);
    g.setFont(h);
    g.drawString("Texas",343,210);
    g.drawString("USC",511,210);

    }
    }

    and this is the Driver file (not sure if this is necessary):


    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Font.*;
    public class SnowDriverWSB
    {
    public static void main(String args[])
    {
    GfxApp gfx = new GfxApp();
    gfx.setSize(1000,650);
    gfx.addWindowListener(new WindowAdapter() {public void
    windowClosing(WindowEvent e) {System.exit(0);}});
    gfx.show();
    }//void main
    }//SnowDriverWB
    class GfxApp extends Frame
    {
    public void paint(Graphics g)
    {
    int xCoor=350;
    g.setColor(Color.red);
    g.drawOval(350,350,10,10);
    Color burntOrange=new Color(236,112,51);
    Color cardinal = new Color(211,24,24);
    Color gold = new Color(236,232,51);
    Color footballGreen = new Color(71,150,73);
    snowBackground.drawField(g,footballGreen);
    snowBackground.scoreboard(g);
    Snowperson vince = new snowFootball(150,350,200,200);
    vince.drawSnowperson(g,burntOrange,Color.white,Col or.black,10);
    Snowperson usc = new uscFootball(550,350,200,200);
    usc.drawSnowperson(g,cardinal,gold,gold,31);
    drawGrid(g);
    g.setColor(Color.blue);
    }
    public static void drawGrid(Graphics g)
    {
    g.setColor(Color.black);
    for (int x = 0; x<1024;x+=20)
    g.drawLine(x,0,x,768);
    for (int y=0;y<768;y+=20)
    g.drawLine(0,y,1024,y);
    }

    }

    There are 3 other files that make the actual Snowmen. To do this, I need VERY basic steps, as I'm extremely confused and new to Java. Also, would I need to download the mp3 sound file seperately and play that, or will inserting the video do both? Any replies are appreciated.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,530
    My Mood
    Mellow
    Thanks
    157
    Thanked 615 Times in 602 Posts

    Default Re: Inserting a video into graphics?

    Welcome! Please read this topic to learn how to post code correctly and other useful info for new members.

Similar Threads

  1. Inserting a video into graphics?
    By vy2005 in forum Java SE APIs
    Replies: 1
    Last Post: February 12th, 2014, 02:35 AM
  2. Replies: 0
    Last Post: November 16th, 2012, 04:25 AM
  3. Games/Application (Video output, Frame, Graphics Components,Versatility)
    By chronoz13 in forum Java Theory & Questions
    Replies: 3
    Last Post: July 7th, 2011, 08:06 AM
  4. Graphics class NullPointerException Initialize Graphics Class??
    By bglueck in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 13th, 2011, 11:13 PM
  5. Replies: 2
    Last Post: March 16th, 2011, 06:32 AM