Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2004

Tip: Looking for answers? Try searching our database.

JProgressBar look ?

Thread view: 
FET - 22 Jul 2004 10:02 GMT
Hello everyone,
I am trying to get a particular look of the JProgressBar for my Splash
screen. This JProgressBar should display a bar from left to right
(normal), but it shoulnd't be a continuous bar, it should be like a
dashed bar. How do I get that effect in Java ?

Thanks in advance.

Best regards.
ak - 22 Jul 2004 10:27 GMT
> Hello everyone,
> I am trying to get a particular look of the JProgressBar for my Splash
> screen. This JProgressBar should display a bar from left to right
> (normal), but it shoulnd't be a continuous bar, it should be like a
> dashed bar. How do I get that effect in Java ?

you should override paintComponent and use appropriate Stroke to draw
progress line.

for example:

Stroke myStroke = new BasicStroke(lineWidth, cap, join, miterlimit, dash,
dashPhase);

public void paintComponent(Graphics g) {
   //may be super.paintComponent();
   Graphics2D g2d = (Graphics2D)g;
   Stroke save = g2D.getStroke();
   g2D.setStroke(myStroke);
   g2D.drawLine(....)    ;
   g2D.setStroke(save);
   ....
   //and so on
}

Signature

Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader

FET - 23 Jul 2004 04:52 GMT
Hi there,
Thanks for the prompt response, but I am not very familiar with
Graphics2D. Can you please tell me do I calculate the co-ords for the
drawLine method since these are supposed to vary and increase with the
ProgressBar's setValue(int) method ?
Thanks in advance.

Best regards.

> > Hello everyone,
> > I am trying to get a particular look of the JProgressBar for my Splash
[quoted text clipped - 20 lines]
>     //and so on
> }
ak - 23 Jul 2004 05:16 GMT
> Thanks for the prompt response, but I am not very familiar with
> Graphics2D. Can you please tell me do I calculate the co-ords for the
> drawLine method since these are supposed to vary and increase with the
> ProgressBar's setValue(int) method ?
Source is your best friend - look first how it was made in original, then
make your own.

Signature

Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader

Andrew Thompson - 23 Jul 2004 07:07 GMT
>> ..Can you please tell me do I calculate the co-ords for the
>> drawLine method since these are supposed to vary and increase with the
>> ProgressBar's setValue(int) method ?

> Source is your best friend..

<http://www.physci.org/api.jsp?class=javax.swing.JProgressBar>

HTH

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

ak - 23 Jul 2004 08:40 GMT
> >> ..Can you please tell me do I calculate the co-ords for the
> >> drawLine method since these are supposed to vary and increase with the
[quoted text clipped - 3 lines]
>
> <http://www.physci.org/api.jsp?class=javax.swing.JProgressBar>

http://www.physci.org/source.jsp?class=javax.swing.plaf.basic.BasicProgressBar

Signature

Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader

Andrew Thompson - 23 Jul 2004 08:48 GMT
>>>> ProgressBar's setValue(int) method ?
>>
[quoted text clipped - 3 lines]
>
> http://www.physci.org/source.jsp?class=javax.swing.plaf.basic.BasicProgressBar

Oh, right.. rIIIght, yes.  

That *would* help to link to the source
to which you were referring.  But I
thought that made it *too* easy.

(Walks off brusquely, whistling loudly)

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

FET - 26 Jul 2004 06:54 GMT
Hey Guys,
That link was simply awesome. All I needed to do in my code was

   UIManager.put("ProgressBar.cellLength",new Integer(10));
   UIManager.put("ProgressBar.cellSpacing",new Integer(3));

That gives me the dashed pattern of the JProgressBar.

Thanks a lot for all your help!

> >>>> ProgressBar's setValue(int) method ?
>  
[quoted text clipped - 11 lines]
>
> (Walks off brusquely, whistling loudly)
ak - 26 Jul 2004 07:18 GMT
> That link was simply awesome. All I needed to do in my code was
>
>     UIManager.put("ProgressBar.cellLength",new Integer(10));
>     UIManager.put("ProgressBar.cellSpacing",new Integer(3));
>
> That gives me the dashed pattern of the JProgressBar.

I just wonder why they didn't put methods setCellLength() and
setCellSpacing() in JProgressBar

Signature

Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader

Andrew Thompson - 26 Jul 2004 13:40 GMT
> That link was simply awesome.

..ak'll point you in the right direction.   :-)

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.