Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
806 views
in Technique[技术] by (71.8m points)

java - Is it possible jtable row in optionDialog box

I have a jtable.

Some of the cells contain very long strings and trying to scroll left and right through it is difficult. My question is whether it is possible to show a row from a JTable in a pop-up eg showDialog type box (ie where the selected row is organised as a column).

Even a link to a tutorial would do.

I have scoured the internet but I don't think I'm really using the correct keywords as I get a lot of right-click options.

If this is not possible are there any other suggestions for how to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I want to show all the values in the row, each in their cel, organised vertically- that's what I meant by 'in a column'.

That should be in the question, not in the comment.

There is no default functionality for this but you can do it yourself.

You could create a JPanel (maybe using a GridBagLayout), with two labels in a row to represent the data in a column of the selected row of the table.

For the data in the first label you would use the getColumnName(...) method of the TableModel.

For the data in the second label you would use the getValueAt(...) method of the TableModel.

Another option is to simply display a tool tip for the cell. See the section from the Swing tutorial on Specifying ToolTips For Cells for more information.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...