mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

jTextPane about alignment #681

Closed wyj3531 closed 2 years ago

wyj3531 commented 2 years ago

0EC41E4A-A9FB-47cc-BEF4-9308BF3A1711

just like pic ,i use jTextPane add the button(data1), and input the text( testest).and how i make the both in center vertical . i custom a boxview can make the button in center vertical . but the input text how to do ?

mgarin commented 2 years ago

What you're probably looking for is aligning components by their baseline.

I recommend reading this official article on Swing's GroupLayout - https://docs.oracle.com/javase/tutorial/uiswing/layout/groupExample.html Specifically "Vertical layout" section that has some examples.

I'm personally not completely sure whether JTextPane supports baseline alignment or not, but considering that JTextArea does - I don't see any reasons why JTextPane wouldn't.