Missing preferredWidth feature (or workaround)

A couple of times I have ran into a problem where I want to create a swing component where the default preferred dimension is wider that I want. I miss a feature where I can set preferredWith to something (and not specify the preferred height).
Example:
JLabel descriptionLabel = new JLabel("<html>Yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi yadi</html>");
This label's preferredDimension suggest that the label is printed on one line, however the component supports wrapping to multiple lines fines, and in my case this would give a much nicer result.
I am aware of that adding <br> tags would solve the problem to some degree, but what I am looking for is a solution using Swing layout mechanism.
Have anyone had the same problem and found a simple solution for it?
Kind regards,
Morten

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.text.View;
public class Tester {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        JLabel label =
                new JLabel("<html>Yadi yadi yadi yadi yadi yadi yadi yadi "+
                "yadi yadi yadi yadi yadi yadi yadi yadi</html>");
        label.setPreferredSize(getPreferredSize(label.getText(),true,150));
        frame.getContentPane().add(label);
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    private static final JLabel resizer = new JLabel();
    /**Returns the preferred size to set a component at in order to render
     * an html string.  You can specify the size of one dimension.*/
    public static java.awt.Dimension getPreferredSize(String html,
            boolean width, int prefSize) {
        resizer.setText(html);
        View view = (View) resizer.getClientProperty(
                javax.swing.plaf.basic.BasicHTML.propertyKey);
        view.setSize(width?prefSize:0,width?0:prefSize);
        float w = view.getPreferredSpan(View.X_AXIS);
        float h = view.getPreferredSpan(View.Y_AXIS);
        return new java.awt.Dimension((int) Math.ceil(w),
                                      (int) Math.ceil(h));
}It dosen't seem to work if you just specify a height, but you can play around with it. The view class also has a pretty interesting break method that I haven't tried yet.

Similar Messages

  • After updating to the latest version of Firefox on my Mac there is no progress bar for the page load. I really miss this feature and can't seem to find a way to obtain it.

    The page load progress bar that was on the lower right of the window is no longer there. After updating to the latest version of Firefox on my Mac there is no progress bar for the page load. I really miss this feature and can't seem to find a way to obtain it. The tab has a circular progress wheel but this is useless for determining a stuck or slow loading page.
    PLEASE NOTE: I am typing this in from a Windows based work computer but am asking about my Apple MacBook Pro that i use at home.

