• 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

Format to display Filepath in JTextArea/JTextField/ JLabel

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to display a file path in JTextarea/ JLabel.

I want to display it in following format , "C:/Program Files/... .../abc.xml"
means if file path i too long then i want to display it by above format starting with left & ends at right & middle part can be shown in dots.

so how can I show this format in JTextArea/ JTextFiled/ JLabel.
which alignment should i use for this.

Please help me...

Thanks
Sharda
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off, you need to firm up those specifications.

1. What constitutes the 'right part' (the last slash and everything that follows it? a fixed number of characters?)
2. What constitutes the 'left part' (as many characters as can be accommodated? up to the last slash that can be accommodated?)
3. Depending on the first two specs, what's the fallback if the 'right part' and 'left part' together are too long to display?
4. In the event that dots are required, what's the minimum (and maybe maximum) number of dots? how are they to be grouped?
5. Does the solution have to cater to resizing of the Swing component used for display? With changing the LaF? With setting a different Font?

Whatever the spec, you'll want to look into java.awt.font.TextLayout and its getBounds() method.

Oh, and does this have anything at all to do with JSP (Java Server Pages)? Looks to me it would sit better in the GUI forum.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a JSP question. Moved to the Swing forum.
 
Anuj Joshi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic