Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Quick answer</h1> <p>The problem you asked about was that the window decorations (the "frame", titlebar etc.) cover parts of the cropped image. (That's why I thought comparing with expected results or the result uploaded/saved to file might help).</p> <p>In terms of a solution you basically have to ensure that you do not resize the window as by its outer boundaries, but give the content the space needed. There are several ways to do that. MadProgrammer moved most of your code to a panel class and added an instance of that as the JFrame's content.</p> <p>Alternatively you could keep using the JFrame contentPane and just ensure that you set the size on it instead of the frame:</p> <pre><code>getContentPane().setPreferredSize(new Dimension(newWidth, newHeight)); pack(); </code></pre> <p>(methods are called on your JFrame instance, the solution works from Java 5 on)</p> <hr> <h1>Finding the answer yourself</h1> <p>The image cropping itself is fine. Your problem lies somewhere else and I want to help you find it yourself.</p> <h2>Minimize the problem</h2> <p>You have to narrow down where in your code the "strange things" happen. So do not stare at all your code but make a copy and, as a first step throw out what is not needed for the cropping. Throw out the upload stuff, you don't need it for cropping. A lot of your code deals with getting a filename by drag and drop. Shorten it down to either a command line option or a plain hardcoded string (hardcoded stuff is bad in general, but for debugging it's okay). And so on.</p> <p>Actually cropping does not need any GUI, really. So what happens if you write your cropped image to a file instead of displaying it in a window?</p> <h2>Know what to expect</h2> <p>GUI or not, put out the position(x,y) and dimension(width,height) of your selection. Now, how does the image cropped by your program compare to the same image cropped with the same parameters using gimp/ImageMagick/... ? Which parts of the image are missing?</p> <h2>Ask good questions</h2> <p>Following those steps and asking such questions, you should know what's wrong with your program. At the very least you will be able to ask a short and precise question about your problem. And on StackOverflow there will probably be someone who can answer it!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload