-1 to normal width convert does not work

Hello, i'm pretty new to java and i was trying to make a class that add's a picture to a JFrame. I wanted to make it so that if you use -1 as the width or height parameter it converts it into the normal width or height of the picture.
It converts the -1 into the correct number but for some reason the image won't show up and i can't figure out why. If i use for example 100 it works perfectly. could somebody help me?
this is the code:
package plaatje;
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class Main extends JFrame{
    private tekenPlaatje tekenplaatje = new tekenPlaatje();  
    public static void main(String[] args) {
        Main frame = new Main();
        frame.setSize(500,300);
        frame.createGUI();
        frame.show();
    private void createGUI(){
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container window = getContentPane();
        window.setLayout(new FlowLayout());
        File bestandsPlaats = new File("C:\\Users\\Per\\Pictures\\28gb.jpg");
        tekenplaatje.tekenen(window, bestandsPlaats, -1, 384);
package plaatje;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.Graphics;
public class tekenPlaatje {
    private Image plaatje;
    private int w,h;
    private JPanel panel;
    // teken plaatje in frame, bepaal hoogte er van
    //-1 BIJ HOOGTE EN BREEDTE VOOR NORMALE GROOTTE
    public void tekenen(Container window, File bestandsPlaats, int breedte, int hoogte){
        panel = new JPanel();
        panel.setPreferredSize(new Dimension(breedte,hoogte));
        panel.setBackground(Color.white);
        window.add(panel);
        krijgPlaatje(bestandsPlaats);
        if(breedte==-1) breedte=w;
        if(hoogte==-1) hoogte=h;
        tekenPlaatje(breedte,hoogte);
    //privates
    private void krijgPlaatje(File bestandsPlaats){
        try{
            plaatje = ImageIO.read(bestandsPlaats);
            w = plaatje.getWidth(null);
            h = plaatje.getHeight(null);
        catch(IOException exception){
            JOptionPane.showMessageDialog(null, "fout in iostream: " + exception.toString());
    private void tekenPlaatje(int x,int y){
        final int breedte = x;
        final int hoogte = y;
        System.out.println(breedte);
        System.out.println(hoogte);
        int delay = 70;
        ActionListener taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                Graphics paper = panel.getGraphics();
                paper.drawImage(plaatje,
                                0, 0, breedte, hoogte, /* nieuwe plaatje */
                                0, 0, w, h,     /* grootte normale plaatje */
                                null);
        new Timer(delay, taskPerformer).start();
}

Never mind. solved it.

Similar Messages

  • The PDF to Excel converter does not work on the reports I need to convert so I need to cancel my order

    I just purchased Export PDF but when I tried it I got a message that it doesn't work on the PDF I need to convert. I need to cancel my order and not be charged.

    Cancel the Cloud http://forums.adobe.com/thread/1439535?tstart=0 may help

  • Converter, does not work. I paid for nothing

    I just paid 20 euros for purchasing one year Adobe service Converter from PDF to Docs or Excell. I tried some recent PDF files I have .  BIG ****, nothing!! Results no readable documlents. I Think IT'S BIG BIG JOke ... I hope I wiil receive credit from Adobe (????) but no way to contact cutumer support!!!!! ?????? big bibg ****!!!!!!

    My Macbook Pro is relatively new
    Then it should still be under warranty. Take it in for repair.

  • Horizontal width - AUTO does not work in IE

    ----- sorry someone sent me a screen grab and my description
    was wrong... I'll repost later, sorry!

    use the html page published by flash to isolate the issue to your embedding html.

  • When trying to PDF a webpage into a PDF, it does not work, I go through all the steps as normal, and It does nothing. I can repeat my action, where instead of "printing" to adobe, it saves the file, which it doesn't save it at all. I can't even find the o

    When trying to PDF a webpage into a PDF, it does not work, I go through all the steps as normal, and It does nothing. I can repeat my action, where instead of "printing" to adobe, it saves the file, which it doesn't save it at all. I can't even find the original in my work folder. I need to know how to stop this from happeing and get it back to the way it has been working he last 6 months since i purchased this program.

    Hi pissedadobeuser,
    Does this issue occur with any particular web page?
    Are you able to print the webpage to 'Adobe PDF' to convert it to pdf.
    Which Browser version, OS version and Acrobat version are you using?
    Regards,
    Rave

  • Converting .docx with chart to .pdf does not work correctly

    I have a docx file with an excel chart and a hyperlink in it. The chart is a line chart with data makers on the lines. One set of data markers are circles. The chart is simply copied from excel and pasted into word. I am using word and excel 2007 and adobe acrobat 8 standard on windows XP SP2. all software is fully updated.
    When I convert this doxc file to pdf, the circle data markers from the chart are greatly enlarged and obscure the text and chart. The hyperlink works fine. This occurs when I use the acrobat plug-in within word to create a "quick and simple" pdf. this also occurs when I open adobe and choose create pdf from file. I cannot use the word plug-in to create a "fully functional" pdf. This feature simply does not work.
    When I convert the file to a pdf using the adobe printer/distiller, the circle data markers on the chart are fine, but the hyperlink no longer functions.
    I can copy the chart from excel and paste it into powerpoint and publisher and the conversion to pdf works fine. i can also create a pdf of the chart from excel to pdf without problems, so it appears to be a word to pdf issue.

    Thanks Bill
    Perhaps I was not clear enough though. I am not really concerned with the hyperlinks.
    The main problem is the excel chart. When I use PDF Maker the circle data markers from the chart are greatly enlarged and obscure the text and chart. The only way to make the chart look normal is to use the distiller, which kills the hyperlinks. I would rather use PDF Maker, keep the functionality of the hyperlinks, and have the excel chart look normal. The PDF Maker distorts the circle data markers on the chart and makes the page unreadable. That is what I need to fix.
    I realize the simple solution is to use something other that circles for data makers, but I have a lot of charts and don't want to spend the time remaking them all.

  • I've become increasingly frustrated with the ipad adobe app. I've subscribed to be able to convert my pdf files into word documents and it has yet to work I've paid for a service that does not work which in turn makes me a disgruntled customer to say the

    I've become increasingly frustrated with the ipad adobe app. I've subscribed to be able to convert my pdf files into word documents and it has yet to work I've paid for a service that does not work which in turn makes me a disgruntled customer to say the least very disappointed with such horrible service

    Which service did you subscribe to?  Adobe PDF Pack?
    Once I know the service that you subscribed to, I can move this post to the right forum so that you can get in touch with the folks who can assist you.

  • Front page opens works shortly freezes. only yellow green buttons work. I click yellow to minimize normal top bar menu appears I choose new page, opens works normally. The restart saved tabs does not work on that first page.

    front page opens works shortly freezes.
    only yellow green buttons work. I click yellow to minimize normal top bar menu appears I choose new page, opens works normally.
    The restart saved tabs does not work on that first page.

    Hi @prdstudio3 ,
    Thank you for visiting the HP Support Forums. The Serial Number needed to be removed from your Post. This is From our Rules of Participation:
    Protect privacy - yours and others'. Don't share anything about yourself that you would not want to see on a road-side billboard. Don't post contact or other personal information-your own or anyone else's-or any content that you receive in one-to-one communications without the author's consent. For example, don’t post your computer’s serial # or contact information publicly, and do not allow someone you don’t know to remotely take control of your computer.
    If you need people to contact you directly, either ask them to send you a private message or subscribe to the thread so you will be notified when there are replies. You may also click on your name anywhere in the forum and you will be taken to your profile page, where you can find a list of threads you have participated in.
    Sharing personal email addresses, telephone numbers, and last names is not allowed for your safety. If you have any questions feel free to send me a private message in reply.
    Thank you
    George
    I work for HP

  • Convert Sample Rate on Import- does not work

    Setting: *"Automatically convert sample rate of imported audio"*
    You'll want to set this if you have audio on your computer
    that wasn't sampled at 44k. It prevents your imported audio from
    sounding like Mickey Mouse drinking a gallon of espresso and inhaling helium.
    HOWEVER...It does NOT work when you drag audio into the project from
    Logic's internal File Browser.
    Dragging audio into the project from Logic's Browser,
    or browsing to the file in Logic's Browser and choosing to
    "Add selected Files to Audio Bin",
    will NOT convert to the audio's sample rate.
    Sample rate of your audio is only converted if you do: "Import audio file",
    then browse to the file(again) in a popup browser dialog, and then choose import.
    If the audio is already in your Audio Bin, choosing "Convert File"
    will bring up another Finder Dialog asking you where you want the
    converted audio to be placed.
    Now you'll have to Browse (yet again) to the song's folder, because that's where
    you'll probably want it anyway, and choose to put
    your converted audio into the song's folder.
    Please realize: If a composer or producer wants his/her audio to sound like
    Mickey Mouse on Helium and Espresso, he will do it after the fact, on purpose, using a plugin.
    Is it too much to ask, to have this Setting do what it says it does, with ALL audio brought into the song?
    No matter how I bring audio material into a Project, the sample rate should always conform
    to the Project's sample rate.

    Hi there
    I've been using Captivate since version 1. And to be honest, I'm not sure I've ever seen the option work. If it does work, I'd also like to know under what conditions it works. Perhaps it only works with certain applications. I'm not sure. Largely I've ignored the option exists because I've never recorded anything where I wanted tooltips to be an option. I've never wanted to simulate to that detail.
    You should probably consider filing a bug report.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • I just bought my first iphone 4 actually i bought two and for some reason on both phones one of the speakers does not work im just wondering if this is normal because i took it back to the store and they told me all of the phones are the same?????

    i just bought my first iphone 4 actually i bought two and for some reason on both phones one of the speakers does not work im just wondering if this is normal because i took it back to the store and they told me all of the phones are the same?????

    There is only one speaker, what looks like another speaker is actually a microphone. All iPhones only have one speaker down by the dock connector.

  • Apple TV2 led does not work, but apple tv2 works ok - is this normal

    I have an apple tv2 that seems to work ok but the led on the front does not work.. is this normal? is the led burnt out?
    is there a way to get it back working??
    i have restored in via the tv menu and i have restored it via usb cable to itunes..
    still no luck..
    is there some option that is causing it to not work?
    will it work ok with the led not working?
    what is it for??
    thanks

    Try:
    - Resetting the iPod:
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    - Resetting network settings: Setting>General>Reset>Reset Network Settings

  • I use OverDrive to get audiobooks from my library to listen on my ipod. Does not work since latest update of ipod. Converts the WMA and acts like it is putting it on the ipod but then it isn't there.

    I use OverDrive to get audiobooks from my library to listen on my ipod. Does not work since latest update of ipod. Converts the WMA and acts like it is putting it on the ipod but then it isn't there.

    Downgrading the iOS is not supported by Apple.Have yo tried:
    - Backing up and restore from backup. See:                                               
    iOS: Back up and restore your iOS device with iCloud or iTunes
    - Restore to factory settings/new iOS device.                       
    - Go to the OverDrive support site

  • My aux input does not work. When i put in my headphones my mac does not respond, and my speakers just continues as normal. What to do?

    My aux input does not work. When i put in my headphones my mac does not respond, and my speakers just continues as normal. What to do?

    I had the same issue. Initially i thought i need to take it to apple for replacing the aux port. But luckily I was able to fix it by resetting the PRAM . To reset the PRAM
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Immediately press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.Continue holding the keys down until the computer restarts, and you hear the startup sound for the second time.
    Release the keys.
    Resetting PRAM may change some system settings and preferences. Use System Preferences to restore your settings.
    You can try this before you take to apple store. It may work if you are lucky. Good luck

  • Since upgrading my Macbook pro with Yosemite, I have problem with my Xerox Work Centre 3045 - the printer works normally but it does not recognise the scanner, can you help with this?

    Since upgrading my Mac book pro with Yosemite, I have problems with my Xerox Work Centre 3045 printer. The printer works normally but it does not recognise scanner, I can not scan anything. Can you help?

    Open Disk Utility and select your hard drive, then Repair Permissions, it will probably return a very large number of errors, primarily printer and library errors, so run it a second time.  Then restart the MacBook Pro.  If it still will not scan, try using Image Capture from Finder > Applications and see if that will work.  If not, contact Xerox about updated drivers.

  • MDT - Custom Reference Image does not work with Task Sequence, normal Windows 7 Enterprise Iso media works fine.

    Hi,
    Our MDT server is acting strange!
    I have previously had this system running without problem - i could both capture and deploy computers as is and no changes have been made to mdt.
    But my latest capture does not work. When i capture my reference maching in my VM environment it completes without errors and i can import the latest wim file.
    When i deploy the tast sequence, it install the custom Wim image, but it ends up with "login" screen as the administrator i have entered for the capture/deploy sequence, but it goes to stop at this point and applications is not installed.
    If i change the ISO in the task sequence under Install OS step, to a clean Win7 install media then the capture completes and install applications.
    I have also tried to:
    Capture reference without password
    Capture reference without Windows updates
    Customsettings.ini, bootstrap, BDD.log and SMSTS.log to be found here: https://onedrive.live.com/redir?resid=ED5029A20300B814!365&authkey=!AALV1b2ubD0laEE&ithint=folder%2cini
    Hope you will be able to assist,
    Regards,
    Anders

    if you have noticed your smsts.log, there is same error multiple - 
    Executing in non SMS standalone mode. Ignoring send a task execution status message request
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    User did not specify local data drive TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    Volume A:\ is not a fixed hard drive TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    Volume D:\ is not a fixed hard drive TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    Volume X:\ is not a fixed hard drive TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    Volume Z:\ is not a fixed hard drive TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    TSM root drive = TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    We do not find an available volume to store the local data path
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Set a global environment variable _SMSTSNextInstructionPointer=1
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Set a TS execution environment variable _SMSTSNextInstructionPointer=1
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Set a global environment variable _SMSTSInstructionStackString=0
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Set a TS execution environment variable _SMSTSInstructionStackString=0
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Save the current environment block TSManager
    1/23/2015 12:50:37 PM 1656 (0x0678)
    pszPath[0] != L'\0', HRESULT=80070057 (c:\qfe\nts_sms_fre\sms\framework\core\ccmcore\path.cpp,58)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Filesystem::Path::Add(sEnvPath, EnvDataFileName, sEnvPath), HRESULT=80070057 (e:\nts_sms_fre\sms\framework\tscore\environmentlib.cpp,639)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Failed to save environment to  (80070057)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    TS::Environment::SharedEnvironment.saveEnvironment(szPath), HRESULT=80070057 (e:\nts_sms_fre\sms\client\tasksequence\executionengine\executionenv.cxx,842)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Failed to save the current environment block. This is usually caused by a problem with the program. Please check the Microsoft Knowledge Base to determine if this is a known issue or contact Microsoft Support Services for further assistance.
    The parameter is incorrect. (Error: 80070057; Source: Windows)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    SaveEnvironment(), HRESULT=80070057 (e:\nts_sms_fre\sms\client\tasksequence\executionengine\executionenv.cxx,420)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Failed to persist execution state. Error 0x(80070057)
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Failed to save execution state and environment to local hard disk
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Start executing an instruciton. Instruction name: Gather local only. Instruction pointer: 1
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Set a global environment variable _SMSTSCurrentActionName=Gather local only
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    Set a global environment variable _SMSTSNextInstructionPointer=1
    TSManager 1/23/2015 12:50:37 PM
    1656 (0x0678)
    what about the mass storage driver in your boot image, is it updated?
    Md.Waseem Please remember to click “Mark as Answer” on the post that helps you. Thank you.

Maybe you are looking for

  • Error: while configuring logs for changes in infotype data

    Hi All, I am configuring the following Tables for maintain logs for changes in infotype data. V_T585A, V_T585B and V_T585C While configuring V_T585B, when i input * in 'field name' column it gives me an warning message " All data fields in **** infot

  • How can I get Adobe Shockplayer and Flashplayer to work?

    Yesterday I had a problem with a program that I installed.  My pc wouldn't open Windows any longer.  So I chose F8 > Last known configuration that worked.  That fixed the problem but Adobe Flashplayer and Shockwave Player stopped working.  I get a bl

  • Keeping 1 photo selected for printing AFTER editing

    I still haven't adapted comfortably to iPhoto '08, because it's hard to change one of my iPhoto habits. Previously, after selecting a photo to edit, I'd click DONE and then go straight to File>Export or File>Print to output the edited photo. With iPh

  • Oracle 11gr2 ODBC - error updating linked table (Ora 01722 and 01461)

    Good day folks, My shop has just moved to 11gR2 client and server. We were previously using 11gR1 with no issues (and before that, 10, 9, 8, etc). After moving from 11r1 to 11r2, we began getting errors from some of our MS Access ODBC applications wi

  • How to build LOV based on colon deliminated values in table?

    Hi All, I have a CUSTOMERS table with a column TYPES. This column stores colon deliminated values coming from a standard shuttle element eg.: CUSTOMER_NAME   TYPES Customer 1      1:2:3 Customer 2      2:3:4I need to build a query which will return m