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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:27:41+00:00 2026-06-18T05:27:41+00:00

Is there any way to refresh the counter in jLabel when a button is

  • 0

Is there any way to refresh the counter in jLabel when a button
is on click? I tried with repaint(), revalidate() methods already but all does not work.

When like button is on click :

    jButton_like.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                int count = 1;
                eForumLikeCounter likeAmount = new eForumLikeCounter(
                        userName, topicId, count);
                if (likeAmount.checkLikeAmount() == true) {
                    JOptionPane
                            .showMessageDialog(null,
                                    "Unable to perform like on the same thread by the same user");
                } else if (likeAmount.checkDislikeExists() == true) {
                    JOptionPane
                            .showMessageDialog(null,
                                    "You can only either like or dislike this thread");
                } else {
                    likeAmount.likeCounter();
                }
            }
        });
    }

Set up for database :

    public void SetUpLikeDislikeAmount() {
    int likes = 0;
    int dislike = 0;
    // Set Up Database Source
    db.setUp("IT Innovation Project");
    String sql = "Select likeDislike_likes,likeDislike_dislike from forumLikeDislike WHERE likeDislike_topics = "
            + topicId + "";
    ResultSet resultSet = null;
    // Call readRequest to get the result
    resultSet = db.readRequest(sql);
    try {
        while (resultSet.next()) {
            likes += resultSet.getInt("likeDislike_likes");
            dislike += resultSet.getInt("likeDislike_dislike");
        }
        resultSet.close();
    } catch (Exception e) {
        System.out.println(e);
    }
    jLabel_like.setText(Integer.toString(likes));
    jLabel_dislike.setText(Integer.toString(dislike));
}

Thanks in advance.

  • 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-18T05:27:43+00:00Added an answer on June 18, 2026 at 5:27 am

    Just use the setText() method of the JLabel. Probably something like:

    counter.setText("");
    

    or

    counter.setText("0");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any way to create a button which will on click take you
Is there any way to force a browser to refresh or empty it's cache,
In visual studio datasource designer is there any way to refresh a table and
Is there any way to quit from drawRect: without refresh the current UIView ?
Is there any way to redirect a page to a specific hash but prevent
Possible Duplicate: Disable browser's back button Is there any way to disable browser(specifically IE)
It seems to be weird but still : Is there any way I can
On pages with meta refresh, is there any way to disable meta refresh, within
Is there any way to refresh some part of page (e.g div/span) on selection
Is there any way in Notepad++ (or even with another tool) to change the

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.