Frage

How could I set 2 textfields as one viewport and set each textfield to expand as more text is typed in, rather than adding a scroll bar to each textfield.

I find it hard to describe it with words so I have uploaded a sketch.

enter image description here

War es hilfreich?

Lösung

You could do something like this, everytime you type something in, it gets bigger:

field.addKeyListener(this);

And in your KeyListener implementation this:

@Override
public void keyReleased(KeyEvent arg0) {
    field.setSize(field.getWidth() + 10, field.getHeight());
    repaint();
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top