jtable单元中的按钮和文本框对齐 [英] Button and Textbox alignment in a jtable cell

查看:144
本文介绍了jtable单元中的按钮和文本框对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,在某些单元格中同时包含按钮和文本框.现在,我可以将这两个组件都放在表格单元格中.感谢您的 OscarRyz的代码.现在我的问题是我必须对齐这些组件,以使按钮位于单元格的最右端,并且文本框应从单元格的最左端开始至按钮的开头. (简单地说,它们应该彼此相邻并占据整个单元格.)如何在单元格内对齐它们?

I have a table which has both button and text box in some cells. Now I am able to put both the components in the table cell. Thanks for OscarRyz's code. Now my problem is I have to align these components such that the button is to extreme right of the cell and text box should start from the extreme left of the cell to the start of the button. (In simple, they should be adjacent to each other and occupy entire cell.) How can I align them inside the cell?

当前看起来像这样

但是我正在寻找的是这样的视图,

But what I was looking is for the view something like this,

我看过组件边框代码,但是可以t弄清楚如何在桌子上使用它.

I have looked at Component Border code but can't figure out how to use it for the table.

任何帮助将不胜感激.

推荐答案

带有BorderLayoutJPanel,您将JTextField放入BorderLayout.CENTER并将JButton放入BorderLayout.EAST

A JPanel with BorderLayout where you put the JTextField in the BorderLayout.CENTER and the JButton in the BorderLayout.EAST should do it.

以及供以后参考:将布局管理器的可视指南添加为书签如果您正在寻找LayoutManager

And for future reference: bookmark the Visual guide to layout managers if you are looking for a LayoutManager

这篇关于jtable单元中的按钮和文本框对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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