• Post Reply Bookmark Topic Watch Topic
  • New Topic

Change size of progress monitor

 
Eric Juneau
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I change the size of the javax.swing.ProgressMonitor?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Progress monitor is not a visible component.
More details here
 
Robert Evans
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True, but you *know* what he was asking, why not help out?

I'll at least share what I found, maybe somebody else can chime in.

The designers of the ProgressMonitor class used a JDialog to display the progress monitor. Unfortunately, they made the JDialog field private with no accessors, so...you are out of luck, there is really no way to get a reference to the JDialog so that you can resize it.

I even tried padding the title or note with spaces, but no joy.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert Evans wrote:True, but you *know* what he was asking, why not help out?


True. And I did provide a link for details. Did you find time to go through that link?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Unfortunately, they made the JDialog field private with no accessors, so...you are out of luck,
> there is really no way to get a reference to the JDialog so that you can resize it.

just use the ProgressMonitor code, changing all the 'ProgressMonitor' to your own name
you'll need to add your own extended JOptionPane class for getWindowForComponent()
you'll also need to decide if you want to worry about SwingUtilities.SharedOwnerFrame,
I just commented it out, otherwise additional code would be required
and, the the ripped code, change dialog.pack() to dialog.setSize(1000,200) (or whatever size)

anyway, took less than 10 minutes, and a 1000 x 200 ProgressMonitor displayed OK
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same kind of problem. Can you guide me how to increase the size of the ProgressMonitor.

I have the code like this :

public JFrame getMyParentFrame()
{
return new JFrame();
}

ProgressMonitor progressMonitor = new ProgressMonitor(context.getMyParentFrame(),
"PM Search in progress...",
"Calculating file numbers...",
0, 100);

progressMonitor.setMillisToDecideToPopup(0);
progressMonitor.setMillisToPopup(0);
progressMonitor.setProgress(1);


String note = "Searching file " + currentFileNumber +
"/" + totalNumberOfFiles + "... Found " +
searchResults.size() + " records...";

progressMonitor.setNote(note);


In the above code "currentFileNumber " ,"totalNumberOfFiles " and searchResults.size() are some dynamic values.

In my progress monitor window, the note was displayed only till ...Fou as set in the note.

The searchResults.size() + " records..." is not shown in the progress monitor window. but if user enlarges the corners of the window he is able to see the full message.

Is it possible to increase the size? please help
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I have the same kind of problem. Can you guide me how to increase the size of the ProgressMonitor.

steps are in previous post - just tested again, java 1.6.0_20, and 1000x200 displayed fine.
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Michael, you have told like this

just use the ProgressMonitor code, changing all the 'ProgressMonitor' to your own name
you'll need to add your own extended JOptionPane class for getWindowForComponent()
you'll also need to decide if you want to worry about SwingUtilities.SharedOwnerFrame,
I just commented it out, otherwise additional code would be required
and, the the ripped code, change dialog.pack() to dialog.setSize(1000,200) (or whatever size)

anyway, took less than 10 minutes, and a 1000 x 200 ProgressMonitor displayed OK

As I am new to swings, I am not able to understand your words.

I request you to please post the code here. That will be more helpful. Thanks in advance
 
Darryl Burke
Bartender
Posts: 5154
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a forum, not a code mill.
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:This is a forum, not a code mill.


Hemanth, read this.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I request you to please post the code here. That will be more helpful. Thanks in advance

you already have 99+% of the code in the source file.

in the last 12 months this thread has been viewed 500+ times (check listing at bottom of page).
everyone else has been able to follow the steps.

> As I am new to swings..

Perhaps you should start learning on simpler projects, and it is 'Swing' not 'swings'

 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael, I have taken the source code of ProgressMonitor and chnaged the names and during compilation I am stuck up. You told that

you'll need to add your own extended JOptionPane class for getWindowForComponent()
you'll also need to decide if you want to worry about SwingUtilities.SharedOwnerFrame,



I am getting this compilation error:





I have one more doubt here: Do I have to add this whole new ProgressMonitor class to my project code to resize progressMonitor? Also for JOptionPane problem in the above you mean to say that I have to write one more class that extends JOptionPane and use this new class to extend in the new ProgressMonitor class?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you've copied the progressMonitor code into it's own separate file, about line 140 you'll find this inner class

a few more lines to this

which needs to be changed to this

and MyOptionPane is a separate class (just add it at the end, and you can call it anything you want)

a few more lines after ...MyOptionPane.getWindowForComponent(... you'll find this line

this is where you size the progressMonitor to what you want, so change it to

in the same section as all the above, that only leaves

I commented it out, and everything works fine. You'll have to decide how you want to handle it,
as mentioned in my first reply in this thread
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!