Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Component" Watch "Component" New topic
Author

Component

Javed Inamdar
Greenhorn

Joined: Mar 30, 2008
Posts: 13
Anybody tell me is there any component in Java whose width we can specify in double/long?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
Look in the API documentation for Component, and you can see whether it has any setSize methods or constructors or setWidth or anything which take double or long parameters.
Note that the getWidth method of the Dimension class has a different return type.

And if you plan to use a double for width, I would repeat the advice I gave somebody else here, earlier this week.
Buy a bigger screen.




Much bigger
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Javed Inamdar:
Anybody tell me is there any component in Java whose width we can specify in double/long?


Do you actually have a need for a Component with a double/long width?

Long would only be useful if you planned to have a Component that
was wider than 2.1 billion pixels, hence Campbell Ritchie's comment.

Double would only be useful if you planned to have a Component
with a fractional width, such as 33.3 pixels. This can actually
make sense at times. To that end the javax.swing.text.View class
has a getPreferredSpan() method that returns a float, and the
java.awt.geom.RectangularShape class has a getWidth() method that
returns a double. But neither of these are Components with a
capital C.


bitguru blog
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
Originally posted by Brian Cole:
Do you actually have a need for a Component with a double/long width?
I don't think it's that bad; you can probably fit a Component that size onto a screen 450 miles wide.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Campbell Ritchie:
I don't think it's that bad; you can probably fit a Component that size onto a screen 450 miles wide.
Such a screen might be useful if you wanted to construct a web-enabled billboard next to I-10 in West Texas, for example.
Javed Inamdar
Greenhorn

Joined: Mar 30, 2008
Posts: 13
Anybody is not going to understand my question here..............!!!

I want JPanel of size in double/long on which I have to draw digital waveforms. Then i will add this JPanel to JScrollpane so on scrolling user will see waveforms start to end.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

So you need a panel of over 2147483647 pixels, just for showing a wave form.
I'll tell you this: unless you want to create your own component system you can forget that approach, since Component uses ints for its size. No way you can change that.

Now I was thinking you could solve this problem by just adding a JScrollBar, listening to its adjustment and just painting the part you need. JScrollBar is also limited to ints though, so that's not the solution.

What you could possibly do is create your own scroll bar class that does support long sizes, and use the same approach: add it to the panel, and only paint the part that is needed based on the adjustment on the scroll bar. You can't use the Adjustable interface or the AdjustmentListener / AdjustmentEvent because these too are limited to ints. You'll have to rewrite the entire model, although you can use the API classes as an example.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Javed Inamdar
Greenhorn

Joined: Mar 30, 2008
Posts: 13
Thanks..........I will try that approach
Javed Inamdar
Greenhorn

Joined: Mar 30, 2008
Posts: 13
will you please give me some guidelines for implementing BoundedRangeModel for JScrollBar, better if you give one example
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Look at the source code for javax.swing.DefaultBoundedRangeModel for an example. In fact, try if you can use that one first.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Component
 
Similar Threads
Printing GUI current Coordinates in the GUI
Updating Components
How to handle JComboBox?
class vs component
Web services and Components?