Changeset 8358 in josm


Ignore:
Timestamp:
2015-05-16T00:49:42+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11290 - fix width of auto_increment buttons for Aqua & Nimbus look and feels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java

    r8342 r8358  
    1010import java.awt.GridBagLayout;
    1111import java.awt.GridLayout;
     12import java.awt.Insets;
    1213import java.awt.event.ActionEvent;
    1314import java.awt.event.ActionListener;
     
    3435import java.util.TreeSet;
    3536
     37import javax.swing.AbstractButton;
     38import javax.swing.BorderFactory;
    3639import javax.swing.ButtonGroup;
    3740import javax.swing.Icon;
     
    695698                    aibutton.setMargin(new java.awt.Insets(0,0,0,0));
    696699                    aibutton.setFocusable(false);
     700                    saveHorizontalSpace(aibutton);
    697701                    bg.add(aibutton);
    698702                    try {
     
    731735                    }
    732736                });
     737                saveHorizontalSpace(releasebutton);
    733738                pnl.add(releasebutton, GBC.eol());
    734739                value = pnl;
     
    737742            p.add(value, GBC.eol().fill(GBC.HORIZONTAL));
    738743            return true;
     744        }
     745
     746        private static void saveHorizontalSpace(AbstractButton button) {
     747            Insets insets = button.getBorder().getBorderInsets(button);
     748            // Ensure the current look&feel does not waste horizontal space (as seen in Nimbus & Aqua)
     749            if (insets != null && insets.left+insets.right > insets.top+insets.bottom) {
     750                int min = Math.min(insets.top, insets.bottom);
     751                button.setBorder(BorderFactory.createEmptyBorder(insets.top, min, insets.bottom, min));
     752            }
    739753        }
    740754
Note: See TracChangeset for help on using the changeset viewer.