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.

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 thejava.awt.geom.RectangularShape class has a getWidth() method that returns a double. But neither of these are Components with a capital C.

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.