Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4491372

ProgressMonitor.setNote() method doesn't support "\n"

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      generic
    • OS:
      generic

      Description

      Name: yyT116575 Date: 08/13/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


      1) Run this program and click the Start button

      2) I have submitted my original code several times. Here is a really simple
      example of the use of one.

      ---

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class ProgressMonitorTester extends JFrame implements ActionListener {

        MyThread thread;
        JButton start;
        JPanel pane;

        ProgressMonitorTester() {
          pane = (JPanel)getContentPane();
          start = new JButton("Start");
          start.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              thread = new MyThread();
              thread.start();
            }
          });

          pane.add(start);

          setSize(100,100);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }

        public static void main(String[] args) {
          ProgressMonitorTester pm = new ProgressMonitorTester();
          pm.show();
        }

        public void actionPerformed(ActionEvent e){}

        class MyThread extends Thread {
          ProgressMonitor pm;

          public void run() {
            int maxCount = 100;
            pm = new ProgressMonitor(start,"Processing request..","0% Completed",0,maxCount);

            for (int i=0 ; i<maxCount ; i++ ) {
              pm.setProgress(i+1);

              try {
                Thread.sleep(250);
              } catch (InterruptedException e) {
              }

              double percent = 100.0 * (i) / (maxCount);
              pm.setNote((int)percent + "% Completed" + "\n" + (100-percent) + " % to go.");

              if(pm.isCanceled()) {
                JOptionPane.showMessageDialog(null,"Process ending prematurely.",
                    "User intervention",JOptionPane.WARNING_MESSAGE);
                return;
              }
            }

          }
        }
      }

      ---

      3) A small box appears where the newline character should appear
      (Review ID: 129846)
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: