final WebTextArea textArea = new WebTextArea ( text, 3, 20 );
textArea.setLineWrap ( true );
textArea.setWrapStyleWord ( true );
// Scroll pane that will be sized by resize corner
final WebScrollPane scrollPane = new WebScrollPane ( textArea );
overlayPanel.setComponent ( scrollPane );
// Resize corner displayed as overlay
final JComponent resizer = new JComponent ()
{
@Override
protected void paintComponent ( final Graphics g )
{
final Graphics2D g2d = ( Graphics2D ) g;
final Object aa = GraphicsUtils.setupAntialias ( g2d );
g2d.setPaint ( isEnabled () ? Color.GRAY : Color.LIGHT_GRAY );
if ( getComponentOrientation ().isLeftToRight () )
{
g2d.drawLine ( 0, 10, 10, 0 );
g2d.drawLine ( 4, 10, 10, 4 );
g2d.drawLine ( 8, 10, 10, 8 );
}
else
{
g2d.drawLine ( 11, 10, 1, 0 );
g2d.drawLine ( 7, 10, 1, 4 );
g2d.drawLine ( 3, 10, 1, 8 );
}
GraphicsUtils.restoreAntialias ( g2d, aa );
}
@Override
public Dimension getPreferredSize ()
{
return new Dimension ( 12, 12 );
}
};
resizer.setCursor ( Cursor.getPredefinedCursor ( Cursor.SE_RESIZE_CURSOR ) );
resizer.addPropertyChangeListener ( WebLookAndFeel.ORIENTATION_PROPERTY, new PropertyChangeListener ()
{
@Override
public void propertyChange ( final PropertyChangeEvent evt )
{
resizer.setCursor ( Cursor.getPredefinedCursor (
resizer.getComponentOrientation ().isLeftToRight () ? Cursor.SE_RESIZE_CURSOR : Cursor.SW_RESIZE_CURSOR ) );
}
} );
// Resize adapter
final MouseAdapter mouseAdapter = new MouseAdapter ()
{
private Dimension startDim = null;
private Point start = null;
@Override
public void mousePressed ( final MouseEvent e )
{
if ( resizer.isEnabled () && SwingUtilities.isLeftMouseButton ( e ) )
{
startDim = scrollPane.getSize ();
start = MouseInfo.getPointerInfo ().getLocation ();
}
}
@Override
public void mouseDragged ( final MouseEvent e )
{
if ( start != null )
{
final boolean ltr = resizer.getComponentOrientation ().isLeftToRight ();
final Point p = MouseInfo.getPointerInfo ().getLocation ();
final Dimension ps = scrollPane.getLayout ().preferredLayoutSize ( scrollPane );
final Dimension newPs = new Dimension ( startDim.width + ( ltr ? p.x - start.x : start.x - p.x ),
startDim.height + ( p.y - start.y ) * 2 );
scrollPane.setPreferredSize ( SwingUtils.max ( ps, newPs ) );
scrollPane.revalidate ();
scrollPane.repaint ();
}
}
@Override
public void mouseReleased ( final MouseEvent e )