    Firefox 4 saves the previous session automatically, so there is no longer need for the dialog asking if you want to save the current session.<br />
    You can use "Firefox > History > Restore Previous Session" to get the previous session at any time.<br />
    There is also a "Restore Previous Session" button on the default <b>about:home</b> Home page.<br />
    Another possibility is to use:
    * [http://kb.mozillazine.org/Menu_differences Firefox (Tools) > Options] > General > Startup: "When Firefox Starts": "Show my windows and tabs from last time"

  • Is the iPhone 5 in UAE missing any features?

    Hi guys,
    As far as anyone of you know is the iPhone 5 (and/or iOS in general) missing any features if bought from the UAE??
    Because as I recall at some point the iPhone 4 or 4S didn't offer FaceTime in UAE, so that's why I am asking!!
    Thank you

    FaceTime is not available on iPhones purchased in the UAE. It doesn't matter where you activate it or what version of the software you update it to. It can't be added to those phones. Ever. Sorry.

  • SH %LICMGR-3-LOG_LIC_FILE_MISSING: License file(s) missing for feature LAN_ENTERPRISE_SERVICES_PKG

    Hello,
    I have a log file that tells that the license file is missing for  LAN_ENTERPRISE_SERVICES_PKG, but I do not use any feature of that package
    NX3k# sh feature | include ena
    lldp                  1         enabled
    private-vlan          1         enabled
    sshServer             1         enabled
    tacacs                1         enabled
    telnetServer          1         enabled
    The log file:
    SH %LICMGR-3-LOG_LIC_FILE_MISSING: License file(s) missing for feature LAN_ENTERPRISE_SERVICES_PKG
    NX3k# sh license usage
    Feature                      Ins  Lic   Status Expiry Date Comments
                                     Count
    LAN_BASE_SERVICES_PKG         Yes   -   Unused Never       -
    LAN_ENTERPRISE_SERVICES_PKG   Yes   -   Unused Never       license missing
    **** WARNING: License file(s) missing. ****
    I would very appreciate if someone can help to disable the
    LAN_ENTERPRISE_SERVICES_PKG
    Regards,
    Egor.

    I found the solution. There is open bug regarding the issue.
    CSCtz91348 - LIC_FILE_MISSING: log after ".lic" file lost in SPROM
    https://www.cisco.com/cisco/psn/bssprt/bss?searchType=bugIdfilterData&bugId=CSCtz91348&filterData=EMPTY&QueryString=nexus%203000%20license%3Fst=kw&highLight=true&searchCriteria=nexus%25203000%2520license&isadvancedpage=false&SavedSearchType=false&advkeywords=&page=bstBugDetail&sortedCol=bugId&sortedDir=descending
    Maybe it will help somebody.
    Egori4.

  • Missing update features?

    I got the newest version of Lightroom (5.7.1 (assured by image 1)) after reading about the new features (HDR and Panorama merge) in the update window (shown in image 3).
    BUT when clicking "Search for updates" I still get the same window (image 3) that originaly made me update. And as one can see, in image 2, there is just no "Merge" - option at all.
    I'm looking forward to your solution.

    Thanks a lot!
    Von: dj_paige 
    Gesendet: Donnerstag, 23. April 2015 16:20
    An: Matthias Wiesemes
    Betreff:  missing update features?
    missing update features?
    created by dj_paige <https://forums.adobe.com/people/dj_paige>  in Photoshop Lightroom - View the full discussion <https://forums.adobe.com/message/7470467#7470467>

  • Missing Search feature

    I like the iPhone but, for anyone who uses the phone for work and has lots of contacts or info in his phone, the Search function is an absolute necessity...
    I have close to 500 business contacts. It is almost impossible to scroll through the whole list. I have keywords in the contact records to locate someone if I forget the name or company. If that happens with the iPhone, I am out of luck. I hope Apple adds the search feature on the first software update.
    Also, the business world has adopted the Adobe and MS Office document formats. Why have they been ommited in the iPhone? Is the target audience non-business people?
    Let the Flames begin...
    IBM Comp.   Windows XP  

    I would actually disagree that the iPhone isn't being targetted to business buyers. I think the only reason it seems that way is because of missing critical features like a find function, copy and paste, multi-recipient SMS, teathering, etc.
    Don't get me wrong, I'm not knocking the iPhone. I love it. And its exceeded my expectations as a Rev. A v1.0 device. But I think you might be making a leap there by assuming Apple isn't positioning this device to business users, when it's probably just that Apple was rushed to get the device out. (Remember how Apple delayed Leopard a few months because they had to pull the Leopard dev team to help with the iPhone to meet the June 29th launch date).

  • Flash Pro CC - missing export feature & dropshadows

    Hi everyone,
    recently started a new job and received Cloud membership for all new Adobe products.
    I primarily use Flash to create visuals for exporting as png's or into illustrator. I still haven't found a drawing tool for sequential imagery or UI guides that suits me better. So... two annoyances I've noticed straight off :-
    -Can anyone give me a workaround to the missing ability to export images as an fxg
    -why I can't change the angle or distance on Dropshadows now? Otherwise I'll have to find someway to go back to Flash 5.5.
    Thanks!

    Thanks - I'll try that.
    As for your own question. Simply put, illustrator just doesn't have the layers, timeline and animation features I use for all my complex UI layouts, states and interactive multimedia. I also find it a bit clunky and unintuitive in comparison to Flash for Vector drawing.
    If I was doing one state vector illustrations for print...perhaps. I need to do a lot more than that.
    Shame about the fxg though. It was the best way to export to illustrator for print AND multimedia.

  • Some thoughts on new features and workarounds

    Hey Gang,
    I am a recent FCP7 convert, actually used to use PPro up unitl 2005. A couple things have really bugged me and I think that these requests may be helpful to some of you or perhaps you know an easy workaround.
    One thing that is annoying is the lack of "Apple" keystrokes in the MacOS version. For isntance when trying to select multiple clips with the selection tool I am unable to hold down the Apple key to add additional clips to my selection.
    Secondly, we should have the option to when using paste attributes, to select what attributes we want to paste. I like going through a project adjusting volume throughought and then applying color correction. Many times I'll want a whole scene to use Magic Bullet Looks but I cannot copy and then "Paste Attributes" without changing all the audio as well. You can tell PPro what effects to remove but not to paste. Yes I can nest the sequence and apply the Magic Bullet Looks to the nested sequence, but that makes fine tuning additional clips more difficult.
    Why am I not able to cut an effect from the Effects Controls window or even drag and drop it onto multiple selected clips? That's another one that doesn't make sense. Again if I am color correcting and many clips need the same correction. I suppose I could create a million presets for all these things, but I don't want to clutter up my effects menu.
    In FCP I used to be able to rightclick a selected audio or video clip near an edit and find "Add Video/Audio Crossfade". Yes there is a shortcut for this but some times the dissovles show up on tracks that are highlighted on the left. This is another funny Premiere thing that I guess I'll get used to, but I am not sure why I need to highight the clip and the track when all I want to do is apply something to that clip?
    I won't even get into the stereo/mono track situation. That seems to have been covered all over the place.
    Just my 2 cents as I sit here editing away! Your thoughts?

    Please be sure to submit these feature requests where the right folks will be certain to see them:
    http://www.adobe.com/go/wish
    More on feedback for Premiere Pro: http://adobe.ly/q6pEBy

  • Missing shared feature Reporting Services Sharepoint and Reporting Services Add-in for Sharepoint products

    Hi, when I try to install SQL Server 2012 SP1 (ISO from Microsoft Download website) on a Windows Server 2012 and try to select the shared feature options: 
    - Reporting Services Sharepoint
    - Reporting Services Add-in for Sharepoint products
    They are both missing from the list.
    How do I solve this? Help!

    Hello,
    Did you download the SQL Server 2012 Express with Advanced Services edition from the Microsoft website? If so, this edition did not support SharePoint Integration mode.
    Just as Alberto post above, Business intelligence features are not all available in all editions of SQL Server 2012. You can refer to the following link about support features in Editions of SQL Server 2012:
    Reference:http://technet.microsoft.com/library/cc645993(SQL.110).aspx#Reporting
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • Missing shared feature Reporting Services Sharepoint

    We have all 64bit servers with Windows Server 2012 Standard Evaluation
    In our SP Farm we decided to have 1 WFE Server, 1 App Server & 1 Sql Server
    In Sql Server we installed "en_sql_server_2012_enterprise_edition_with_service_pack_2_x86_dvd"
    With that we got the following version installed
    Now when we are trying to install SSRS on our App Server we could not see the following Shared Features
    - Reporting Services Sharepoint
    - Reporting Services Add-in for Sharepoint products
    Please suggest me what am i missing or where i was wrong?
    Thanks,
    Naveen.

    Hi Naveen,
    From the image in your post, it seems that there may be something wrong with your setup file of SQL server 2012.
    Please make sure that you are installing SQL server with the intact setup file.
    And the installation of SQL will also be affected by the viruses in your system.
    So please make sure that there is no viruses in your App server.
    As this issue is regarding to SQL server installation, I recommend you to post the question in SQL forum:
    https://social.technet.microsoft.com/Forums/Lync/en-US/home?category=sqlserver.
    More experts will assist you, then you will get more information relation to SQL Server.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Missing pro features in 64 bit mode

    so i spent $4,000 on a new 64 bit computer, done everything in order to be 64 bit compatible only to find that pro features such as "exporting audio to quicktime" are missing from 64 bit mode.  now this is one of the most important features for folks like myself who wrtite music for advertising/film/tv.  are there plans to make this feature available in 64 bit?  the manual suggests that this feature will be gone from future releases. 

    It is believed that this is due to the limitation of the current Quicktime code that is still 32bit. Hope is around the corner with the announced June release of Final Cut X in 64bit and most likely QT 64bit.
    It surprised many that the recent Logic 9.1.4 release didn't include that fix if you think that the QT must be ready by now. Question is, how long do we have to wait for 9.1.5 with QT 64bit, or a possible Logic X written for OS X Lion.
    Trust me, you are not alone with your pain.
    Edgar Rothermich (DingDingMusic.com/Manuals)

  • Thoughts about the bin window - bugs or features and workarounds...

    Hi there,
    I really have big toubles using the bin window. It is even worse in OSX.5 (the only thing I don't like with OSX.5 and Logic8!).
    There are some Problems:
    1. I can't move any audio-files to wherever I want them to without Logic is copying them back into the audio-folder by saving the song. The problem is that I want Logic to copy imported audio files into the audio-folder but if I change something manually Logic should remember that without working against me. So for example: I am bouncing a lot of audio into the bounce folder. In Logic 7 all the finished bounces were located there on the hard drive. Easy to find and to organize. But in Logic 8 they are moved to the audio-folder and I have to search very carefully which files I want to send to my client. That's the biggest source of trouble for me right now.
    2. If I am making groups, Logic is sometimes copying even that audio-files back into the normal audio-folder. The problem here is: sometimes. I really have no idea what the problem is. Sometimes just some audiofiles are staying in the group (on the hd) for a couple of Logic-saves and then are moved back at the 10th save or something.
    3. I am not able to organize my groups and audio files very well. So if I have group that always is shown on top of the bin window and I have a audio-bounce called "zoo" it is the last one in the list. Then I have to move it the whole way up to the group. That costs me about a half our per day. Way too much. There should be some kind of easier handling. For example a second window for groups or something. The next one is that I have to call the group something like 001AASFX or ZZZ_SFX so that I am able to find it fast enough in the finder. It was so much easier to go the bounce folder in Logic 7 days.
    4. The hide-regions keycommand was unstable with OSX.4.10 but now with OSX.5 it is not working at all. If I choose a audiofile in the bin window and hit the standard keycommand for hiding regions just the region for that audiofile is hiding and instantly shown again. I want to have a shorter way to move my bounced files into the group that is the whole way up to the list's beginning.
    So I wonder if that are new features or if it is really buggy. I am not able to work with that structure right now and with that kind of unstable location behavior. Are there any workarounds, tips, tricks? Is there anyone who feels like me? May I hope for a update?
    That's it
    Xcell
    Message was edited by: Axel Rohrbach

    Hey Jim,
    thanks for the support. Seems to be something Apple has to work on. There are some posts and questions about the bin window in every forum I know but there is never a "this is not want we want and there are bugs" - thread. In fact the whole Logic 8 structure with the one-window-gui is great and works much better than I expected. So it is no general "what the **** are they doing"-thing
    Nevertheless, is there a way to get this to apple? I don't know if they are aware of these problems and perhaps the testers are making music with one bounce and that's it. Just one file is not that difficult to handle, organize and to find. But there are other users working in different ways (like us I think).
    @ David: I am sorry but you are wasting time and thread-space. If you don't say anything if you do not feel comfortable nothing will change. You are not able to let it rain in Austria (yet) but there are real guys working at apple and it's not a kind of wonder that there is logic at all. So am trying to discuss here something and hope for any reaction or attention and don't need any "go deeply into your self and you will find a way"-stuff. Thanks anyway to bring god back to that forum.
    Xcell
    Message was edited by: Axel Rohrbach

  • Wish List? Or Have I just missed the feature?

    I'm finding 2 features I'm really missing in Aperture:
    1. I wish the import/export function followed the Finder convention. I don't see my folder favorites and I see no way to add a folder to the favorities...
    Is there a way to do that?
    2. Some images require more than Aperture can give. I'd like to be able to double click or select an image for editing in another application like Photoshop.
    Is that possible? If so, how?
    Jeff

    That's really estrange, all the folder showing on the left hand side of the finder are shown in the left hand side of the import/export window in Aperture, at least in my case. There could be something wrong on your file system. Try a Mac OS X maintenance app as Cocktail or Onyx. The automate option fixes everything wrong in the system.

  • SQL Server Data Tools (SSDT) is missing some features

    I am using SSDT  for the Team Database development.   I have created the Database project on SSDT and bind this project with the TFS. And asked team to start working on SSDT instead of SSMS. Below are the list of challenge that team are facing
    1. There is no filter option in Project explorer to filter and search the database objects. Its taking time to find the Database objects.
    2. SQL command does not work against the SSDT project like sp_helptext , sp_help etc.
    3. Once we modify the code on SSDT we have to manually modify the Database in server, it should have some switching facility so if developer change the object in the SSDT it should effect in bind Database as well and also vice-versa.
     Am I missing to understand the use of SSDT or MS have plan to add these feature in future release?
    Regards Vikas Pathak

    I finally figured it out. I noticed that the third party software opens a connection with IMPLICIT_TRANSACTIONS ON by default. Turning IMPLICIT_TRANSACTIONS OFF at the beginning of the whole SQL script will allow individual SQL statements to autocommit and
    thus to release any locks. The SQL script should, therefore, be:
    set implicit_transactions off;
    Declare @execution_id bigint, @environment_id bigint
    SELECT
      @environment_id = reference_id
    FROM
      SSISDB.catalog.environment_references er
    INNER JOIN
      SSISDB.catalog.projects p
    ON
      p.project_id = er.project_id
    WHERE
      er.environment_name = N'&ETLENV#'
      AND p.name = N'&ETLPROJ#' ;
    EXEC SSISDB.catalog.create_execution
      @package_name=N'&;ETLPKG#'
      , @execution_id=@execution_id OUTPUT
      , @folder_name=N'&;ETLFOLD#'
      , @project_name=N'&;ETLPROJ#'
      , @use32bitruntime=False
      , @reference_id=@environment_id ;
    EXEC SSISDB.catalog.set_execution_parameter_value
      @execution_id
      , @object_type=50
      , @parameter_name=N'SYNCHRONIZED'
      , @parameter_value=1 ;
    EXEC SSISDB.catalog.start_execution @execution_id ;

  • Missing calendar features.

    Missing features:
    Search
    Color-Coding of calendars sync'ed via iCal
    "Week" View
    To Do Lists

    I agree... I feel the iCal calendar feature was an after thought. if you goto settings it is the only application you cannot customize or change settings. I hope they pay more attention to this app in the very near future with an update.
    It is very frustrating to see the many colors in my iCal calendar and then on the phone they are all over the place in that same boring blue / grey color..
    I hope Apple is listening..

Maybe you are looking for

  • How much does it cost to fix an iPod touch if the charger broke and is stuck in the iPod touch

    My next door neighbor has an iPod 4th generation. While the iPod was charging he had a friend over. His friend got mad and snapped the charger while it was charging. Now the mettle piece from the charger is stuck in it. How much is it to fix it. I wa

  • Member's of v$logfile shows broken in standby database

    Friends, DB: 11.2.0.3 - 64 bit OS: OEL 6.3 64 bit just now i set up the physical standby database using rman duplicate..... while duplicating i received this error...but i ignored...that error... RMAN-05535: WARNING: All redo log files were not defin

  • SYSTEM SETTINGS ISSUE

    i am having problem with my system preference settings. whenever i try to open it, it is not responding. I am using OS 10.8.4. PLEASE HELP ...

  • Is it possible  Hide a column in BPS layout "WEB" ?

    Hi, Is it possible to hide a column in a "WEB" BPS layout  ? Have you an example to hide a column in web thanks to Java and where insert it ?

  • NI CRIO 9073 doubt regarding compatibility

    Hello,              I have installed 2011 version of labview in one PC and on another PC I have 9.0 version. More, I would like to write a simple program in MODBUS RTU in such a way that can communicate with pressure sensor(Keller) that is already co