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

  • Home
  • SEARCH
  • 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 8029669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:30:05+00:00 2026-06-05T00:30:05+00:00

The following code continues to give me: Cannot refer to a non-final variable textBoxPassword

  • 0

The following code continues to give me:

Cannot refer to a non-final variable textBoxPassword inside an inner class defined in a different method Login.java /ChurchWebLogin/src/com/gwt/churchweb/churchweblogin/client line 61

package com.gwt.churchweb.churchweblogin.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.Window;

public class Login extends Composite {

    public Login() {

        VerticalPanel verticalPanel = new VerticalPanel();
        initWidget(verticalPanel);
        verticalPanel.setSize("329px", "186px");

        Label lblNewLabel = new Label("Sign into your account");
        lblNewLabel.setStyleName("gwt-Login-SigninLabel");
        verticalPanel.add(lblNewLabel);

        FlexTable flexTable = new FlexTable();
        verticalPanel.add(flexTable);
        flexTable.setWidth("308px");

        Label lblNewLabel_1 = new Label("Username:");
        lblNewLabel_1.setStyleName("gwt-Label-Login");
        flexTable.setWidget(0, 0, lblNewLabel_1);
        lblNewLabel_1.setWidth("72px");

        TextBox textboxUsername = new TextBox();
        textboxUsername.setStyleName("gwt-LoginTextBox");
        flexTable.setWidget(0, 1, textboxUsername);
        textboxUsername.setWidth("204px");

        Label lblNewLabel_2 = new Label("Password:");
        lblNewLabel_2.setStyleName("gwt-Label-Login");
        flexTable.setWidget(1, 0, lblNewLabel_2);
        lblNewLabel_2.setWidth("66px");

        TextBox textBoxPassword = new TextBox();
        textBoxPassword.setStyleName("gwt-LoginTextBox");
        flexTable.setWidget(1, 1, textBoxPassword);
        textBoxPassword.setWidth("204px");
        flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
        flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT);

        CheckBox chckbxRememberMeOn = new CheckBox("Remember me on this computer");
        chckbxRememberMeOn.setStyleName("gwt-Checkbox-Login");
        flexTable.setWidget(2, 1, chckbxRememberMeOn);

        Button btnSignIn = new Button("Sign In");
        btnSignIn.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (textboxUsername.getText().length() == 0
                        || textBoxPassword.getText().length() == 0) {
                        Window.alert("Username or password is empty."); 
                    }
            }
        });

        btnSignIn.setStyleName("gwt-Login-SigninButton");
        flexTable.setWidget(3, 1, btnSignIn);



    }


}
  • 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-05T00:30:06+00:00Added an answer on June 5, 2026 at 12:30 am
    final TextBox textboxUsername = new TextBox();
    

    and

    final TextBox textBoxPassword = new TextBox();
    

    should fix it.

    Java requires references to variables from inner classes to be final variables (for reasons of concurrency management, I suppose).

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

Sidebar

Related Questions

The following code continues to be displayed even if there are entries in my
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();
Following code: <%= render 'shared/error_messages', f.object %> where f.object is instance of a class
Following code is generated by a for loop. <form action=saveresponse.php method=POST name=mainForm> <input class=cbox_yes
Consider the following code : class TestTimerGC : Form { public TestTimerGC() { Button
I have a slider that rotates between different divs nicely with the following code:
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following code gets executed whenever I want to persist any entity. Things seems to
Following code is a pretty simple and complete JQuery Dialog. Everything works. Problem is

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.