Created
January 30, 2019 18:31
-
-
Save maifeeulasad/6dfee20882d237c925dda24f4e193655 to your computer and use it in GitHub Desktop.
Extending size of JFrame according to JTextArea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.scene.input.KeyCode; | |
import javax.swing.*; | |
import javax.xml.soap.Text; | |
import java.awt.event.KeyAdapter; | |
import java.awt.event.KeyEvent; | |
import java.security.Key; | |
public class Test extends JFrame { | |
JTextArea jTextArea; | |
Test() | |
{ | |
this.setSize(200,80); | |
jTextArea=new JTextArea(); | |
this.add(jTextArea); | |
jTextArea.addKeyListener(new KeyAdapter() { | |
@Override | |
public void keyPressed(KeyEvent e) { | |
if(e.getKeyCode()==KeyEvent.VK_ENTER) | |
{ | |
Test.this.setSize(200,Test.this.getSize().height+jTextArea.getFont().getSize()); | |
} | |
} | |
}); | |
this.setVisible(true); | |
} | |
public static void main(String[] args){ | |
Test o=new Test(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment