我如何对齐的JTextField中的文本? [英] How do I align text within a JTextField?

查看:376
本文介绍了我如何对齐的JTextField中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JTextField具有相当大的发展,文本但是并不像我想它。

I have a JTextField with rather big bounds, the text however does not behave like I want it to.

 _________________
|                 |
|                 |
|text             |
|                 |
|_________________|

如何将我做,所以我的文字对齐像这样

how would i do it so my text aligns like this

 _________________
|text             |
|                 |
|                 |
|                 |
|_________________|

编辑: 使用的JTextArea 固定我的问题。谢谢你。

Using JTextArea fixed my problem. Thank you.

推荐答案

使用的JTextArea 所需的垂直对齐方式。

Using JTextArea is required for vertical alignment.

的JTextField 不允许超过垂直对齐方式的控制。

JTextField does not allow for control over vertical alignment.

JTextArea myLabel = new JTextArea();

和调用:

myLabel.setHorizontalAlignment(SwingConstants.LEFT);
myLabel.setVerticalAlignment(SwingConstants.TOP);

这篇关于我如何对齐的JTextField中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