This is just an idea where you may start looking.
In swing, the gui components do use a layout manager ( LayoutManagers ) whose are responsible to place each graphic element in its place.
They are bit tricky, because the logic to layout the elements vary from LayoutManager to another, most of the times you have to combine them.
LayoutManagers usually query the component they are laying out to know what is the minimum size, the maximum size and the preferred size. Some lym completely ignore this information, some of them use it partially.
Well the suggestion would be to use a layout manager that honors the preferred size ( or the maximum ) and then add a mouse listener over other element. When then the element is dragged you may programaticlly increase/decrease the max/min/preff size of your component ( most likely a JTextArea ) and let the LYM resize the visual apparence of the component.
So it would look like this pseudo:
public App {
private JComponent container;
private JComponent myTarget;
private JComponent dragComponent;
public void someWhere() {
container.setLayoutManager( someLayoutManager() );
container.add( myTarget );
container.add( dragComponent );
// warn: not actual method names, I don't remember them
dragComponent.addMouseListener( new MouseAdapter() {
public void mouseDragged( MouseEvent me ) {
Point point me.getPoint();
int h = myTarget.getHeight();
int w = myTarget.getWidth();
// Do some math to know if you have to add or subtract.
int movement = // -20, +20, whatever.
myTarget.setMaximumSize( h + ( movement ) , w );
}
} );
}
}
That's just a pseudo code, so don't shoot me.
Again the idea is to find the right layoutmanager and add a mouse listener to know where the component is being dragged. Each time the component is dragged you change the size of the target component and let the LayoutManager reshape the component.
I hope this helps.
p.s. Swing also have drag/drop support, see if it helps.