3 questions-1)easy-images.2)hard-building a timer in a game.3)medium

hello to all the java canons...
1)Can anyone give me a code of image cuting.the problem is that i need to cut an image but not in a square shape,i need to cut it as a trpeze and i didnd found find in the api a method that recives 4 x point and 4 y poins to cut an image in a shape of a trapeze.
2)I have 2 classes:one is JPanel and the other is JApplet.I want to build a timer in a game which gives a player a period of time to play,and if he didnt the game ends.i thoght to build a timer in the JPanel class and to paint a line which is getting bigger every second and when the line ends the player lost.how do the JPanel class know when the player played and stop the animation(the JApplet class has an actionlistener method),because the timer running stayes in the JPanel class until the timer ends...help....give me ideas...
3)I need to upload a gif image to a JButton,i tried the code in the tutorial and it didnt work,can anyone give me a code that he wrote and it worked???
thanks in advance....

In response to your first question I recommend following this line into the turorial:
java tutorial >> 2D Graphics >> Displaying Graphics With Graphics2D >> and from there follow the links to Transforming Shapes, Text, and Images and Clipping the Drawing Region.
The first section on Transforming... will show how to use the AffineTransform class to shear. The second shows how to use the clip methods found in the api of the Graphics and Graphics2D classes.
For questions 2 and 3:
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.net.URL;
import javax.swing.*;
import javax.swing.Timer;
public class QuestionDemo extends JApplet
    public void init()
        String fileName = "images/dukeWaveRed.gif";
        URL url = getClass().getResource(fileName);
        ImageIcon icon = new ImageIcon(url);
        JButton gifButton = new JButton(icon);
        JPanel buttonPanel = new JPanel();
        buttonPanel.add(gifButton);
        GamePanel panel = new GamePanel();
        Container cp = getContentPane();
        cp.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = gbc.REMAINDER;
        gbc.insets = new Insets(5,0,5,0);
        cp.add(buttonPanel, gbc);
        cp.add(panel, gbc);
        cp.add(panel.getUIPanel(), gbc);
    public static void main(String[] args)
        JApplet applet = new QuestionDemo();
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(applet);
        f.setSize(400,400);
        f.setLocation(200,200);
        applet.init();
        applet.start();
        f.setVisible(true);
class GamePanel extends JPanel
    final int PAD;
    int time;
    Timer timer;
    Color color;
    final int
        delay = 250,
        interval = 60;
    public GamePanel()
        PAD = 30;
        color = Color.black;
        time = 0;
        timer = new Timer(delay, new ActionListener()
            int timeLimit = interval * 1000;  // milliseconds
            public void actionPerformed(ActionEvent e)
                time++;
                if(time > timeLimit/delay)
                    color = Color.red;
                    Toolkit.getDefaultToolkit().beep();
                    timer.stop();
                repaint();
        setPreferredSize(new Dimension(300,200));
        setBackground(Color.white);
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
         int w = getWidth();
         int h = getHeight();
         double elapsed = time * (w - 2*PAD) * delay/(interval*1000);
         double x = PAD;
         double y = h - PAD - 8;
         g2.setPaint(color);
         g2.fill(new Rectangle2D.Double(x, y, elapsed, 8));
    public JPanel getUIPanel()
        final JButton
            start = new JButton("start"),
            stop = new JButton("stop");
        ActionListener l = new ActionListener()
            public void actionPerformed(ActionEvent e)
                JButton button = (JButton)e.getSource();
                if(button == start)
                    if(!timer.isRunning())
                        time = 0;
                        color = Color.black;
                        timer.start();
                        repaint();
                if(button == stop)
                    if(timer.isRunning())
                        timer.stop();
        start.addActionListener(l);
        stop.addActionListener(l);
        JPanel panel = new JPanel();
        panel.add(start);
        panel.add(stop);
        return panel;
}

