• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Component

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody tell me is there any component in Java whose width we can specify in double/long?
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks..........I will try that approach
 
Javed Inamdar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic