File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Component

 
Javed Inamdar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody tell me is there any component in Java whose width we can specify in double/long?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 886
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Javed Inamdar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks..........I will try that approach
 
Javed Inamdar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will you please give me some guidelines for implementing BoundedRangeModel for JScrollBar, better if you give one example
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the source code for javax.swing.DefaultBoundedRangeModel for an example. In fact, try if you can use that one first.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic