Java JComponent Width fixWidth(JComponent c, int width)

Here you can find the source of fixWidth(JComponent c, int width)

Description

fix Width

License

Apache License

Declaration

public static void fixWidth(JComponent c, int width) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;

import java.awt.*;

public class Main {
    public static void fixWidth(JComponent c, int width) {
        Dimension ps = c.getPreferredSize();
        c.setPreferredSize(new Dimension(width, ps.height));
        c.setMinimumSize(c.getPreferredSize());
        c.setMaximumSize(c.getPreferredSize());
    }/* w  w w  .ja  v a  2  s  .com*/
}

Related

  1. calculateCharWidth(JComponent component, int numChars)
  2. clearWidth(JComponent comp)
  3. clipString(final JComponent component, final String string, final int avaiableWidth)
  4. clipStringifNeeded(final JComponent component, final String string, final int avaiableWidth)
  5. createTitledPanel(JComponent component, String title, int width, int height)
  6. getMinimumWidth(JComponent comp)
  7. getRectangle(JComponent comp)
  8. getRectangle(JComponent comp)
  9. initComponent(JComponent component, String title, int width, int height)