public void pack() { BufferedImage _bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); Graphics g = _bi.getGraphics(); Rectangle _bounds = ProcessUtils.drawText( (Graphics2D) g, 0, 0, this.getSize().width, this.getText(), Orientation.CENTER); this.setSize(this.getSize().width, _bounds.height + 10); }