Need help creating a "mask" effect in swing

So I'm making the visual part of my connect four program. I'm trying to create the effect of dropping the piece from the top of the board to the bottom. I use the timer swing to create the animation and the animation works fine. My problem is to make the piece seem like it's between the board whereas right now the piece is in front of the board.
To see what I mean...here's the board without any pieces
Please click --> https://students.washington.edu/porrkice/connect4.jpg
Here's the board with a piece in the process of "dropping" into the bottom
Please click --> https://students.washington.edu/porrkice/connect43.jpg
The way I "drew" the board is this, and the piece is this...
  public void paintComponent(Graphics the_g) {
    super.paintComponent(the_g);
    Graphics2D g2d = (Graphics2D) the_g;
    This draws the board
    g2d.setColor(Color.yellow);
    g2d.fillRect(10, 10, my_board.getBoardsWidth() * 100, my_board.getBoardsHeight() * 100);
    g2d.setColor(Color.white);
    for (int i = 0; i < my_board.getBoardsWidth(); i++) {
      for (int j = 0; j < my_board.getBoardsHeight(); j++) {
        g2d.fillOval(MARGIN + i * 100, MARGIN + j * 100, 80, 80);
This is to draw piece
g2d.setColor(Color.red);
g2d.fillOval(MARGIN + my_x * 100, my_y, 80, 80);
}So basically, I just draw a rectangle, then draw a bunch of circles on top of it, then a circle that represents the piece...
And what I want is when the piece is dropping, when it goes pass the white circles which represents holes on the board, the yellow part between the holes will be on top of the piece
Hopefully I made my problem clear enough and someone could lend me a hand.
Edited by: inspiredone on Feb 13, 2008 12:06 AM
Edited by: inspiredone on Feb 13, 2008 12:06 AM

Here's an example of what Darryl suggested:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class CompositeBoardTest extends JFrame {
     private static int size = 400;
     private static int offset = 10;
     private static int ovalSize = size/4 - offset*2;
     private static int pos = offset/2;
     private static int incr = size/4;
     public static void main( String[] args ) throws Exception {
          SwingUtilities.invokeLater( new Runnable() {
               public void run() { new CompositeBoardTest(); }
     public CompositeBoardTest() {
          super( "CompositeBoardTest" );
          setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        Board board = new Board();
        add( board );
        setSize( size, size+34 );
          setVisible( true );
     static class Board extends JPanel implements ActionListener {
          private int[][] pieces = new int[4][4];
          private Piece addingPiece = null;
          private Timer pieceDropped = null;
          public Board() {
               setPreferredSize( new Dimension( size, size ) );
               setBounds( 0, 0, size, size );
               pieceDropped = new Timer( 10, this );
               addMouseListener( new MouseAdapter() {
                    public void mousePressed( MouseEvent e ) {
                         int column = ( e.getPoint().x-pos )/incr;
                         addPiece( column );
          protected void paintComponent( Graphics g ) {
               super.paintComponent( g );
               Graphics2D g2d = (Graphics2D) g;
               Composite comp = g2d.getComposite();
               Dimension d = getSize();
               int w = d.width;
               int h = d.height;
             BufferedImage buffImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
             Graphics2D gbi = buffImg.createGraphics();
             // Clear area
               g2d.setColor( Color.WHITE );
               g2d.fillRect( 0, 0, w, h );
               // Draw screen
               gbi.setColor( Color.YELLOW );
               gbi.fillRect( 0, 0, w, h );
               // Draw pieces or holes
               gbi.setColor( Color.RED );
               for ( int row = 0 ; row < 4 ; row++ ) {
                    for ( int column = 0 ; column < 4 ; column++ ) {
                         if ( pieces[row][column] == 1 ) {
                              gbi.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 1.0f ) );
                         } else {
                              gbi.setComposite( AlphaComposite.getInstance( AlphaComposite.CLEAR, 1.0f ) );
                         gbi.fillOval( incr*column+pos, incr*row+pos, ovalSize, ovalSize );
               // Draw adding piece if we have it
               if ( addingPiece != null ) {
                    gbi.setComposite( AlphaComposite.getInstance( AlphaComposite.DST_OVER, 1.0f ) );
                    gbi.fillOval( addingPiece.x, addingPiece.y, ovalSize, ovalSize );
               // Draws the buffered image.
               g2d.drawImage(buffImg, null, 0, 0);
               g2d.setComposite( comp );
          public void addPiece( int column ) {
               if ( addingPiece == null ) {
                    if ( pieces[0][column] == 0 ) {
                         addingPiece = new Piece();
                         addingPiece.row = 0;
                         addingPiece.column = column;
                         addingPiece.x = incr*column+pos;
                         addingPiece.y = 0;
                         pieceDropped.start();
                    } else {
                         getToolkit().beep();
          public void actionPerformed( ActionEvent e ) {
               if ( addingPiece != null ) {
                    addingPiece.y += 5;
                    int row = ( addingPiece.y - pos )/incr + 1;
                    if ( row > 3 || pieces[row][addingPiece.column] == 1 ) {
                         pieces[row-1][addingPiece.column] = 1;
                         addingPiece = null;
                         pieceDropped.stop();
               repaint();
     private static class Piece {
          public int row, column, x, y;
}

Similar Messages

  • Need help creating a cursor effect.

    I'm working on a little project that's like a text-based adventure, but played on a tumblr, so the readers submit their siggestions for actions.
    I'm looking to create animations for each post, so that it looks like the reader is typing in the text on the "game."
    I have the text-generation effect down using this code:
    var myString:String = "text data goes here.";
    var myArray:Array = myString.split("");
    addEventListener(Event.ENTER_FRAME, frameLooper);
    function frameLooper(event:Event):void
              if(myArray.length > 0)
                        tf.appendText(myArray.shift());
              else
                        removeEventListener(Event.ENTER_FRAME, frameLooper);
    //code sporked from Adam Khoury's Flash Typing Text Effect Tutorial video
    So that runs okay, but after that is done, I want there to be a final > prompt followed by a flashing cursor,as if asking for input.
    If anyone has a suggestion, that would be much appreciated.
    Thanks in advance!

    There's not much need to show anymore.  I already provided the code you can try to get a blinking cursor, but also said how it is iffy as far as it actually working. 
    The only difference I would offer for the code I provided earlier based on the image you show would be to add a new line before the ">", as in...
         removeEventListener(Event.ENTER_FRAME, frameLooper);
         tf.appendText("\n>");
         stage.focus = tf;
         tf.setSelection(tf.text.length,tf.text.length);  // in an ideal world this line, in league with the focus line preceding it will add the cursor... it just doesn't always work as advertised... especially for me

  • Uber Noob Needs Help Creating website!

    I need help creating my webpage: It has a textbox on it were
    the user enters a URL and it then redirects the end user to that
    URL when they press the GO Button. It also has a check box saying
    "Hide my IP", If the end user clicks this box and then clicks go
    they will be directed to the website they stateted in the Textbox
    but this time it shall mask there IP Address so they can bypass
    proxys and surf anonomosly. Please can someone give me some HTML
    code i could use for this site or a Link to a website that can give
    me the code.

    I assume the application is connecting to Oracle using an application ID/password. If so, check to see if that user has a private synonyn to the table. If so drop it since you have a public synonym.
    Verify that the public synonym is in fact correct. Drop and recreate the public synonym if you cannot select against the synonym name using an ID that can perform select * from inhouse.icltm where rownum = 1. That is if this other user cannot issue select * from icltm where rownum = 1 without an error.
    Check that the application ID has the necessary object privileges on the table.
    Queries you need
    select * from dba_synonyms
    where table_owner = 'INHOUSE'
    and table_name = 'ICLTM'
    You may find both public and private synonms. Either fix or delete. (Some may reference someelses.icltm table if one exists)
    select * from dba_tab_privs
    where table_name = 'ICLTM'
    and owner = 'INHOUSE'
    Note - it is possible to create mixed case or lower case object names in Oracle by using double quotes around the name. Do not do this, but do look to see that this was not done.
    You could also query dba_objects for all object types that have the object_name = 'ICLTM'
    HTH -- Mark D Powell --

  • Help creating a mask!

    Hi I'm new to FCP. I am trying to create a mask for a video I have imported. Here's the circumstances. I need to create a mask around the torso of an individual. We are creating video to be placed on plexiglass cut to the shape of a human being. The video will be projected onto the plexiglass thus creating the illusion there is a live person giving a presentation.
    I need a mask of the torso so it can be imposed over the diecut plexiglass without any bleeding off of the edge of the plexiglass and onto the wall, viewer or whatever.
    I can't seem to be able to create the mask successfully. I am trying to import a grayscale Photoshop tiff file (Black & White) and it doesn't seem to be working when I use the Image Mask filter.
    Can anyone please help me.
    Thanks in advance.

    Never mind I figured it out. Trial and error is a wonderful thing.

  • Hi, In need of help creating a simple effect to image.

    Attached is an image which shows more or less the effect I am needing to achieve.
    http://i303.photobucket.com/albums/nn149/Jaybeedubya/FotoliaComp_635945_xs3N3VFLwPNTIOm1.j pg
    I created the image above by desaturating the colour image of the man and then adding a new purple layer and selecting 'vivid light' from the layer palette drop down box. In doing this the man became purple but the white area surrounding him stayed white...I then adjusted the layers on the first layer so that the white part became purple - the final result is what you see in the attached image.
    The problem is this - I need to create this effect for 15 or so images all with a specific purple pantone colour, I need to create these for print ready artwork. All the pictures (ie the man) I will be using, need to look the same kind of shade. The way I was creating these before was to adjust the bottom layer so its grey rather than white so that the white area becomes purple.
    Confusing huh, If you dont understand my question (and I dont blame you!) then all I need is to create a set of 15 images that look like the attached image (using a specific pantone) but I have no idea how the best way to do it is.
    How would you guys achieve that? Any help greatly appreciated.

    So its gonna be a two-color-job?
    Because with the extreme depths adding Black at least might be beneficial.
    You could make a Selection of a black&white-version-of-the-photographs luminance, inverse it and, in the Channels-Panels PopUp-menu, choose Add New Spot Channel for the Foreground color and select the Pantone color.
    Then Add New Spot Channel for the background-color and fill that solid black and hide the layers that contain the composite of the photograph.
    This should leave You with blank composite channels and the two Spot Channels visible.
    Indesign can handle either psd- or DCS2-files containing Spot Channels.
    The problem I perceive here is that depending on the print-process and the background color selected it might proof necessary to knock out the foreground elements if the company is very strict on their CI colors. Unfortunately simply inversing the foreground selection would probably not work as this might leave the mixed-color-areas greyish.
    Are the prints gonna be offset or silkscreen?

  • Need help creating landscape in AE

    Hi, I need to create an animation of a train moving through different landscape scenes. I want the hills to be an actual 3D rendering with the train moving through them but I am unsure how to do this. I am familiar with 3D and can create the hills in my 3D application but how do I get my 3D hill into AE so the train, camera and lights etc. can interact with the hill?
    1. How do i get my 3D hill into AE?
    2. How do I add the train so it goes around the hills?
    3. How do I get the camera and lights etc. to reflect on my 3D hill?

    First of all, it would be very helpful to post an example of the kind of look you're going for or a similar shot you're trying to recreate.  In animation there are limitless ways of making things so it really helps to be very specific.  For now I can advise this much...
    1.  Render your hills out of your 3D application as an image sequence that supports transperancy if you want to layer them or you want the sky to show up behind them.
    2.  If you want the train to go around the hills, it really depends on how you make the train.  Are you also rendering that in a 3D app?
    3.  I don't know what you mean by getting the camera to reflect, but when you make a layer 3D, After Effects shows the Material Options settings that allow you to control how your layers react to different lighting setups.

  • Need help creating arraylist

    I am trying to help a friend in school with a project and we need some help...
    We need to write a program to estimate how much paint is needed to paint a house. Assuming we know the square feet that a gallon of paint covers, number of coats required, and the dimensions of the wall, window, door, or gable.
    We are using a GUI to enter the data for the different regions.
    We have the GUI created and the hierchy competed. I need some help creating the arraylist to run the program.
    The user will enter a new region by selecting:
    surface type
    width
    height
    then you will be able to add or insert to include this region in the list.
    You will also be able modify, delete, or navigate to existing regions in the list by selecting the appropriate navigigation buttons below:
    ( |< or < or > or >| )
    Classes include:
    PaintEstimatorView
    PainEstimator Model
    Regions:
    Wall
    Door
    Gable
    Window
    And the Approriate Listners
    Each region will have its own height and width which are set when the region is created
    Each region will compute and return its area and the walls and gables will contribute to the surface; windows and doors will reduce the surface.
    each region will calculate its area.
    We need to include a View and Model
    The view will manage the interface and the model will provide the necessary processing.
    responsibilities of the view:
    Instantiate and arrange the windowobjects
    instantiate and initialize the model
    handle user generated events such as button clicks and menu selections by sending message to the model
    represent the model to the user.
    Model:
    Define and manage the applications data(coordinating the activities of several programmer defined classes)
    respond to messages from the view
    We have the GUI completed I just need some help getting the arraylist started to run the program.
    We will need to keep a count and index of all the regions created by the user and you need to be able to shuffle throught them if you need to delete or modify them. You also need to insert windows and doors which will subtract from the total surface area but you have to go back to which ever wall or gable and create the window or door before or after that region.
    If anybody could help it would be greatly appreciated.
    Thanks in adavnce
    Rus

    Sorry, I forgot to add my code last night.
    This is what we have so far.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.*;
    public class TestSwingCommonFeatures extends JFrame {
    private JRadioButton wall, window, gable, door;
    private JButton computegal;
    public TestSwingCommonFeatures() {
    // Create a panel to group three buttons
    JPanel p1 = new JPanel(new GridLayout(2, 2, 5, 5));
    JTextField sqftpergal = new JTextField(8);
         JTextField coats = new JTextField(8);
         JTextField gallonsneeded = new JTextField(8);
         gallonsneeded.setEditable(false);
         p1.add(new JLabel("SQ ft / gallon"));
    p1.add(sqftpergal);
    p1.add(new JLabel("Number of gallons:"));
    p1.add(coats);
    p1.add(new JLabel("Gallons needed:"));
    p1.add(gallonsneeded);
         p1.add(computegal = new JButton("Compute gallons needed"));
         //computegal;
    p1.setBorder(new TitledBorder("Select gallons & coats"));
    // Create a font and a line border
    Font largeFont = new Font("TimesRoman", Font.BOLD, 20);
    Border lineBorder = new LineBorder(Color.BLACK, 2);
    // Create a panel to group two labels
    // panel 2
         JPanel p2 = new JPanel(new GridLayout(4, 2, 5, 5));
    p2.add(wall = new JRadioButton("wall"));
    p2.add(gable = new JRadioButton("gable"));
         p2.add(new JButton("ADD"));
              p2.add(window = new JRadioButton("window"));
              p2.add(door = new JRadioButton("door"));
                   p2.add(new JButton("Remove"));
    p2.add(new JLabel("Width"));
    p2.add(new JTextField(12));
         p2.add(new JButton("Insert"));
         p2.add(new JLabel("Height"));
    p2.add(new JTextField(12));
         p2.add(new JButton("Delete"));
    p2.setBorder(new TitledBorder("Controls"));
    ButtonGroup radiogroup = new ButtonGroup();
    radiogroup.add(wall);
    radiogroup.add(gable);
         radiogroup.add(window);
         radiogroup.add(door);
    //panel 3     
         JPanel p3 = new JPanel(new GridLayout(2, 1, 5, 5));
    p3.setBorder(new TitledBorder("Section Selection"));
         p3.add(new JButton("<|"));
              p3.add(new JButton("<"));
                   p3.add(new JButton(">"));
                        p3.add(new JButton("|>"));
    p3.add(new JLabel("Count"));
    p3.add(new JTextField(4));
         p3.add(new JLabel("Index"));
    p3.add(new JTextField(4));
    // Add two panels to the frame
    setLayout(new GridLayout(3, 1, 5, 5));
    add(p1);
    add(p2);
         add(p3);
    public static void main(String[] args) {
    // Create a frame and set its properties
    JFrame frame = new TestSwingCommonFeatures();
    frame.setTitle("TestSwingCommonFeatures");
    frame.setSize(600, 400);
    frame.setLocationRelativeTo(null); // Center the frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    private class UpdateListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    System.out.println("Update button was clicked");
    private class NavListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    System.out.println("Nav button was clicked");
    // Create a list to store data
    java.util.ArrayList paintList = new java.util.ArrayList();
    This is the GUI for the project that we have come up with. I have to write the arraylist for inside the model.
    I have tried a couple different things but have been unsuccessful getting it to work. All I am looking for is a start of the arraylist I will try to figure out the rest myself.
    Thanks

  • Aperture Workflow - need help creating workflow for photo management

    Hi -
    I currently shoot with a Canon SD890 (point & shoot) and a Nikon D300 (SLR). My photography is either personal photography or street photography. I may use some of my photography for a web project but that should not be considered right now. I shoot jpegs with the SD890 and RAW with the D300. I need to create a workflow that will allow me to manage all of my photos as well as the RAW vs JPEG aspect. Here are a few initial questions:
    1) Should I separate the RAW and JPEGs in Aperture (two libraries)? One library for finished photos and one for negatives?
    2) What folder structure should I use? Since I am not a professional photographer, I won't be shooting projects. I think something date or event driven would be best (preferably both).
    I am interested to hear how others do this...especially if you use both point & shoot and SLR cameras.
    Thanks for your help!

    jnap818 wrote:
    1) Should I separate the RAW and JPEGs in Aperture (two libraries)? One library for finished photos and one for negatives? I am interested to hear how others do this...especially if you use both point & shoot and SLR cameras.
    No, use a single Library. Aperture will have no problems with the various formats or with various different cameras.
    2) What folder structure should I use? Since I am not a professional photographer, I won't be shooting projects. I think something date or event driven would be best (preferably both).
    Actually those date or event driven batches of images are very logically "Projects" in Aperture. Simply name each group of images as you import into AP as a new Project.
    IMO it is not good to import camera-to-Aperture (or direct to any app other than the Finder). Best is to use a card reader and use the Finder to copy images from the camera card to a folder on the computer hard drive.
    Below is my Referenced-Masters workflow:
    • Remove the CF card from the camera and insert it into a CF card reader. Faster readers and cards are preferable.
    • Finder-copy images from CF to a labeled folder on the intended permanent Masters location hard drive. I label that folder with the Project name suffixed with _masters, that way I can always find the Masters if Aperture forgets where they are.
    • Eject CF.
    • Burn backup copies of the original images to DVDs or to hard drives (optional backup step).
    • Eject backup DVDs/hard drives (optional backup step).
    • From within Aperture, import images from the hard drive folder into Aperture selecting "Store files in their current location."
    • Review pix for completeness (e.g. a 500-pic shoot has 500 valid images showing).
    • Reformat CF in camera, and archive DVDs of originals off site.
    Note that the "eject" steps above are important in order to avoid mistakenly working on removable media.
    I strongly recommend that every Aperture user spend $35 and work through the tutorial CD Apple Pro Training Series: Aperture 2 (Apple Pro Training Series) by Ben Long, Richard Harrington, and Orlando Luna (Paperback - May 8, 2008), Amazon.com. Note that the value is in working the tutorial, not in using the book as a manual.
    Good luck!
    -Allen Wicks

  • Need Help Making This Text Effect

    Can someone please assist on how I can create this text effect with the thick line surrounding the text phrase at this link?
    http://www.flickr.com/photos/lalogotheque/2801883641/in/set-72157608260902848/
    I have the font already and I'm using Illustrator CS 1.0 for Mac OS X.
    Thanks in advance for the help!

    Yes I guess that is the way it is done:
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=18MgENxFZNBGeizw4wAaWr5Jo6B5vS0" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/18MgENxFZNBGeizw4wAaWr5Jo6B5vS0_thumb.png" border="0" />
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=1Np8mdgE1ZazEbQZjQnP6huKdaL7EJ" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1Np8mdgE1ZazEbQZjQnP6huKdaL7EJ_thumb.png" border="0" />
    <br />
    <br />That is you make three copies of the text but this time I composed the text as one unit using baseline shift and different type sizes and spacing.
    <br />
    <br />Once I had text they way I wanted it and the three copies I kept one as is, in this case the black version.
    <br />
    <br />I then gave a color to the bottom most and gave it a sufficient Offset path setting to look solid.
    <br />
    <br />So there is now black text and a solid colored background in and expanded shape of the text.
    <br />
    <br />I then outlined the text for the text that had been offset and then used the pathfinder to merge the different paths within that art. That would be the first icon on the top left of the pathfinder panel.
    <br />
    <br />I then gave the text in between and outline twice the weight I wanted the gap to be and no fill and flattened the transparency choosing to outline the strokes.
    <br />
    <br />Then I selected the outlined I just created and the background I created before leaving the
    <br />the outline on top of the background and went back to the pathfinder and chose to minus the front. The second icon on the top left of the panel.
    <br />
    <br />And there you are.
    <br />
    <br />Now I can do a Video or perhaps someone like Mordy will stop by and clean up my explanation as I understand i am often not easy to follow as far as my writing is concerned.
    <br />
    <br />I hope this helps.

  • Quick Time VR - need help creating qtvr

    I'm teaching my middle school students web design and flash to create an interactive school map. I want to add 360 qtvr's but I need help - I can't seem to get information on how to create them. Any Los Angeles help possible?

    QuickTime Pro doesn't create VR files. It only presents them.
    http://www.panoramas.dk/quicktime/qtvr/software.html
    A pretty good list of tools at that link.

  • Need help installing adobe after effects CS5 free trial

    i cant install adobe after effects CS5 trail it keeps giving me an erorr that says "error occured with connection with adobe.com (error 107), how do i restart adobe download assingment,and the bar at the bottom tells me to sing in when i already have, anyways i need help, can u guys helpme install adobe after effects CS5 trial?

    http://kb2.adobe.com/cps/898/cpsid_89867.html
    Mylenium

  • New to Illustrator, need help creating a map?

    Need to create a map of a neighborhood.  New to program any help would be great!

    rdelaroca,
    There are vector maps available for many areas.
    Or you may work on a locked image from Google Maps or something including the important parts/themes/whatever, using the Pen Tool as the primary tool for shapes in general.

  • Need help creating a rectangle with a bunch of  text scrolling up within it

    Hey everyone, I'm using Motion 2 and want to add a large amount of text scrolling up. Which behavior would be best to use, the Scroll up or Motion Path?
    I want to create a rectangle where the text will be scrolling within it but I'm not sure how to do that. I'm I suppose to create a mask rectangle and then add the text?
    Please help
    Thank You

    As with most things there are a number of ways you could do it.
    One way is, if your making a rectangle anyway (as a bkg for the text) you can make an image mask (command shift m) on the text object and drag the rectangle into the mask well (then turn the rectangles visibility back on). This works with a filled rectangle.
    Of course you have to format the text to fit in the rectangle as it won't act as a bounding type area (like in AI, PSD).
    o| TOnyTOny |o

  • Iscripts - Need help creating a form in one

    I am confused about delimiting in iscripts. I need to create the fiollowing form:
    In iscript named IScript1
    in function: buildform
    buildform has these two inputs, firstname and lastname
    the action of the form is also in iscript1 function getinputs
    iscript getinputs will just print out the firstname and lastname
    Could I get some help with this?
    Thanks, Allen Cunningham

    Your site is running on an Apache server, so it definitely doesn't support ASP. Apache frequently supports PHP, but I couldn't tell from the headers sent by your server whether it's supported on your site.
    I suggest that you contact BT Business support to see if they offer a formmail script. Most hosting companies do. The support pages should describe how to set it up.

  • Need help creating URL for getImage

    In the following code example, I get an error when javac compiling. I need help, because I cannot determine what is wrong. "....." denotes extraneous code removed for readability.
    import java.awt.*;
    import java.io.*;
    import java.applet.*;
    import java.net.*;
    public class testapp extends java.applet.Applet implements java.lang.Runnable
    public static void main(String[] argv)
    ����.
    public void init()
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image1 = toolkit.getImage("imageFile.gif");
    Image image2 = toolkit.getImage( new URL("http://java.sun.com/graphics/people.gif"));
    ��
    javac reports:
    unreported exception java.net.MalformedURLException; must be caught or declared to be thrown
    Image image2 = toolkit.getImage( new URL ("http://java.sun.com/graphics/people.gif"));
    ................................................^

    With this recommended code:
    ===================
    try {  Image image2 = toolkit.getImage( new URL  ("http://java.sun.com/graphics/people.gif"));}catch(MalformURLExceptione){System.out.println("Error"); }
    ======================
    it now compiles ok, but when I access the page through the browser, I get "applet not initialized" and the page times out.
    With the lines commented out, the page loads.
    What does this tell us:
    - all we have done is mask a problem that the compiler previously highlighted.
    But what is the problem?
    As far as I can tell, the code is exact copies from the examples posted online.
    Where should System.out.println("Error"); be displayed? I can't find it. There might be a clue in the error message.

Maybe you are looking for

  • Actions from CS5 fail in CS6

    Using CS6 v13.0 x64 on a Win 7 ^4 bit PC with 12Gb RAM. I have actions that call for an image to be opened, selected, copied, the image closed and the "clipboard" image pasted into another, already open, image in PS.  This works without fail in CS5 b

  • Moving Image from one Review to Another?

    I attempted to upload an image (open in Photoshop) to a specific review. However, I could not see the desired review in the Photoshop CS Review panel. Out of frustration - after attempting to "find" the desired review for several minutes - I uploaded

  • Want to delete adverts that came with updated Firefox

    When I go onto Jacquie Lawson web page adeverts appear at the top of the page and it has happed on another site too. How can I stop this happening as they are a distraction. If the mouse hovers near the advert it then fills the page. Many thanks Jane

  • Session/too_many_rows error

    Hello, this is a strange problem that I've been working on for ages now - hopefully you can help! The problem is when I save my session I get a TOO_MANY_ROWS error. It sounds crazy but I've been putting exception blocks around every select...into sta

  • Joining of to internal tables

    Hi, I am having to internal tables it_itab and it_jtab of diffrent structure in my program. my requirement is to add all the fields it_jtab into it_itab and write the write the write statement  so that I can see all the fields. How is this possible.