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 9088755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:58:31+00:00 2026-06-16T21:58:31+00:00

I am trying to create a browser to get the hands on practice on

  • 0

I am trying to create a browser to get the hands on practice on JavaFX. I implemented the Back button with Stack.

  1. When the URL of the page change, add url to Stack(java.util.Stack)
  2. When back button is pressed, pop 1 item from Stack and show the page

But this does not work in case of URL redirection. Eg. I entered http://www.google.com , It automatically redirects to http://www.google.co.in (India). This makes 2 entries in Stack which corrupts the Back button logic since the page is the same but taken from different locations.

Please assist me in fixing this problem.

Thanks for your help

webEngine.locationProperty().addListener(new ChangeListener<String>(){

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            //urlField is a text Field
            urlField.setText(newValue);
            addURLToStack(oldValue);
            if(backButtonStack.size() ==1){ //means on last url of Stack
                backButton.setDisable(true);
            }
            else{
                backButton.setDisable(false); 
            }}      
    });
 backButton.setOnMouseClicked(new EventHandler<MouseEvent>(){

        @Override
        public void handle(MouseEvent event) {
            if(backButtonStack != null && !backButtonStack.isEmpty()){
                String poppedURL = backButtonStack.pop();
                webEngine.load(poppedURL);

            }
        }

    });
private void addURLToStack(String url) {
    if(backButtonStack == null){
        backButtonStack = new Stack<String>();
    }

    backButtonStack.push(url);
}
  • 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-16T21:58:32+00:00Added an answer on June 16, 2026 at 9:58 pm

    You don’t need to solve this problem.

    JavaFX WebEngine has a WebHistory object which has all the API you need to completely manage the history and it should take care of not adding redirected URLs to the history for you. And, if you don’t want to use that, you can use webengine.executeScript("history.back()"); to have the engine’s JavaScript engine handle the navigation for you.

    What Chris Gerken says is right about monitoring the http status return codes to work out whether or not to place the object in history. The difficulty with that in the JavaFX WebEngine is that the http status return codes happen at the network layer and are not exposed through the WebEngine interface. So if you just monitor the location property of the WebEngine as you are doing, it is going to be really hard to get a high quality navigation interface. I found this out when I implemented a JavaFX WebBrowser to get JavaFX experience and my browser’s history mechanism using an ObservableList with a current index pointer had exactly the same issue as you point out in your question. If I were to implement the same functionality again today, I would just make use of the new WebHistory functionality provided by the later JavaFX versions, rather than writing my own.

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

Sidebar

Related Questions

Im trying to create my own url scheme so my android app can get
I am trying to create very simple image browser with jQuery. I am doing
Trying to create a new Dedicated Cache Role in Windows Azure but get the
I'm trying to create a mini browser inside a window using extJS. Here's what
I am new to xcode and I'm trying to create a web browser with
I create a browser like so, and manually navigate to the web page I
I am trying to create a simple service-like application. I am using the browser
I'm trying to create a file download page. This page when requested should prompt
I am trying to create a site-specific browser application. I've created a new Cocoa
I am trying to create a page that lets a user delete an image

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.