List of utility methods to do JLabel Size
void | adjustLabelSizes(List Adjusts the label sizes. Dimension max; max = new Dimension(0, 0); for (JLabel label : labels) { if (max.getWidth() < label.getPreferredSize().getWidth()) max = label.getPreferredSize(); for (JLabel label : labels) label.setPreferredSize(max); ... |
Dimension | getLabelPreferredSize(JLabel label) Returns the preferred size for a label. return getLabelPreferredSize(label, "Sample text"); |
Dimension | getPreferredLabelSize(JLabel c, int widthHint) get Preferred Label Size View v = (View) c.getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey); if (v == null) { return c.getPreferredSize(); String text = c.getText(); Icon icon = c.isEnabled() ? c.getIcon() : c.getDisabledIcon(); int hAlign = c.getHorizontalAlignment(); int vAlign = c.getVerticalAlignment(); ... |
Dimension | getPreferredSize(JLabel label) get Preferred Size if (label == null) { throw new IllegalArgumentException("label==null"); Dimension preferredSize = null; Dimension dm = getTextDimension(label); dm = extendByIcon(label, dm); dm = extendByBorder(label, dm); preferredSize = dm; ... |
void | makeSameSize(int alignment, JLabel... labels) make Same Size makeSameSize(labels);
for (JLabel label : labels) {
label.setHorizontalAlignment(alignment);
|
void | resizeLabel(JLabel label, Dimension newDim) resize Label label.setPreferredSize(newDim); |