JButton with three dots

Hi,
how can I recognize whether a text within the JButton fit the bounds to avoid the "..." text instead of the proper value?

This might work (untested):
          FontMetrics fontMetrics = yourButton.getFontMetrics(yourButton.getFont());
          textWidth = fontMetrics.stringWidth(yourButton.getText());
          int buttonWidth button.getWidth()-10;  //subtract the button's margins, probably a better way to do this
          if(textWidth > buttonWidth){
                    //the button will display ...
          }

Similar Messages

  • Why method parameter end with three dots

    i generate hibernate pojos + hybernate mapping + dao. in dao class i have some doubt in coding please clear.
    package org.triology.blog.hibernate;
    import org.triology.blog.GenericDAO;
    import java.io.Serializable;
    import java.lang.reflect.ParameterizedType;
    import java.util.List;
    import java.util.Map;
    import org.hibernate.Criteria;
    import org.hibernate.FlushMode;
    import org.hibernate.Query;
    import org.hibernate.LockMode;
    import org.hibernate.Session;
    import org.hibernate.criterion.Restrictions;
    import org.hibernate.criterion.Criterion;
    import org.hibernate.criterion.Example;
    * Generated at Wed Jul 30 16:57:35 IST 2008
    * @author Salto-db Generator v1.0.16 / Pojos + Hibernate mapping + Generic DAO
    * @see http://www.hibernate.org/328.html
    public abstract class AbstractHibernateDAO<T, ID extends Serializable> implements GenericDAO<T, ID> {
    private Session session;
    private Class<T> persistentClass;
    public AbstractHibernateDAO() {
    this.persistentClass = (Class<T> ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
    public void setSession(Session session) {
    this.session = session;
    protected Session getSession() {
    if (session == null)
    session = HibernateUtil.getSessionFactory().getCurrentSession();
    return session;
    public Class<T> getPersistentClass() {
    return persistentClass;
    @SuppressWarnings("unchecked")
    public T getById(ID id) {
    return (T) getSession().get(getPersistentClass(), id);
    @SuppressWarnings("unchecked")
    public T getById(ID id, boolean lock) {
    if (lock) {
    return (T) getSession().get(getPersistentClass(), id,
    LockMode.UPGRADE);
    } else
    return getById(id);
    @SuppressWarnings("unchecked")
    public T loadById(ID id) {
    return (T) getSession().load(getPersistentClass(), id);
    public void save(T entity) {
    getSession().save(entity);
    public void update(T entity) {
    getSession().update(entity);
    public void saveOrUpdate(T entity) {
    getSession().saveOrUpdate(entity);
    public void delete(T entity) {
    getSession().delete(entity);
    public void deleteById(ID id) {
    getSession().delete(loadById(id));
    @SuppressWarnings("unchecked")
    public List<T> findAll() {
    return findByCriteria();
    * Use this inside subclasses as a convenience method.
    @SuppressWarnings("unchecked")
    protected List<T> findByCriteria(Criterion... criterion) {
    Criteria crit = getSession().createCriteria(getPersistentClass());
    for (Criterion c : criterion) {
    crit.add(c);
    return crit.list();
    * Find by criteria.
    @SuppressWarnings("unchecked")
    public List<T> findByCriteria(Map criterias) {
    Criteria criteria = getSession().createCriteria(getPersistentClass());
    criteria.add(Restrictions.allEq(criterias));
    return criteria.list();
    * This method will execute an HQL query and return the number of affected entities.
    protected int executeQuery(String query, String namedParams[], Object params[]) {
    Query q = getSession().createQuery(query);
    if (namedParams != null) {
    for (int i = 0; i < namedParams.length; i++) {
    q.setParameter(namedParams, params[i]);
    return q.executeUpdate();
    protected int executeQuery(String query) {
    return executeQuery(query, null, null);
    * This method will execute a Named HQL query and return the number of affected entities.
    protected int executeNamedQuery(String namedQuery, String namedParams[], Object params[]) {
    Query q = getSession().getNamedQuery(namedQuery);
    if (namedParams != null) {
    for (int i = 0; i < namedParams.length; i++) {
    q.setParameter(namedParams[i], params[i]);
    return q.executeUpdate();
    protected int executeNamedQuery(String namedQuery) {
    return executeNamedQuery(namedQuery, null, null);
    @SuppressWarnings("unchecked")
    public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
    Criteria crit = getSession().createCriteria(getPersistentClass());
    Example example = Example.create(exampleInstance).excludeZeroes().enableLike().ignoreCase();
    for (String exclude : excludeProperty) {
    example.excludeProperty(exclude);
    crit.add(example);
    return crit.list();
    in above class my doubt is
    * Use this inside subclasses as a convenience method.
    @SuppressWarnings("unchecked")
    protected List<T> findByCriteria(Criterion... criterion) {
    Criteria crit = getSession().createCriteria(getPersistentClass());
    for (Criterion c : criterion) {
    crit.add(c);
    return crit.list();
    why we pass findByCriteria parameter end with three dots (Criterian...)
    Edited by: BalaTTPL on Jul 31, 2008 8:53 AM

    protected List<T> findByCriteria(Criterion... criterion) {
        Criteria crit = getSession().createCriteria(getPersistentClass());
        for (Criterion c : criterion) {
            crit.add(c);
        return crit.list();
    }The "Criterion..." argument just means that you can call the method with any number (zero or more) of Criterion references. Within the method criterion is treated like an array - for instance in the for loop.
    The notation is known as "varargs" and is described in the JDK1.5 [Tech notes|http://java.sun.com/javase/6/docs/technotes/guides/language/varargs.html].

  • Cd... with three dots after the cd would take you back two directories NOT ANYMORE

    .. one dir
    ... two dirs
    does not work anymore

    What operating system?  I went back to Windows XP and it doesn't do that.  It simply ignores three dots, just like it does with current operating systems.
    It is always helpful if you would include version and environment information when statements are made.  Without that, everybody has to end up guessing.
    .:|:.:|:. tim
    this thing on the top of the screen does not help?
    Windows Server forums > 
    Windows Server 2012 General

  • What does the little bubble with three dots on the lower left side of the Messages screen on my iPhone 4 mean?

    frequently, after messages are exchanged on my iPhone 4 there is a little bubble on the lower left of the message screen that has three dots. What do they mean?

    It means the other person is typing.

  • Camera's automatic focus function stopped working. Factory reset did not work. (Yes the three dots were pressed). What should I do?

    I enjoyed taking pictures with one touch of the screen but now the camera does not focus no matter what I do. I did try to take it without the camera sub-menus by pushing the button with three dots and without. The focus simply does not work!
    What should I do?
    I contacted LG support and they told me the whole thing might take 1-2weeks. That seems too long for me to live without a phone. Any suggestions?
    Thanks for reading my question,
    Josh

        Let's get this resolved kimjoshy! If you completed a factory reset and still unsuccessful please respond to my direct message so I may review options. Thank you.
    TominqueBo_VZW
    Follow us on Twitter @VZWSupport

  • Can I turn off the iMessage typing indicator bubble with the three dots off?

    I currently use software on iOS 6 that disables my outgoing bubble with the three dots that lets whoever I'm communicating with know that I'm typing. I want to update to iOS 7, but can't find any information about whether the option to disable the indicator is present in the new settings. Thanks in advance to anyone who can't point me in the right direction.

    dr.klm wrote:
    I don't see any "typing" in iOS 7.
    You only see them if someone is iMessaging you. You won't see them for SMS. They've been there since iMessages was released.

  • The three dots in imessage won't go away

    I have been in a text message conversation with someone and I am getting the three dots to indicate that they are typing. However, I never received a message and the three dots have just beensitting there in our conversation for like 12 hours. Does anyone know why this is?

    It could be that the other person has left Messages open and the keyboard up on their phone. Ignore the dots and click the Home button to leave Messages.

  • JButton with Icon question

    In the Toolbar I have a JButtons. I created the JButtons with Icons.
    When I click on a button it is putting a dotted line right around the Icon. How can I get rid of that? Thanks.

    You're talking about the focus rectangle. If memory serves in the SwingSet demo there's an entire panel devoted to buttons and such. You can find something there to help you. The toggle in the example is labeled "Paint Focus", and it does what you want.

  • Why does data/3g work on my O2 sim but not with Three sim (iphone 5)?

    as the title says...
    i have been using an O2 sim for a while in my iphone 5 without problems.  today i tried a sim from the three network.  calls and texts work fine, but i can not get any data connection to work.
    i have been on the phone to three and tried many different settings/network resets etc. 
    when  i put the sim in the phone updated automatically - i was directed to go to "settings>about", where it asked me to update. i clicked yes. after a long phone call with three, they say all my settings are correct. 
    i have tried the same sim in an iphone 4 and the data works fine with it, so there's definitely something a miss with the actual iphone 5 handset.
    i am running ios 7.0.4
    (in setting > about)
    carrier: Three 15.6
    Model: ND662B/A
    Modem firmware 5.02.00
    any ideas?
    thanks 

    Hi. :)
    Thanks for the reply.
    When I insert the three SIM card there is no option for apn. From what I've read, three do not allow it. The apn settings show up fine with my O2 sim.
    I have noticed something strange when playing about with the data. If I open tunein radio app with wifi and steam a live broadcast, if I switch on data and then switch off wifi, the stream still plays. Then when I look at my data usage it shows data has been used. If I try and use data at the start of the app, it will not connect and I still can't get the data to work on anything else. So some slight element of the data connection is getting through.

  • I am trying to hook my macbook pro to a sony bravia TV via DVI to HDMI cable and the TV will not recognize the signal. The same set up has worked with three other, though different televisions. Any thoughts?

    I am trying to hook my MacBook Pro to a Sony Bravia TV via DVI to HDMI cable and the TV will not recognize the signal. I have used the same setup with three other TV's, each a different brand with no problem. Any ideas?

    Is the TV set to take input from the HDMI connection?
    On your computer, if you open the Displays preferences and do not see an Arrangement tab (or there is an Arrangement tab that shows only a single monitor) then there is something physically wrong with your connection.  Try clicking Detect Displays just to see if the computer can now sense the presence of the connection.  Check your connections.
    If you do have an Arrangement tab, and it shows two screens, then click Gather Windows to bring the TV's Displays preferences on to your main screen if the TV is not yet showing an image.  Set the proper resolution (probably 720p, 1080i, or 1080p).  Set the refresh rate (probably 60Hz) if that preference is shown.  You should see a picture at this point.  I  recommend turning off mirrored displays if it is enabled.

  • I have three different computer with three different libraries. All are under the same sign on and password, can I sync them so I have the same content on all computers?

    I have three different computer with three different libraries, but all are under the same sign on and password. Can I sync the libraries somehow and get all my music and movies on each computer?

    Can you just create a new "Playlist", name it Bob Seger and drag what you want into the Playlist.
    File/New Playlist

  • We have Windows 7 Deluxe Home Edition on our Computer with three of us, but only I see our iTunes Library. How can the other two see it on the one computer?

    We have Windows 7 Deluxe Home Edition on our family's computer with three users. I can only see our iTunes library when I get on the computer, it is blank on the other two users. I must be doing something wrong beacuse thety cannot access our own library. Can this be fixed?

    Try homesharing. I am not sure if this will keep them seprate but this is really close to what you are looking for.http://www.apple.com/itunes/inside-itunes/2010/01/sharing-itunes-libraries-at-ho me.html

  • The screen on my ipod mini is black with small dots.  It looks like space.  Can I do anything to fix it?

    Hi,
    My screen on my ipod mini is black with small dots.  It looks like space.  Does anyone have any suggestions, please?
    Thank you. Cindy

    This is an iPod mini, not the iPod nano in your profile info?
    If you have not already, try doing a reset
    http://support.apple.com/kb/ht1320
    This restarts the iPod.  It is not erased.
    If that does not help, the next thing to try would be a Restore (as long as the iPod is still recognized by iTunes when connected.  The Restore button is in the iPod's Summary screen in iTunes.  This DOES erase the iPod, reinstall its software, and set it to default settings.  If a software problem on the iPod is the cause, a Restore should fix it.
    If the screen still has this problem after doing a Restore, it is likely to be a hardware problem on the iPod.

  • I currently run Mac Pro with three hard drives. Can I dual boot or even triple boot with Snow Leaopard on one drive and Mountain Lion or Lion on others?

    I currently run Mac Pro with three hard drives. Can I dual boot or even triple boot with Snow Leopard on one drive and Mountain Lion or Lion on others?
    I need to keep Snow Leopard so that I can run some old softward.

    If you are careful you can put at least two on one drive, having Recovery from Lion and Mountain Lion on their own drives though.
    CCC can clone Lion Recovery - great for moving or backup.

  • How do I create a dropdown with three options so that only one is visible in a form (non-flowable)

    I'm working on a form which needs to provides three options for the user out of a drop down list. When the user chooses one option, only that subform is to be visible. Two of the three subforms are text fields, and the third subform is a series of fields which are editable by the user.
    How do i create a dropdown with three options in it, so that in each instance only one subform is visible? This needs to happen in the same space on the main form.

    Hi Nellie,
    Here is the form back to you. There were three main issues:
    In order for dynamic behaviour, like showing and hiding, the form must be saved as a Dynamic XML Form in the save-as dialog.
    While you can use a minus sign when naming objects and subforms, it will cause scripts to fail. I have changed the name of the subforms so that they now use an underscore.
    The dropdown had specified values in the Object > Binding palette (1, 2, 3), so the script needs to use these in the if statements.
    When sharing forms on Acrobat.com, the best option is to select the file in your workspace and then click Publish. This will make it available to anyone who has the published URL.
    I hope that helps,
    Niall

Maybe you are looking for