Similar Messages

  • Easy question I'm sure. imac hard full (500gb) mostly from iphoto. no capacity left. what are my options? I've thought of an external drive of 1tb and then a 2nd external drive of 3tb to back up both???? please help.

    easy question I'm sure. imac hard full (500gb) mostly from iphoto. no capacity left. what are my options? I've thought of an external drive of 1tb and then a 2nd external drive of 3tb to back up both???? please help.

    Those are the options - more space is more space.
    Moving the iPhoto Library is simple:
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

  • How do I add an image in Survey Builder?

    I am trying to build a survey in Survey Builder where images are part of the questions and/or the answers.  Any idea how I could do this?  I am an APEX novice.
    Thanks,
    Sara

    Survey Builder does not have support for images in questions or answers. You cannot put markup in question or answer text.
    You can, however, put markup in section introduction messages. So if a section that introduces a group of questions has an image in it then the questions can refer to the image. Survey Builder will not manage the images for you so they should already be accessible by some URL that the survey questionnaire has access to (meaning if the survey is public the images should not be behind a firewall or require authentication to access).
    Create a section for each image you want to ask questions about. In the introduction message add an image tag. For example a section introduction message could be:
         The next few questions relate to the following image:<br>
         <img src="http://example.com/images/icon00012.png">
    Then add questions to each section about the image.

  • HT1553 I restored my hard drive from time machine. Why is iPhoto not displaying images properly?

    I restored my hard drive from time machine after power blinks corrupted the file system so badly that disk utility could not repair it. Since then, iPhoto has not displayed images correctly. Events are there, and blank squares are shown, but that's all. I rebuilt small and all thumbnails and permissions -- I think the top three or four options in the iPhoto rebuild utility, which took five hours to do but which seems not to have changed anything. The iPhoto library is still more than 100GB, so the photos are there. I didn't choose rebuild from backed up --- whatever the final option on the rebuild menu offers -- because that seems to be appropriate only when a backup is interrupted. Could certainly do it, though. How do I get iphoto behaving again? I have full time machine backups saved automatically and another fairly recent copy on a separate hard drive stored remotely. Thanks for whatever help anyone can provide. I've looked at existing questions and solutions without success so far.

    What version of iPhoto and system are your running?  Since you've tried rebuilding with iPhoto give this a try:
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments. However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    If you have an external HD you might want to have the rebuilt copy created on it unless you have well more than 100 GB available on your boot drive.
    OT

  • Posing a question to those well versed in building Flash training applications

    I would like to start an off-line communication chat with those of you who are well versed in Adobe Flash or Adobe Flex.
    I've worked with Cold Fusion but I am not up to date on all the technologies available.  This seems like the perfect forum for this question.
    I simply want to build an application (web or desktop is unknown) in which a person can learn a foreign language, in this case English.
    I need some technical advice as to whether Flash, Flex, or a combination of technologies (Cold Fusion for server side functionality) is the best choice for this application.  I do not understand the technical aspects of Flash or Flex in building applications so I need the advice of you experts.
    As with most foreign language textbooks, audio, or foreign language video training, the material is not interesting, not pertinent to daily life, and is great for late night insomnia.  I've never seen any type of foreign language training that is interesting, fun, or uses current events as part of the curriculum.
    I would like to illustrate my idea with an example.  I want to use an existing English beginners textbook (for kids), scan the images in the textbook, store the content (rules of grammar) in a database and store example sentences in a database.
    I would like to record basic audio sentences from the textbook (Do you know tomorrow's weather), incorporate some animation (baseball player hitting a home run), incorporate some basic video (purchasing an item at the grocery store), add a quiz, test question or puzzles, etc..
    In addition, since this is a classroom setting and the kids are split into groups, I would like to store a seating chart with the kids names and pictures in a database.  After the first segment is finished (e.g. purchasing a toy at the store) the kids next perform an activty.  I want to use a combination of audio, video, and animation to explain the activity, give instructions, split the class into groups,and perform the activity.
    As I mentioned before, I would like to start an off-line discusion for those of you who are willing to share some of you knowledge and experience with Flash and maybe Flex.  Since you are extremely busy, maybe you might be able to point me in the right direction.
    Hopefully, some of you can provide some sound technical advice.
    Thanks in advance

    thank you for your reply
    the best answer is email or chat.  I use Skype and google talk.
    the reason is simple.  I can probably guess that we are at least 10 time zones from each other.  I am currently in Tokyo Japan; just moved last year because of my Japanese wife.
    Meeting face to face is virtually impossible and the time zones make a telephone call impratical.
    My English training idea stems from the fact that kids in Japan study English for 6 years.  This is mandatory.  After 6 years of studying any subject matter, you certainly should know it fairly well.  In Japan, the education system stresses grammar, not conversation.  The kids can read and write English fairly well, but can't speak much English.
    This seems extremely strange; judging by the high level of science and mathematics taught in school.  The system of English education is extremely broken in Japan.  Everybody laughs when I tell them learning to read and write a foreign language is more important that speaking the foreign language.  Well, that's how it is in Japan.  I am making it my personal quest to break this broken system and give them something that is sorely needed in Japan.
    Anyway, that is too much information about what I am trying to do.
    If you can point me in the right direction, I would be eternally grateful.  I also forgot to ask how Adobe Captivate might fit into all this.  I notice Adobe carries a suite of e-learning products.  My idea is to be interactive and fun, not so much a slide presentation look and feel.

  • Error 1003 occurred at Open VI Reference in Dist Copy Non-VI Files.vi- Dist Build LLB Image.vi- Dist Build App Image.vi- Build Application.vi

    When trying to build  an application using labview 7.1 and windows XP,  I get the error
    Error 1003 occurred at Open VI Reference in Dist Copy Non-VI Files.vi->Dist Build LLB Image.vi->Dist Build App Image.vi->Build Application.vi
    I've tried the crtl-shift-run as well as  a mass compile and I still get the error.
    Any ideas?
    Thanks,
    Mike

    Hopefully this thread, or this KB article might help.
    It seems like this could come from a lot of things, but there's suggestions in those which might lead you in the right direction
    Message Edited by Day on 09-22-2006 02:07 PM

  • External Hard Drive and Time Machine questions

    Hello, I am new here to the forums and I have looked all over for the answers to two questions that I have regarding external hard drives and the time machine feature.
    For some background, I recently had a scare (water spill but luckily I had a keyboard cover on and the entire spill landed on the cover) with my Mid-2012 13" Macbook Pro (2.5Ghz) and due to almost losing all my data I've decided to invest in an external hard drive. However, rather than just purchasing a 500GB HDD to use as an external hard drive, I decided to kill two birds with one stone and upgrade my Macbook Pro as well by investing in the 480GB OCW Mercury Extreme Pro SSD. I'll be using the SSD as my internal drive so the original hard drive that came with my Macbook will serve as my backup external drive. Lastly, I plan to use the external drive solely for the purpose of backing up my MacBook in case something ever happens to my Macbook.
    I am using this guide to help me with this whole process: http://circuitremix.com/?q=content/macbook-pro-solid-state-drive-upgrade-guide-a nd-performance-testing.
    My two questions are:
    1) When following the guide, it never mentions anything about the Partition Map Scheme. After being alerted to this and doing some additional research, is it better to go with the GUID Partition Table rather than the Master Boot Record?
    2) After I have cloned everything onto my new SSD and replaced the HDD in my MacBook with it, should I erase everything on my HDD before setting it up with time machine?  I was thinking about keeping the original data on the original hard drive (which would now be my external drive) just in case something goes wrong with time machine but I have read that people recommend solely dedicating the entire external hard drive for time machine backups.
    Thanks in advance!

    Format the new SSD in Disk Utility to Mac OS Extended (Journaled) and that will solve question No. 1.
    After formatting, clone the new SSD using Disk Utility>Restore or Carbon Copy Cloner (down load from the Internet).  Test the new SSD and if it performs as expected, do the physical swap.
    Question No. 2.  Erase the Time Machine HDD using Disk Utility and then install Time Machine.  See this excellent website regarding Time Machine.
    http://pondini.org/OSX/Home.html
    If you want an external boot HHD, get another one and use Carbon Copy Cloner.  This will give you redundancy in backups as well which is a good strategy.  CCC also can update the contents in an incremental manner similar to Time Machine.
    Ciao.

  • Hard drive, SSD, Time machine question

    I was using a Macbook Pro mid 2012 13" for this problem.
    About a month ago, I upgraded my hard drive to a Crucial Solid State Drive (SSD) 240 gb m500. I used Carbon Copy Cloner and everything went very smoothly and my computer worked great for about two months. Randomly one day, I turned on my computer and got a WHITE SCREEN. I have tried several things to try and correct this SSD but none of them will work. I have come to the conclusion that it is a broken/unusable SSD and am returning it.
    My problem comes that my time machine backup is on my old macbook pro hard drive. I want to put back in that hard drive into my MBP with all my files intacted, but of course it is not in the right format to run.
    I have access to another MBP, a 500 gb external drive, as well as a internal hard drive enclosure to plug my old hard drive into USB externally.
    My question is would it be to risky, if I backed up my friends MBP to the 500gb external hard drive using time machine. Then I put my time machine backup on his computer. Then make a copy from his computer of my time machine backup to my old MBP hard drive. Then put my newly copied hard drive back into my MBP. And then take my friends MBP and time machine his backup back from the external drive back onto his computer.
    Let me know if you have any other ideas. Thanks
    ~Katherine

    With the SSD still in the MacBook, hold down the Option key at Startup. This will draw an icon for each potentially-bootable drive.
    Now go away from your Mac and leave it powered on doing nothing for 20 to 30 minutes.
    Sometimes an SSD gets so clogged with data it needs idle to do a major Garbage collect, but thinks it is still being accessed, so it delays the Garbage Collect. Leaving it alone for 20 minutes or more MAY allow it the time to fix itself.
    If this helps, read this article on TRIM:
    http://en.wikipedia.org/wiki/TRM
    consider installing TRIM Enabler from Groths.

  • How to upload images on hard drive to iPad?

    how to upload images on hard drive to iPad?

    You can import them into iTunes then use that to get them onto your iPad.
    You can download the iCloud control panel and use photo stream to get the photos onto your iPad
    You can e-mail them to yourself and them save them from that e-mail
    You can upload them to something like dropbox and then download them onto your pad from there.

  • Questions for the end users in Building an application.

    Questions for the end users in Building an application.
    Hello,
    I am assigned a project in building a CF application. As far
    as the business requirements, I have an idea from the MIS people.
    However, I have a meeting with direct users and I have to ask
    questions to add to my requirements. I am still a beginner in this
    but I need to ask questions.
    Can anyone give me tips? what basic / important questions?

    For starters,
    DO:
    Ask them to discuss what they want to do with the application
    Try to understand their level of computer literacy
    Keep your conversation non-technical
    Continue to interact with the users during the design and
    development process
    Try to identify a "champion" with whom you can interface as the
    project progresses
    DON'T:
    Use technical terms or discuss technical issues
    Talk down to them
    Promise delivery dates until you have documented their
    requirements and they have approved them

  • Questions on Still Image Export

    I shot a wedding where the photog's Hasselblad failed. Only the first two frames of each roll where successful. I need to export around 100 images as stills. Each time I use QT Conversion I have to select "still images" from the format drop down box. Is there a way to set "still" as a default?
    Secondly, the exported image looks a bit "wide" compared to the images in FCP's canvas. How do I adjust for this. In FCP? In Photoshop? I'm sure this is remedial but I'm a bit of a novice. Thanks in advance for any help.
    Frank, Cranford, NJ

    Studio X wrote:
    2. When you start with DV material, the highest res
    you can get is 720x480 (non-square) or the equivalent
    of a really bad quality cheepo still camera.
    (~640x480 square pixels)
    To avoid the need to deinterlace, (the horrors of
    which are described below) find sections in your
    video that have VERY LITTLE motion, i.e.
    everyone/thing standing/existing absolutely still
    with the camera locked down on a tripod. These
    sections will yield the very best possible still
    images.
    If you have motion, the still images will exhibit
    'tearing' which comes from the two fields of video
    being recorded ~1/60 second apart. The second field
    shows elements displaced from the first field - hence
    a kind of internal image shifting going on. The only
    real way to deal with these kind of images is to
    deinterlace them - that is - decide which field you
    are going to keep and throw away the other.
    When you have deinterlaced the image, you have in
    effect reduced it from a 720x480 image to a 720x240
    image. The image pixel count REMAINS 720x480 but with
    half the vertical information as the remaining lines
    are doubled or interpolated to build back to 480
    lines.
    I take your explanation to mean that when you export a frame from FCE you get both fields. I am confused by the use of the term "de-interlace", since in television displays that term is defined as obtaining a full frame picture either by a) combining the two fields (called "weave"); b) duplicating lines of a single field (called "bob") or c) using some form of interpolation to derive the alternate lines.
    From this point of view, the term "de-interlace" as applied to the filter in FCE does not have the same meaning. Exporting without filtering produces what the TV interpretation would be a picture "de-interlaced" according to process a); applying the de-interlace filter produces an image containing one field only, and de-nterlacing that in Photoshop amounts to the application of either b) or c) above.
    Am I correct on this?
    867 MHz PowerPC G4   Mac OS X (10.3.9)  

  • Lightroom color cast question of JPEG image

    Lightroom color cast question of JPEG image
    Camera Canon MKII Color Matrix Adobe RGB
    Photoshop CS Color Setting Adobe RGB (1998)
    Lightroom 1.2 as new lightroom user I did not think that I needed to choose a color setting or color profile until I am ready to print my photos. I have not done any preset camera calibration.
    Link to my website with example photo http://www.basecampphotos.com/color.jpg
    My question is why is Lightroom displaying the images with a yellow color cast ? The image is a print screen from Lightroom on the left and Photoshop on the right The color cast problem can be seen in the white walls of the stairway. Also when viewing the image with Windows Picture and Fax viewer the walls are white as expected.
    Any ideas or suggestions as to why Lightroom is displaying the images with the yellow color cast or what I need to do to correct the issue ?
    Thanks
    Jim

    Almost definitely a corrupt monitor profile. Time and again this turns out to be the cause of such differences between PS and LR. You need to recalibrate the monitor or if you do not have a hardware calibrator, delete the profile from windows' monitor properties pane to test and then get a hardware calibrator.
    P.S since you are using adobeRGB jpegs, Windows picture and Fax viewers cannot give you the correct colors even on a calibrated monitor. Those are not color managed programs (I believe picture viewer finally is in Vista but definitely not in XP which you appear to be using). Also, PS has to be correctly set up to always preserve embedded profiles and to ask when you have profile mismatches, otherwise even PS will give incorrect color. Make sure to set this up in Edit>Color settings.
    P.S.2: Make sure you are not applying defaults in Lightroom to your images either on import or elsewhere. Sometimes people by accident define develop defaults that in this case might contain a white balance shift. Go to LR preferences and open the Presets tab. Here click on "Reset all default Develop settings" and make sure that only the auto grayscale checkbox is ticked. For images that it might have already happened to, make sure to hit the reset button.

  • I have backed my Mac Book pro up to my external hard drive using time machine. My iPhoto now does not show any images, even when I upload from my iPhone

    I have backed my Mac Book pro up to my external hard drive using time machine. My iPhoto now does not show any images, even when I upload from my iPhone

    Mac 101: File Sharing
    Mac OS X 10.7 Help: Transfer files between two Mac computers
    Mac OS X 10.7 Help: Set up a Windows computer to share files with Mac users
    Mac OS X 10.7 Help: Use iDisk to share files
    Mac OS X: Sharing your files with non-Apple computers
    How to share a Mac's files with a PC and vice versa.

  • Have a MacBook Pro running Lion and an IMac running Snow Leopard. Want to Back up both images and restore on opposite machine. Essentially swapping images between hard drives. Is this possible and any "gotcha's" to look for? Thanks

    Have a MacBook Pro running Lion (10.7.9) and an IMac running Snow Leopard (10.6.8). Want to Back up both images and restore on opposite machines. Essentially swapping images between hard drives. Is this possible and any "gotcha's" to look for? Thanks

    If the MBP came with Lion, it most likely won't boot with SL. Easiest thing to do is create a bootable backup/clone of each to an ext HD, partitioned to hold each on a separate volume, ensure that the original machines can boot with their respective clones, and finally, try booting the other machine with the other clone. Images are useless since you can't boot with them to test them out.

  • Question about taking Images from video in FCP

    I just recently upgraded from pinnacle to FCP 7 and am loving it. My question is when I try to take a still Image from video using Quick Time Conversion, the image comes out blurry or with bars around the edges of people. At first I thought It was because I was trying to capture a moving Image, but then I tried it with someone standing still and I ran into the same problem.
    I shoot with a Canon XH-A1

    Take the exported file to Photoshop and use Image Size to correct the aspect ratio of the image. Apply the Deinterlace filter in Photoshop to remove the interlacing.

Maybe you are looking for

  • SSRS 2012 Configuration

    I have installed SQL Server 2012 Developer version and trying to configure SSRS for report manager URL and web service URL. But the url is not working and I am getting page not found error. Below are the screenshots of Reporting services configuratio

  • TS2972 iTunes sharing features issues only with my newest desktop

    Hi, hope someone will find an idea about my strange issue I migrated my iTunes Library on my more recent desktop (OS Windows7 64 Ultimate) I still have an old desktop (Windows XP Pro 32) and a laptop (Windows Home Premium 64) My 2 desktops are plugge

  • Restore External Drive From Time Capsule

    For reasons that I won't bore you with, I needed to perform a complete restore of of my MacBook Pro. My Time Capsule has been backing up the 'Pro's HD and a single external HD. Folowwing the instructions (boot from Snow Leopard install disk, run upda

  • QR Codes

    I use LiveCycle to create QR codes for use on our printed brochures. We would also like to use these codes on our websites as links to our other websites. How do I export the QR code for use on our Web? The only thing that I see is just placing them

  • To big for a clob ?!

    I've got this declaration in my ejb: @Lob @Column(name="LONGDESCRIPTION") private String longDescription; I'm inserting text into a clob and getting an error: javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials -