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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:44:28+00:00 2026-05-22T14:44:28+00:00

I am coding a simple java program. It takes three parameteres. A folder containing

  • 0

I am coding a simple java program. It takes three parameteres. A folder containing images, a desired output folder and an image watermark file. The programs copies a watermarked image of every image in the input folder into the output folder.

I am writing a simple GUI. The user introduces the three parameters and presses a button. The programm works but I want to provide feedback to the user. I want to be able to update a JLabel field everytime an image is processed.

In my WatermarkFolders class i use this code snippet to show the user some feedback:

Gui.FEEDBACK.setText(text);

The issue is that the JLabel does not update each time an image is processed. It just updates with the 100% complete output when the processing is done.
Is there an easy way to update this asynchrously. Thanks for the answers.

import javax.swing.*;

import java.awt.event.*;
import java.awt.*;
import java.util.*;


public class Gui extends JPanel {
    JButton button; 
    JFileChooser chooser;
    JLabel  inputLabel  = new JLabel("Directorio donde estan las imagenes");
    JTextField  inputField  = new JTextField(15);
    JLabel  outputLabel  = new JLabel("Directorio donde guardar las copias con marca de agua");
    JTextField  outputField  = new JTextField(15);
    JLabel  watermarkLabel  = new JLabel("Archivo marca de agua (gif transparente)");
    JTextField  watermarkField  = new JTextField(15);
public static JLabel FEEDBACK  = new JLabel("Número de Imágenes: ");
    JProgressBar pb;

    public Gui() {}

    public void go() {
        JFrame frame = new JFrame("Añadir Marcas de Agua a todas las imágenes de un directorio");
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        JButton button = new JButton("Añadir Marca de Agua a las imágenes");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                String input = inputField.getText();
                String output = outputField.getText();
                String watermark = watermarkField.getText();
                if(!input.equals("") && !output.equals("") && !watermark.equals("")) {
                    WatermarkFolders wm = new WatermarkFolders(input, output, watermark);
                    wm.run();       
                }   
            }
        });
        panel.add(inputLabel);
        panel.add(inputField);      
        panel.add(outputLabel);
        panel.add(outputField);
        panel.add(watermarkLabel);
        panel.add(watermarkField);      
        panel.add(button);
        panel.add(FEEDBACK);
        frame.getContentPane().add(BorderLayout.WEST,panel);
        frame.setVisible(true);
        frame.pack(); 
    }

    public static void main(String s[]) {
        Gui gui = new Gui();
        gui.go();
    }
}
  • 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-05-22T14:44:29+00:00Added an answer on May 22, 2026 at 2:44 pm

    Yes, processes that take time should not be on the EDT. Instead use a SwingWorker class to run the long running task while you make updates to the GUI at the same time.

    You can use the SwingUtilities.invokeLater() method to update the GUI from another thread, or you could have a Swing Timer check the status of a task and update the GUI while it still runs.

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

Sidebar

Related Questions

I'm coding a simple graphics program in Java. So, I have 3 classes. The
I am working on a simple tool to check Java coding guidelines on a
I have a Java program that generates a text file with a word per
I'm coding a simple local search algorithms for TSP in java. Here's the method:
Im coding a simple c/gtk+ app connected to a mysql database. The gui and
I am currently coding a simple Data Access Layer, and I was wondering which
I'm coding a simple code editor for a very simple scripting language we use
I'm coding a simple little class with a single method send an email. My
I am coding a simple login UserControl with two TextBoxes (Username and Password) and
I new with jquery and I can do simple coding with it. and I

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.