Skip to content

Commit

Permalink
Add save confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
cr5315 committed Feb 14, 2017
1 parent 71eb350 commit 1ea5ab0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/me/butzow/pixelbreak/ImageForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
<text value="About"/>
</properties>
</component>
<component id="c7b2a" class="javax.swing.JLabel" binding="statusLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
</children>
</grid>
</form>
13 changes: 11 additions & 2 deletions src/me/butzow/pixelbreak/ImageForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class ImageForm implements ActionListener, ChangeListener {
private JSpinner spinner2;
private JSpinner spinner3;
private JSpinner spinner4;
private JLabel statusLabel;

private Callback callback;
private JFrame frame;
Expand Down Expand Up @@ -64,8 +65,16 @@ public void saveImage(BufferedImage brokenImage) {
try {
File outFile = new File(outDir, selectedFilename);
ImageIO.write(brokenImage, "png", outFile);
} catch (IOException e) {
e.printStackTrace();

statusLabel.setText("Saved!");
Timer timer = new Timer(2000, e -> statusLabel.setText(null));
timer.setRepeats(false);
timer.start();
} catch (IOException ignored) {
statusLabel.setText("Error!");
Timer timer = new Timer(2000, e -> statusLabel.setText(null));
timer.setRepeats(false);
timer.start();
}
}

Expand Down

0 comments on commit 1ea5ab0

Please sign in to comment.