Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7870991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:46:40+00:00 2026-06-03T01:46:40+00:00

I am try to do an undo button using stack so that it would

  • 0

I am try to do an undo button using stack so that it would remove the effect applied such as blur etc , but when i try to pop out the image i stored in the stack something goes wrong , please help me , thanks in advance!.

Applying effect:

if (e.getSource() == btnGrayscale) {
  if (buffImage != null) {
    Imagesteps.push(buffImage);
    ImageEffects ie = new GrayscaleEffect();

    buffImage = ie.GrayscaleEffect(buffImage);
    Icon icon = new ImageIcon(buffImage);
    lblImage.setIcon(icon);
    statusBar.setText("Image is now Grayscaled");
  }
}

UNDO method:

if (e.getSource() == undoimageitem) {
  BufferedImage temp = (BufferedImage) Imagesteps.pop();
  Icon icon = new ImageIcon(temp);
  lblImage.setIcon(icon);
  statusBar.setText("Undo");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:46:43+00:00Added an answer on June 3, 2026 at 1:46 am

    From the exception you are getting it seems that you are trying to pop from an empty stack. To avoid this error you should ideally, before popping, make sure that the size of the stack is at least greater or equal to 1.

    As to why you are getting the exception, the reasons could be many. Two that come to mind are these:

    • You are re-initialzing/clearing the stack at some point in your code between pushing items and popping them from the stack.

    • Assuming that, like most buttons, the method is activated by one click, you are double clicking the button, thus causing the event to fire twice, which could lead into the code performing two pop operations which is causing the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

try: spam.foo except AttributeError: do_somthing() (Is it wise to check an attribute like that
I try to grok this method. Is that only useful when I'm dealing with
I try to use the git filter-branch to remove some big files. This was
I'm using boost::signals and leaking memory when I try to connect multiple signals to
I am refactoring a class so that the code is testable (using NUnit and
How do you roll back a failed rails migration? I would expect that rake
i try to implement a redo undo in my windows form application. i build
i need to clone an entire treeview to implement Undo\Redo actions. i try in
i've been unsuccessfully attempting to create my own undo/redo classes that work well with
I would like to create a stack with array of int (2 dimensional :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.