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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:49:27+00:00 2026-06-05T22:49:27+00:00

i’m developing an app that has a jtable and user could start a download.

  • 0

i’m developing an app that has a jtable and user could start a download. i want to add in the table the name of download, the state and progress bar. I’m doing like this:

INIT JTABLE: ( CODE CREATED AUTOMATICALLY BY NETBEANS ( is there a way to edit it? o.O ))

jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Categoria", "Sottocategoria", "Progresso (%)"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setColumnSelectionAllowed(true);
        jScrollPane2.setViewportView(jTable1);
        jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

CREATE RENDERER:

class ProgRenderer implements TableCellRenderer {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            return (JProgressBar) value;
        }
    }

ADD IT TO THE LAST COLOUM:

jTable1.getColumn("Progresso (%)").setCellRenderer(new ProgRenderer());

Now i’ve created an ArrayList<Thread> to save the active threads, and a ArrayList<JProgressBar> to save all the progressbar existing in jtable ( right way? ).

Now to add new row i make like this:

DefaultTableModel d = (DefaultTableModel) jTable1.getModel();
work++; // to have a number of active threads.
progress.add(getProgress(x, total));
d.addRow(new Object[]{Html.categoria, "Inizio scansione", progress.get(work)});
                Thread t = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        int max = Html.totale;
                        for(int i=1;i<=max;i++){
                            try {
                                progress.get(work).setValue(i); // JUST FOR TRY
                                System.out.println(progress.get(work).getValue()); // TRY
                                Thread.sleep(1000);
                            } catch (InterruptedException ex) {
                        }
                    }
                });
                working.add(t);
                t.start();


private JProgressBar getProgress(int x, int total) {
        JProgressBar progressCsv = new JProgressBar();
        progressCsv.setMaximum(total);
        progressCsv.setStringPainted(true);
        progressCsv.setString("0%");
        return progressCsv;
    }

My problem is that progress isn’t updated, my approach is wrong? can you help me? thanksss

  • 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-05T22:49:28+00:00Added an answer on June 5, 2026 at 10:49 pm

    I recommend you:

    1. In table keep information about progress only.

      Class[] types = new Class [] {
          java.lang.String.class, java.lang.String.class, java.lang.Integer.class
      };
      
    2. Implement progress bar to extend JProgressBar

      class ProgRenderer extends JProgressBar implements 
      
      TableCellRenderer {
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            this.setValue((Integer)value)
            return this;
         }
      }
      
    3. Increment values

      @Override
      public void run() {
          int max = Html.totale;
          for(int i=1;i<=max;i++){
              try {
                  SwingUtiliites.invokeLater(new Runnable(){
                     public void run(){
                         jTable1.setValueAt(Integer.valueOf(i),row,2);
                     }
                  }
                  Thread.sleep(1000);
              } catch (InterruptedException ex) {
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I want use html5's new tag to play a wav file (currently only supported

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.